Skip to content

Commit 77a5337

Browse files
committed
#1 : support static fields/properties
1 parent b7e1f6e commit 77a5337

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

GameData/Mutiny/test.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ SCENE_PATCH
1616
}
1717
}
1818
}
19+
20+
UnityEngine.RenderSettings
21+
{
22+
ambientLight = 0,0,1
23+
}
1924
}

Source/ModifyObject.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Mutiny
1111
internal class ModifyObject : ScenePatch
1212
{
1313
Dictionary<string, Action<object>[]> m_gameObjectMutators = new Dictionary<string, Action<object>[]>();
14+
List<Action> m_staticMutators = new List<Action>();
1415

1516
public override void Load(ConfigNode configNode)
1617
{
@@ -30,6 +31,17 @@ public override void Load(ConfigNode configNode)
3031

3132
m_gameObjectMutators.Add(path, CreateMutators(childNode, typeof(GameObject)));
3233
}
34+
else if (TypeUtilities.FindTypeNamed(childNode.name, out Type type))
35+
{
36+
var mutators = CreateMutators(childNode, type);
37+
m_staticMutators.Add(() =>
38+
{
39+
foreach (var mutator in mutators)
40+
{
41+
mutator.Invoke(null);
42+
}
43+
});
44+
}
3345
}
3446
}
3547

@@ -186,6 +198,11 @@ public override void Execute()
186198
mutator.Invoke(gameObject);
187199
}
188200
}
201+
202+
foreach (var staticMutator in m_staticMutators)
203+
{
204+
staticMutator.Invoke();
205+
}
189206
}
190207
}
191208
}

Source/TypeExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,14 @@ public static Type GetSubclassNamed(this Type thisType, string name)
2626
return result;
2727
}
2828
}
29+
30+
31+
static public class TypeUtilities
32+
{
33+
public static bool FindTypeNamed(string name, out Type type)
34+
{
35+
type = AccessTools.TypeByName(name);
36+
return type != null;
37+
}
38+
}
2939
}

0 commit comments

Comments
 (0)