Variable Movement Removed Temporarily
This commit is contained in:
@@ -6,14 +6,12 @@ namespace Syntriax.Modules.Movement.Config
|
||||
public struct MovementDefinition
|
||||
{
|
||||
public string Name;
|
||||
public string DefaultVariableMovement;
|
||||
public MovementConfig[] MovementConfigs;
|
||||
public string[] MonoBehaviours;
|
||||
|
||||
public MovementDefinition(string name, string defaultVariableMovement, MovementConfig[] movementConfigs, string[] monoBehaviours)
|
||||
public MovementDefinition(string name, MovementConfig[] movementConfigs, string[] monoBehaviours)
|
||||
{
|
||||
Name = name;
|
||||
DefaultVariableMovement = defaultVariableMovement;
|
||||
MovementConfigs = movementConfigs;
|
||||
MonoBehaviours = monoBehaviours;
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Syntriax.Modules.Movement.VariableMovement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Config
|
||||
@@ -94,13 +93,6 @@ namespace Syntriax.Modules.Movement.Config
|
||||
if (definition.MonoBehaviours != null)
|
||||
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);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
@@ -1,106 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using Syntriax.Modules.Movement.VariableMovement;
|
||||
|
||||
namespace Syntriax.Modules.Movement.Config
|
||||
{
|
||||
public class VariableMovementFactory : MonoBehaviour
|
||||
{
|
||||
private const string Name = "Variable Movement Factory";
|
||||
private const int InitialCapacity = 64;
|
||||
private const string ResourceDirectoryToCollections = "Modules/Syntriax/Movement/Variable Movement/Collections/";
|
||||
|
||||
private static VariableMovementFactory _instance = null;
|
||||
public static VariableMovementFactory Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new GameObject(Name).AddComponent<VariableMovementFactory>();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, VMCollection> _collections = null;
|
||||
public Dictionary<string, VMCollection> Collections
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_collections == null)
|
||||
Initialize();
|
||||
|
||||
return _collections;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_instance == this)
|
||||
return;
|
||||
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (_collections == null)
|
||||
_collections = new Dictionary<string, VMCollection>(InitialCapacity);
|
||||
|
||||
Reset();
|
||||
|
||||
foreach (TextAsset definitionTextAsset in UnityEngine.Resources.LoadAll<TextAsset>(ResourceDirectoryToCollections))
|
||||
AddToFactoryWithJSON(definitionTextAsset.text);
|
||||
}
|
||||
|
||||
public void AddToFactoryWithJSON(string definitionJSONText)
|
||||
{
|
||||
VMCollection collectionDefinition = JsonUtility.FromJson<VMCollection>(definitionJSONText);
|
||||
AddCollectionToFactory(collectionDefinition);
|
||||
}
|
||||
|
||||
public void Reset() => _collections?.Clear();
|
||||
|
||||
public void AddCollectionsToFactory(List<VMCollection> collections)
|
||||
{
|
||||
foreach (VMCollection collection in collections)
|
||||
AddCollectionToFactory(collection);
|
||||
}
|
||||
|
||||
public void AddCollectionToFactory(VMCollection collection)
|
||||
{
|
||||
if (Collections.ContainsKey(collection.Name))
|
||||
throw new System.ArgumentException($"{collection.Name} is already in the {Name}");
|
||||
|
||||
Collections.Add(collection.Name, collection);
|
||||
}
|
||||
|
||||
// public Component AddToGameObject(GameObject gameObject, string name)
|
||||
// {
|
||||
// if (!Collections.ContainsKey(name))
|
||||
// throw new ArgumentException($"The key \"{ name }\" does not exists in the current Movement Factory");
|
||||
|
||||
// return gameObject.AddComponent(Collections[name]);
|
||||
// }
|
||||
|
||||
public string GetTypeName(Type type)
|
||||
{
|
||||
if (string.IsNullOrEmpty(type.Namespace))
|
||||
return type.Name;
|
||||
|
||||
return $"{type.Namespace}.{type.Name}";
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SaveCollection(VMCollection collection)
|
||||
{
|
||||
string jsonText = JsonUtility.ToJson(collection, true);
|
||||
string path = $"Assets/Resources/{ResourceDirectoryToCollections}{collection.Name}.json";
|
||||
System.IO.File.WriteAllText(path, jsonText);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 514a385e4a5f87b47ae0f508bc253fb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user