diff --git a/Config/MovementDefinitionFactory.cs b/Config/MovementDefinitionFactory.cs index 29ca797..ef56fd5 100644 --- a/Config/MovementDefinitionFactory.cs +++ b/Config/MovementDefinitionFactory.cs @@ -6,7 +6,7 @@ namespace Syntriax.Modules.Movement.Config { public class MovementDefinitionFactory : MonoBehaviour { - private const string Name = "Movement Definer Factory"; + private const string Name = "Movement Definition Factory"; private const int InitialCapacity = 64; private const string ResourceDirectoryToDefinitions = "Modules/Syntriax/Movement/Definitions/"; @@ -42,27 +42,32 @@ namespace Syntriax.Modules.Movement.Config Destroy(this); } - private void Initialize() + public void Initialize() { - _definitions = new Dictionary(InitialCapacity); + if (_definitions == null) + _definitions = new Dictionary(InitialCapacity); + + Reset(); foreach (TextAsset definitionTextAsset in UnityEngine.Resources.LoadAll(ResourceDirectoryToDefinitions)) { MovementDefinition movementDefinition = JsonUtility.FromJson(definitionTextAsset.text); - AddDefinerToFactory(movementDefinition); + AddDefinitionToFactory(movementDefinition); } } - public void AddDefinersToFactory(List movementDefinitions) + public void Reset() => _definitions?.Clear(); + + public void AddDefinitionsToFactory(List movementDefinitions) { foreach (MovementDefinition movementDefinition in movementDefinitions) - AddDefinerToFactory(movementDefinition); + AddDefinitionToFactory(movementDefinition); } - public void AddDefinerToFactory(MovementDefinition movementDefinition) + public void AddDefinitionToFactory(MovementDefinition movementDefinition) { if (Definitions.ContainsKey(movementDefinition.Name)) - throw new System.ArgumentException($"{ movementDefinition.Name } is already in the Movement Definer Factory"); + throw new System.ArgumentException($"{ movementDefinition.Name } is already in the Movement Definition Factory"); Definitions.Add(movementDefinition.Name, movementDefinition); } diff --git a/Config/MovementFactory.cs b/Config/MovementFactory.cs index b205861..a367294 100644 --- a/Config/MovementFactory.cs +++ b/Config/MovementFactory.cs @@ -45,14 +45,19 @@ namespace Syntriax.Modules.Movement.Config Destroy(this); } - private void Initialize() + public void Initialize() { - _types = new Dictionary(InitialCapacity); + if (_types == null) + _types = new Dictionary(InitialCapacity); + + Reset(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) AddAssemblyToFactory(assembly); } + public void Reset() => _types?.Clear(); + public void AddAssemblyToFactory(Assembly assembly) { foreach (Type type in assembly.GetTypes().Where(predicate)) diff --git a/Config/VariableMovementFactory.cs b/Config/VariableMovementFactory.cs index 9191061..5e052fd 100644 --- a/Config/VariableMovementFactory.cs +++ b/Config/VariableMovementFactory.cs @@ -45,9 +45,12 @@ namespace Syntriax.Modules.Movement.Config Destroy(this); } - private void Initialize() + public void Initialize() { - _collections = new Dictionary(InitialCapacity); + if (_collections == null) + _collections = new Dictionary(InitialCapacity); + + Reset(); foreach (TextAsset definitionTextAsset in UnityEngine.Resources.LoadAll(ResourceDirectoryToCollections)) { @@ -56,6 +59,8 @@ namespace Syntriax.Modules.Movement.Config } } + public void Reset() => _collections?.Clear(); + public void AddCollectionsToFactory(List collections) { foreach (VMCollection collection in collections) diff --git a/Movement.asmdef b/Syntriax.Modules.Movement.asmdef similarity index 89% rename from Movement.asmdef rename to Syntriax.Modules.Movement.asmdef index 6a543f9..1cbe2b4 100644 --- a/Movement.asmdef +++ b/Syntriax.Modules.Movement.asmdef @@ -1,5 +1,5 @@ { - "name": "Movement", + "name": "Syntriax.Modules.Movement", "rootNamespace": "", "references": [ "GUID:75469ad4d38634e559750d17036d5f7c" diff --git a/Movement.asmdef.meta b/Syntriax.Modules.Movement.asmdef.meta similarity index 100% rename from Movement.asmdef.meta rename to Syntriax.Modules.Movement.asmdef.meta