Beispiel #1
0
 public void Copy(VariableStore from)
 {
     foreach (var variable in from._variables)
     {
         Copy(variable.Name, variable);
     }
 }
Beispiel #2
0
        public void Apply(VariableStore store, bool removeMissing)
        {
            if (removeMissing)
            {
                for (var i = 0; i < store.Variables.Count; i++)
                {
                    if (!Contains(store.Variables[i].Name))
                    {
                        store.Remove(i--);
                    }
                }
            }

            foreach (var definition in Definitions)
            {
                var variable = store.GetVariable(definition.Name);

                if (variable == null)
                {
                    store.Add(VariableValue.Create(definition.Name, definition.Type));
                }
                else if (variable.Type != definition.Type)
                {
                    variable.ChangeType(definition.Type);
                }
            }
        }
        public VariableStoreControl(VariableStore store, string name, string tooltip, bool allowAdd, bool allowRemove, UnityAction <Rect, int> customDraw = null)
        {
            _store = store;

            var list = _list.Setup(_store.Variables, name, tooltip, false, false, false, allowAdd, allowRemove, customDraw ?? DrawStoreEntry, RemoveStoreEntry);

            list.onAddDropdownCallback += CustomAdd;
        }
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo)
        {
            _store = GetObject <VariableStore>(property);

            var access = fieldInfo.GetCustomAttributes(typeof(VariableAccessAttribute), true).FirstOrDefault() as VariableAccessAttribute;
            var list   = _list.Setup(_store.Variables, property.name, property.tooltip, false, false, false, access == null ? true : access.AllowAdd, access == null ? true : access.AllowRemove, DrawStoreEntry, RemoveStoreEntry);

            list.onAddDropdownCallback += CustomAdd;
        }
Beispiel #5
0
        public VariableStore Clone()
        {
            var clone = new VariableStore();

            foreach (var variable in _variables)
            {
                clone._variables.Add(variable.Clone());
            }

            return(clone);
        }
Beispiel #6
0
        private void Awake()
        {
            _context = new WorldInstructionContext(gameObject, Variable.Name + " Responder", null);
            _store   = _context.GetStore(Variable);

            if (_store != null)
            {
                var variable = _store.GetVariable(Variable.Name);
                _store.Subscribe(this, null);
                Trigger(variable);
            }
        }
Beispiel #7
0
        public void LoadWorld(GameManager.WorldData data)
        {
            PersistentState = data.WorldState ?? new VariableStore();

            foreach (var zone in World.Zones)
            {
                if (zone.Scene.Index < 0)
                {
                    Debug.LogFormat("zone {0} does not have a valid scene assigned", zone.name);
                }
                else
                {
                    Zones[zone.Scene.Index].PersistentState = (zone.Scene.Index < data.ZoneStates.Length ? data.ZoneStates[zone.Scene.Index] : null) ?? new VariableStore();
                }
            }
        }
 public AddToStorePopup(VariableStore store)
 {
     _store = store;
 }
Beispiel #9
0
 public BattleInstructionContext(UnityObject owner, string name, VariableStore variables) : base(owner, name, variables)
 {
 }
Beispiel #10
0
 public InstructionContext(Object owner, string name, VariableStore variables)
 {
     Owner     = owner;
     Name      = name;
     Variables = variables ?? new VariableStore();
 }
Beispiel #11
0
 public WorldInstructionContext(Object owner, string name, VariableStore variables) : base(owner, name, variables)
 {
 }
Beispiel #12
0
 public EcosystemInstructionContext(Object Owner, string name, VariableStore variables) : base(Owner, name, variables)
 {
 }