Skip to content

Commit b90aad4

Browse files
committed
handle inherited parameters for proxy/composite
1 parent 753e55a commit b90aad4

1 file changed

Lines changed: 66 additions & 16 deletions

File tree

CathodeLib/Scripts/CATHODE/CommandsPAK/Helpers/ParameterUtils.cs

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,14 @@ private static void ApplyDefaultFunction(FunctionEntity baseEntity, Entity targe
221221
}
222222
else
223223
{
224-
if (includeInherited)
225-
ApplyDefaults(baseEntity, targetEntity, overwrite, variants, FunctionType.CompositeInterface);
224+
FunctionType? functionType = FunctionType.CompositeInterface;
225+
while (true)
226+
{
227+
ApplyDefaults(baseEntity, targetEntity, overwrite, variants, functionType.Value);
228+
if (!includeInherited) break;
229+
functionType = GetInheritedFunction(functionType.Value);
230+
if (functionType == null) break;
231+
}
226232
Composite compositeInstance = _commands.GetComposite((baseEntity).function);
227233
foreach (VariableEntity variable in compositeInstance.variables)
228234
{
@@ -253,7 +259,16 @@ private static void ApplyDefaultFunction(FunctionEntity baseEntity, Entity targe
253259
else
254260
{
255261
if (includeInherited)
256-
parameters.AddRange(GetAllParameters(FunctionType.CompositeInterface));
262+
{
263+
FunctionType? functionType = FunctionType.CompositeInterface;
264+
while (true)
265+
{
266+
parameters.AddRange(GetAllParameters(functionType.Value));
267+
if (!includeInherited) break;
268+
functionType = GetInheritedFunction(functionType.Value);
269+
if (functionType == null) break;
270+
}
271+
}
257272
Composite compositeInstance = _commands.GetComposite((functionEntity).function);
258273
foreach (VariableEntity variable in compositeInstance.variables)
259274
{
@@ -263,7 +278,16 @@ private static void ApplyDefaultFunction(FunctionEntity baseEntity, Entity targe
263278
break;
264279
case EntityVariant.PROXY:
265280
if (includeInherited)
266-
parameters.AddRange(GetAllParameters(FunctionType.ProxyInterface));
281+
{
282+
FunctionType? functionType = FunctionType.ProxyInterface;
283+
while (true)
284+
{
285+
parameters.AddRange(GetAllParameters(functionType.Value));
286+
if (!includeInherited) break;
287+
functionType = GetInheritedFunction(functionType.Value);
288+
if (functionType == null) break;
289+
}
290+
}
267291
ProxyEntity proxyEntity = (ProxyEntity)entity;
268292
Entity proxiedEntity = proxyEntity.proxy.GetPointedEntity(_commands);
269293
if (proxiedEntity != null)
@@ -402,9 +426,15 @@ public static (ParameterVariant?, DataType?, ShortGuid) GetParameterMetadata(Ent
402426
}
403427
else
404428
{
405-
var metadata = GetParameterMetadata(FunctionType.CompositeInterface, parameter);
406-
if (metadata.Item1 != null)
407-
return (metadata.Item1, metadata.Item2, metadata.Item3 == null ? ShortGuid.Invalid : new ShortGuid((UInt32)metadata.Item3));
429+
FunctionType? functionType = FunctionType.CompositeInterface;
430+
while (true)
431+
{
432+
var metadata = GetParameterMetadata(functionType.Value, parameter);
433+
if (metadata.Item1 != null)
434+
return (metadata.Item1, metadata.Item2, metadata.Item3 == null ? ShortGuid.Invalid : new ShortGuid((UInt32)metadata.Item3));
435+
functionType = GetInheritedFunction(functionType.Value);
436+
if (functionType == null) break;
437+
}
408438
Composite composite = _commands.GetComposite(functionEntity.function);
409439
if (composite != null)
410440
{
@@ -424,9 +454,15 @@ public static (ParameterVariant?, DataType?, ShortGuid) GetParameterMetadata(Ent
424454
break;
425455
case EntityVariant.PROXY:
426456
{
427-
var metadata = GetParameterMetadata(FunctionType.ProxyInterface, parameter);
428-
if (metadata.Item1 != null)
429-
return (metadata.Item1, metadata.Item2, metadata.Item3 == null ? ShortGuid.Invalid : new ShortGuid((UInt32)metadata.Item3));
457+
FunctionType? functionType = FunctionType.ProxyInterface;
458+
while (true)
459+
{
460+
var metadata = GetParameterMetadata(functionType.Value, parameter);
461+
if (metadata.Item1 != null)
462+
return (metadata.Item1, metadata.Item2, metadata.Item3 == null ? ShortGuid.Invalid : new ShortGuid((UInt32)metadata.Item3));
463+
functionType = GetInheritedFunction(functionType.Value);
464+
if (functionType == null) break;
465+
}
430466
ProxyEntity proxyEntity = (ProxyEntity)entity;
431467
Entity proxiedEntity = proxyEntity.proxy.GetPointedEntity(_commands);
432468
if (proxiedEntity != null)
@@ -604,9 +640,16 @@ public static ParameterData CreateDefaultParameterData(Entity entity, Composite
604640
}
605641
else
606642
{
607-
var data = CreateDefaultParameterData(FunctionType.CompositeInterface, parameter);
608-
if (data != null)
609-
return data;
643+
ParameterData data;
644+
FunctionType? functionType = FunctionType.CompositeInterface;
645+
while (true)
646+
{
647+
data = CreateDefaultParameterData(functionType.Value, parameter);
648+
if (data != null)
649+
return data;
650+
functionType = GetInheritedFunction(functionType.Value);
651+
if (functionType == null) break;
652+
}
610653
Composite comp = _commands.GetComposite(functionEntity.function);
611654
if (composite != null)
612655
{
@@ -622,9 +665,16 @@ public static ParameterData CreateDefaultParameterData(Entity entity, Composite
622665
break;
623666
case EntityVariant.PROXY:
624667
{
625-
var data = CreateDefaultParameterData(FunctionType.ProxyInterface, parameter);
626-
if (data != null)
627-
return data;
668+
ParameterData data;
669+
FunctionType? functionType = FunctionType.ProxyInterface;
670+
while (true)
671+
{
672+
data = CreateDefaultParameterData(functionType.Value, parameter);
673+
if (data != null)
674+
return data;
675+
functionType = GetInheritedFunction(functionType.Value);
676+
if (functionType == null) break;
677+
}
628678
ProxyEntity proxyEntity = (ProxyEntity)entity;
629679
Entity proxiedEntity = proxyEntity.proxy.GetPointedEntity(_commands, out Composite proxiedComposite);
630680
if (proxiedEntity != null)

0 commit comments

Comments
 (0)