Skip to content

Commit f1c23fe

Browse files
update again
1 parent c305bb5 commit f1c23fe

40 files changed

Lines changed: 810 additions & 753 deletions

Code/ContextSystem/Contexts/Control/Loops/OverLoop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ with @plr
4949
over &inventory
5050
with *item
5151
52-
Print "found item {ItemInfo *item type}"
52+
Print "found item {*item -> type}"
5353
end
5454
# its important to remember that the variable type in "with" keyword
5555
# MUST match the value type inside the collection,

Code/ContextSystem/Contexts/ValueExpressionContext.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using SER.Code.TokenSystem.Tokens;
1111
using SER.Code.TokenSystem.Tokens.Interfaces;
1212
using SER.Code.ValueSystem;
13+
using SER.Code.ValueSystem.PropertySystem;
1314

1415
namespace SER.Code.ContextSystem.Contexts;
1516

@@ -194,7 +195,22 @@ public override TryGet<Value> GetReturnValue()
194195
Value current = value;
195196
foreach (var prop in _propertyNames)
196197
{
197-
if (!current.Properties.TryGetValue(prop, out var propInfo))
198+
if (current is not IValueWithProperties propVal)
199+
{
200+
return $"{current} does not have any properties.";
201+
}
202+
203+
Console.WriteLine(propVal.Properties.Select(kvp => $"{kvp.Key} -> {kvp.Value.ReturnType}").JoinStrings(", "));
204+
205+
IValueWithProperties.PropInfo? propInfo;
206+
if (propVal.Properties is IValueWithProperties.IDynamicPropertyDictionary dynamicDict)
207+
{
208+
if (!dynamicDict.TryGetValue(prop, out propInfo))
209+
{
210+
return $"{current} does not have property '{prop}'.";
211+
}
212+
}
213+
else if (!propVal.Properties.TryGetValue(prop, out propInfo))
198214
{
199215
return $"{current} does not have property '{prop}'.";
200216
}
@@ -223,7 +239,24 @@ public override TryAddTokenRes TryAddToken(BaseToken token)
223239
{
224240
foreach (var type in types)
225241
{
226-
if (Value.GetPropertiesOfValue(type).TryGetValue(token.RawRep, out var property))
242+
if (type == typeof(ReferenceValue))
243+
{
244+
_exprRepr += $" {token.RawRep}";
245+
_lastValueType = new UnknownTypeOfValue();
246+
goto found;
247+
}
248+
249+
var props = Value.GetPropertiesOfValue(type);
250+
if (props is IValueWithProperties.IDynamicPropertyDictionary dynamicDict)
251+
{
252+
if (dynamicDict.TryGetValue(token.RawRep, out var dynamicProp))
253+
{
254+
_exprRepr += $" {token.RawRep}";
255+
_lastValueType = dynamicProp.ReturnType;
256+
goto found;
257+
}
258+
}
259+
else if (props?.TryGetValue(token.RawRep, out var property) is true)
227260
{
228261
_exprRepr += $" {token.RawRep}";
229262
_lastValueType = property.ReturnType;

Code/Examples/HotPotatoScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Wait 3s
3131
over {@potatoCarrier -> inventory}
3232
with *item
3333
34-
if {ItemInfo *item type} isnt "GunA7"
34+
if {*item -> type} isnt "GunA7"
3535
continue
3636
end
3737

Code/Extensions/EnumExtensions.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
namespace SER.Code.Extensions;
1+
using System;
2+
using SER.Code.ValueSystem;
3+
4+
namespace SER.Code.Extensions;
25

36
public static class EnumExtensions
47
{
5-
public static IEnumerable<T> GetFlags<T>(this T value) where T : struct, Enum
8+
public static EnumValue<T> ToEnumValue<T>(this T enumValue) where T : struct, Enum
69
{
7-
return from T flag in Enum.GetValues(typeof(T))
8-
where Convert.ToUInt64(value) != 0
9-
where Convert.ToUInt64(flag) != 0
10-
where value.HasFlag(flag)
11-
select flag;
10+
return new EnumValue<T>(enumValue);
1211
}
13-
}
12+
}

Code/MethodSystem/MethodDescriptors/IReferenceResolvingMethod.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

Code/MethodSystem/MethodIndex.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
using SER.Code.Helpers.ResultSystem;
66
using SER.Code.MethodSystem.BaseMethods;
77
using SER.Code.MethodSystem.Structures;
8+
using SER.Code.ValueSystem.PropertySystem;
89

910
namespace SER.Code.MethodSystem;
1011

1112
public static class MethodIndex
1213
{
14+
static MethodIndex()
15+
{
16+
ReferencePropertyRegistry.Initialize();
17+
}
18+
1319
public static readonly Dictionary<string, Method> NameToMethodIndex = [];
1420
public static readonly Dictionary<FrameworkBridge.Type, List<Method>> FrameworkDependentMethods = [];
1521

Code/MethodSystem/Methods/DoorMethods/DoorInfoMethod.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

Code/MethodSystem/Methods/HTTPMethods/JSONInfoMethod.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

Code/MethodSystem/Methods/HealthMethods/DamageInfoMethod.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

Code/MethodSystem/Methods/IntercomMethods/IntercomInfoMethod.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SER.Code.ArgumentSystem.BaseArguments;
66
using SER.Code.ArgumentSystem.Structures;
77
using SER.Code.Exceptions;
8+
using SER.Code.Extensions;
89
using SER.Code.MethodSystem.BaseMethods.Synchronous;
910
using SER.Code.ValueSystem;
1011

@@ -36,7 +37,7 @@ public override void Execute()
3637
{
3738
ReturnValue = (Args.GetOption("mode")) switch
3839
{
39-
"state" => new StaticTextValue(Intercom.State.ToString()),
40+
"state" => Intercom.State.ToEnumValue(),
4041
"speaker" => new PlayerValue(Player.ReadyList.ToList().Where(plr => plr.ReferenceHub == Intercom._singleton._curSpeaker)),
4142
"cooldown" => new DurationValue(TimeSpan.FromSeconds(Intercom.State == IntercomState.Cooldown ? Intercom._singleton.RemainingTime : 0)),
4243
"speechtimeleft" => new DurationValue(TimeSpan.FromSeconds(Intercom.State == IntercomState.InUse ? Intercom._singleton.RemainingTime : 0)),

0 commit comments

Comments
 (0)