Added IMovementController.Move method & Added Some Documentation
This commit is contained in:
@@ -3,6 +3,13 @@ using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// The Singleton factory responsible for loading and applying <see cref="MovementDefinition"/>s,
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para> Looks for the path specified in the variable <see cref="ResourceDirectoryToDefinitions"/></para>
|
||||
/// <para> The default path is "Resources/Modules/Syntriax/Movement/Definitions/"</para>
|
||||
/// </remarks>
|
||||
public class MovementDefinitionFactory : MonoBehaviour
|
||||
{
|
||||
private const string Name = "Movement Definition Factory";
|
||||
@@ -41,6 +48,13 @@ namespace Syntriax.Modules.Movement.Config
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the factory, if already initialized reinitializes
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para> Automatically loads the definition files specificed path <see cref="ResourceDirectoryToDefinitions"/></para>
|
||||
/// <para> The default is "Resources/Modules/Syntriax/Movement/Definitions/"</para>
|
||||
/// </remarks>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_definitions == null)
|
||||
@@ -52,20 +66,36 @@ namespace Syntriax.Modules.Movement.Config
|
||||
AddToFactoryWithJSON(definitionTextAsset.text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually registers a <see cref="MovementDefinition"/> to the factory with a JSON <see cref="string"/>
|
||||
/// </summary>
|
||||
/// <param name="definitionJSONText">A <see cref="string"/> of a <see cref="MovementDefinition"/> in JSON</param>
|
||||
public void AddToFactoryWithJSON(string definitionJSONText)
|
||||
{
|
||||
MovementDefinition movementDefinition = JsonUtility.FromJson<MovementDefinition>(definitionJSONText);
|
||||
AddDefinitionToFactory(movementDefinition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all the definitions in the factory
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Does not reinitialize, please call <see cref="Initialize"/> to initialize it back
|
||||
/// </remarks>
|
||||
public void Reset() => _definitions?.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a list of <see cref="MovementDefinition"/>s to the factory
|
||||
/// </summary>
|
||||
public void AddDefinitionsToFactory(List<MovementDefinition> movementDefinitions)
|
||||
{
|
||||
foreach (MovementDefinition movementDefinition in movementDefinitions)
|
||||
AddDefinitionToFactory(movementDefinition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a single <see cref="MovementDefinition"/> to the factory
|
||||
/// </summary>
|
||||
public void AddDefinitionToFactory(MovementDefinition movementDefinition)
|
||||
{
|
||||
if (Definitions.ContainsKey(movementDefinition.Name))
|
||||
@@ -74,6 +104,12 @@ namespace Syntriax.Modules.Movement.Config
|
||||
Definitions.Add(movementDefinition.Name, movementDefinition);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the <see cref="MovementDefinition"/> in the factory and applies it to the <see cref="GameObject"/>
|
||||
/// </summary>
|
||||
/// <param name="gameObject"><see cref="GameObject"/> that the <see cref="MovementDefinition"/> will be applied to</param>
|
||||
/// <param name="definitionName">The registered <see cref="MovementDefinition"/>'s name that will be applied to the provided <see cref="GameObject"/></param>
|
||||
/// <exception cref="System.ArgumentException">When the provided <see cref="MovementDefinition"/> name is not registered in the factory</exception>
|
||||
public void ApplyDefinitionToGameObject(GameObject gameObject, string definitionName)
|
||||
{
|
||||
if (!Definitions.ContainsKey(definitionName))
|
||||
@@ -82,6 +118,11 @@ namespace Syntriax.Modules.Movement.Config
|
||||
ApplyDefinitionToGameObject(gameObject, Definitions[definitionName]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the provided <see cref="MovementDefinition"/> to the <see cref="GameObject"/>
|
||||
/// </summary>
|
||||
/// <param name="gameObject"><see cref="GameObject"/> that the <see cref="MovementDefinition"/> will be applied to</param>
|
||||
/// <param name="definition">The <see cref="MovementDefinition"/> that will be applied to the provided <see cref="GameObject"/></param>
|
||||
public void ApplyDefinitionToGameObject(GameObject gameObject, MovementDefinition definition)
|
||||
{
|
||||
foreach (MovementConfig movementConfig in definition.MovementConfigs)
|
||||
|
Reference in New Issue
Block a user