// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null || list.variables.Count == 0) { return(true); } for (int i = list.variables.Count - 1; i >= 0; --i) { switch (this.clear) { case ClearType.ClearAll: list.Remove(i); break; case ClearType.ClearEmpty: Variable variable = list.Get(i); if (variable == null || variable.Get().Equals(null)) { list.Remove(i); } break; } } return(true); }
// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null) { return(true); } switch (this.operation) { case Operation.VariableToIterator: int value = this.pointer.GetInt(target); list.SetInterator(value); break; case Operation.IteratorToVariable: this.variable.Set(list.iterator, target); break; case Operation.IteratorToNext: list.NextIterator(); break; case Operation.IteratorToPrevious: list.PrevIterator(); break; } return(true); }
public override bool Check(GameObject target) { GameObject go = this.containsObject.GetGameObject(target); if (go == null) { return(false); } ListVariables list = this.listVariables.GetListVariables(target); if (list == null) { return(false); } if (list.type != Variable.DataType.GameObject) { return(false); } for (int i = 0; i < list.variables.Count; ++i) { GameObject item = list.variables[i].Get <GameObject>(); if (item == null) { continue; } if (item.GetInstanceID() == go.GetInstanceID()) { return(true); } } return(false); }
// PUBLIC METHODS: ------------------------------------------------------------------------ public object Get(GameObject invoker) { ListVariables list = this.GetListVariables(invoker); Variable result = VariablesManager.GetListItem(list, this.select, this.index); return(result != null?result.Get() : null); }
// INITIALIZERS: -------------------------------------------------------------------------- protected override void OnEnable() { base.OnEnable(); this.list = this.target as ListVariables; this.spType = this.serializedObject.FindProperty("type"); this.spSave = this.serializedObject.FindProperty("save"); }
public static void ListClear(ListVariables target) { if (target == null) { return; } for (int i = target.variables.Count - 1; i >= 0; --i) { VariablesManager.ListRemove(target, i); } }
// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null || list.variables.Count == 0) { return(true); } list.Remove(this.listVariables.select, this.listVariables.index); return(true); }
// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null || list.variables.Count == 0) { return(true); } int value = this.pointer.GetInt(target); list.SetInterator(value); return(true); }
// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null) { return(true); } GameObject elementGo = this.item.GetGameObject(target); if (elementGo == null) { return(true); } list.Push(elementGo, this.listVariables.select, this.listVariables.index); return(true); }
public override bool Check(GameObject target) { ListVariables list = this.listVariable.GetListVariables(target); if (list == null) { return(false); } int listCount = list.variables.Count; switch (this.comparison) { case Comparison.Equals: return(listCount == this.count); case Comparison.Different: return(listCount != this.count); case Comparison.LessThan: return(listCount < this.count); case Comparison.GreaterThan: return(listCount > this.count); } return(false); }
public static void ListRemove(ListVariables target, ListVariables.Position position) { target.Remove(position); }
public static void ListRemove(GameObject target, ListVariables.Position position) { ListVariables list = target.GetComponent <ListVariables>(); ListRemove(list, position); }
public static void ListRemove(ListVariables target, int index) { target.Remove(index); }
public static void ListRemove(GameObject target, int index) { ListVariables list = target.GetComponent <ListVariables>(); ListRemove(list, index); }
public static void ListPush(ListVariables target, ListVariables.Position position, object value) { target.Push(value, position); }
public static void ListPush(GameObject target, ListVariables.Position position, object value) { ListVariables list = target.GetComponent <ListVariables>(); ListPush(list, position, value); }
public static void ListPush(ListVariables target, int index, object value) { target.Push(value, index); }
public static void ListPush(GameObject target, int index, object value) { ListVariables list = target.GetComponent <ListVariables>(); ListPush(list, index, value); }
// EXECUTABLE: ---------------------------------------------------------------------------- public override IEnumerator Execute(GameObject target, IAction[] actions, int index) { ListVariables list = this.listVariables.GetListVariables(target); if (list == null) { yield break; } Actions actionsToExecute = null; Conditions conditionsToExecute = null; switch (this.source) { case Source.Actions: actionsToExecute = this.actions; break; case Source.Conditions: conditionsToExecute = this.conditions; break; case Source.VariableWithActions: GameObject valueActions = this.variable.Get(target) as GameObject; if (valueActions != null) { actionsToExecute = valueActions.GetComponent <Actions>(); } break; case Source.VariableWithConditions: GameObject valueConditions = this.variable.Get(target) as GameObject; if (valueConditions != null) { conditionsToExecute = valueConditions.GetComponent <Conditions>(); } break; } for (int i = 0; i < list.variables.Count && !this.forceStop; ++i) { Variable itemVariable = list.Get(i); if (itemVariable == null) { continue; } GameObject itemGo = itemVariable.Get() as GameObject; if (itemGo == null) { continue; } this.executionComplete = false; if (actionsToExecute != null) { actionsToExecute.actionsList.Execute(itemGo, this.OnCompleteActions); WaitUntil wait = new WaitUntil(() => { if (actionsToExecute == null) { return(true); } if (this.forceStop) { actionsToExecute.actionsList.Stop(); return(true); } return(this.executionComplete); }); yield return(wait); } else if (conditionsToExecute != null) { conditionsToExecute.Interact(itemGo); } } yield return(0); }
public static Variable GetListItem(ListVariables list, ListVariables.Position position, int index = 0) { return(list.Get(position, index)); }
public static int GetListCount(GameObject target) { ListVariables list = target.GetComponent <ListVariables>(); return(GetListCount(list)); }
// EXECUTE METHOD: ------------------------------------------------------------------------ public override bool InstantExecute(GameObject target, IAction[] actions, int index) { ListVariables list = this.fromListVariables.GetListVariables(target); if (list == null || list.variables.Count == 0) { return(true); } Transform other = this.to.GetTransform(target); if (other == null) { return(true); } GameObject selectedGO = null; float selectedDistance = 0; switch (this.select) { case Select.Nearest: selectedDistance = Mathf.Infinity; break; case Select.Farthest: selectedDistance = Mathf.NegativeInfinity; break; } for (int i = 0; i < list.variables.Count; ++i) { GameObject item = list.variables[i].Get() as GameObject; if (item == null) { continue; } float distance = Vector3.Distance(other.position, item.transform.position); switch (this.select) { case Select.Nearest: if (distance < selectedDistance) { selectedDistance = distance; selectedGO = item; } break; case Select.Farthest: if (distance > selectedDistance) { selectedDistance = distance; selectedGO = item; } break; } } if (selectedGO == null) { return(true); } this.assignToVariable.Set(selectedGO); return(true); }
public static int GetListCount(ListVariables list) { return(list == null ? 0 : list.variables.Count); }
public static Variable GetListItem(GameObject target, ListVariables.Position position, int index = 0) { ListVariables list = target.GetComponent <ListVariables>(); return(GetListItem(list, position)); }
public void Set(object value, GameObject invoker = null) { ListVariables list = this.GetListVariables(invoker); list.Push(value, this.select, this.index); }
public GameObject GetGameObject(GameObject invoker) { ListVariables list = this.GetListVariables(invoker); return(list != null ? list.gameObject : null); }
public Variable.DataType GetDataType(GameObject invoker) { ListVariables list = this.GetListVariables(invoker); return(list != null ? list.type : Variable.DataType.Null); }