From d03fa51010f819a53e2a53b9e9bc9b6ef085c0e9 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 21 Nov 2022 21:51:27 +0300 Subject: [PATCH] Factory Update --- Config/MovementDefinitionFactory.cs | 21 ++++++++++----------- Config/MovementFactory.cs | 6 ++---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Config/MovementDefinitionFactory.cs b/Config/MovementDefinitionFactory.cs index a67afc5..9ac619d 100644 --- a/Config/MovementDefinitionFactory.cs +++ b/Config/MovementDefinitionFactory.cs @@ -28,6 +28,7 @@ namespace Syntriax.Modules.Movement.Config } } + private void Start() { if (FactorySingleton.Instance == this) @@ -43,17 +44,23 @@ namespace Syntriax.Modules.Movement.Config /// Automatically loads the definition files specificed path /// The default is "Resources/Modules/Syntriax/Movement/Definitions/" /// - public override void Initialize() + protected override void OnFactoryInitialize() { if (_definitions == null) _definitions = new Dictionary(InitialCapacity); - Reset(); - foreach (TextAsset definitionTextAsset in UnityEngine.Resources.LoadAll(ResourceDirectoryToDefinitions)) AddToFactoryWithJSON(definitionTextAsset.text); } + /// + /// Clears all the definitions in the factory + /// + /// + /// Does not reinitialize, please call to initialize it back + /// + protected override void OnFactoryReset() => _definitions?.Clear(); + /// /// Manually registers a to the factory with a JSON /// @@ -64,14 +71,6 @@ namespace Syntriax.Modules.Movement.Config AddDefinitionToFactory(movementDefinition); } - /// - /// Clears all the definitions in the factory - /// - /// - /// Does not reinitialize, please call to initialize it back - /// - public override void Reset() => _definitions?.Clear(); - /// /// Registers a list of s to the factory /// diff --git a/Config/MovementFactory.cs b/Config/MovementFactory.cs index 8e94ccd..0faf474 100644 --- a/Config/MovementFactory.cs +++ b/Config/MovementFactory.cs @@ -33,18 +33,16 @@ namespace Syntriax.Modules.Movement.Config Destroy(this); } - public override void Initialize() + protected override void OnFactoryInitialize() { if (_types == null) _types = new Dictionary(InitialCapacity); - Reset(); - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) AddAssemblyToFactory(assembly); } - public override void Reset() => _types?.Clear(); + protected override void OnFactoryReset() => _types?.Clear(); public void AddAssemblyToFactory(Assembly assembly) {