//makes sure not to add duplicates public void Add(StateMachine.BaseDef def) { if (chore_table == null) { chore_table = new List <StateMachine.BaseDef>(); } bool doAdd = true; if (chore_table.Any(s => s.GetType() == def.GetType())) { doAdd = false; // don't add if def Type is already added } var play_tag = (def as PlayAnimsStates.Def)?.tag; if (play_tag != null && play_tag.Value.IsValid) { doAdd = !chore_table.Any(s => // don't add if any PlayAnimsState matches the tag already { var x = s as PlayAnimsStates.Def; return(x != null && x.tag == play_tag); }); } if (doAdd) { chore_table.Add(def); } }
public static void RemoveDef(GameObject go, StateMachine.BaseDef def) { StateMachineController controller = go.GetComponent <StateMachineController>(); if (controller != null) { if (def != null) { controller.cmpdef.defs.Remove(def); } } }
public Builder Add(StateMachine.BaseDef def, bool condition = true) { if (condition) { Info info = default(Info); info.interruptGroupId = interruptGroupId; info.def = def; Info item = info; infos.Add(item); } return(this); }