using System.Collections; using System.Collections.Generic; using UnityEngine; namespace STRIPS { [CreateAssetMenu(fileName = "VarMapping", menuName = "STRIPS/Create New Variable Mapping", order = 2)] public class StripsVariableMapping : ScriptableObject { [SerializeField] private VariableMapping[] variableMappings; public Dictionary Mappings { get { Dictionary mapping = new Dictionary(); foreach (VariableMapping map in variableMappings) { mapping.Add(map.varName, map); } return mapping; } } public VariableMapping Find(string name) { return Mappings[name]; } public PackageMapping CreateCopy() { VariableMapping[] copiedMappings = new VariableMapping[variableMappings.Length]; int i = 0; foreach(VariableMapping mapping in variableMappings) { VariableMapping newMapping = new VariableMapping(); newMapping.variable = mapping.variable; newMapping.value = mapping.value; newMapping.varName = mapping.varName; copiedMappings[i] = newMapping; i++; } return new PackageMapping(copiedMappings); } public class PackageMapping { public PackageMapping(VariableMapping[] variableMappings) { this.variableMappings= variableMappings; } public void SetMapping(string name, string value) { for(int i =0;i Mappings { get { Dictionary mapping = new Dictionary(); foreach (VariableMapping map in variableMappings) { mapping.Add(map.varName, map); } return mapping; } } } [System.Serializable] public class VariableMapping { public string varName; public VarType variable; public string value; } public enum VarType { Integer, Float, String, Boolean }; } }