Default Variable Movement Field is now Optional
This commit is contained in:
parent
cda057ebeb
commit
c4edfef458
|
@ -67,7 +67,7 @@ namespace Syntriax.Modules.Movement.Config
|
|||
public void AddDefinitionToFactory(MovementDefinition movementDefinition)
|
||||
{
|
||||
if (Definitions.ContainsKey(movementDefinition.Name))
|
||||
throw new System.ArgumentException($"{ movementDefinition.Name } is already in the Movement Definition Factory");
|
||||
throw new System.ArgumentException($"{movementDefinition.Name} is already in the Movement Definition Factory");
|
||||
|
||||
Definitions.Add(movementDefinition.Name, movementDefinition);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Syntriax.Modules.Movement.Config
|
|||
public void ApplyDefinitionToGameObject(GameObject gameObject, string definitionName)
|
||||
{
|
||||
if (!Definitions.ContainsKey(definitionName))
|
||||
throw new System.ArgumentException($"The definition with name \"{ definitionName }\" does not exists in the current { Name }");
|
||||
throw new System.ArgumentException($"The definition with name \"{definitionName}\" does not exists in the current {Name}");
|
||||
|
||||
ApplyDefinitionToGameObject(gameObject, Definitions[definitionName]);
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ namespace Syntriax.Modules.Movement.Config
|
|||
foreach (string monoBehaviours in definition.MonoBehaviours)
|
||||
MovementFactory.Instance.AddToGameObject(gameObject, monoBehaviours);
|
||||
|
||||
if (string.IsNullOrEmpty(definition.DefaultVariableMovement))
|
||||
return;
|
||||
|
||||
IVariableMovementController variableMovementController = gameObject.GetComponent<IVariableMovementController>();
|
||||
VMCollection collection = VariableMovementFactory.Instance.Collections[definition.DefaultVariableMovement];
|
||||
variableMovementController?.LoadVariableMovementCollection(collection);
|
||||
|
@ -101,7 +104,7 @@ namespace Syntriax.Modules.Movement.Config
|
|||
public void SaveMovementDefinition(MovementDefinition definition)
|
||||
{
|
||||
string jsonText = JsonUtility.ToJson(definition, true);
|
||||
string path = $"Assets/Resources/{ ResourceDirectoryToDefinitions }{ definition.Name }.json";
|
||||
string path = $"Assets/Resources/{ResourceDirectoryToDefinitions}{definition.Name}.json";
|
||||
System.IO.File.WriteAllText(path, jsonText);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue