public void Refresh(StateConnection targetStateConnection) { foreach (ObjectState stateScript in targetStateConnection.affectedScripts) { stateScript.Refresh(); } }
public void InicateTree(StateController stateController) { stateController.StateTree = new StateTree(stateController); List <StateNode> nodelist = new List <StateNode>(); foreach (var node in NodesSo) { StateNode n = new StateNode(); n.State = GetStateFromEnum(node.StateEnum, stateController); nodelist.Add(n); } stateController.StateTree.Nodes = nodelist.ToArray(); List <StateConnection> conlist = new List <StateConnection>(); foreach (ScrObjStateConnection conSo in ConnectionsSo) { StateConnection stateNodeConnection = new StateConnection(); stateNodeConnection.TriggerName = conSo.TriggerName; int f = Array.IndexOf(NodesSo, conSo.FromStateSo); int t = Array.IndexOf(NodesSo, conSo.ToStateSo); stateNodeConnection.StateNodeFrom = stateController.StateTree.Nodes[f]; stateNodeConnection.StateNodeTo = stateController.StateTree.Nodes[t]; conlist.Add(stateNodeConnection); } stateController.StateTree.Connections = conlist.ToArray(); foreach (var nod in stateController.StateTree.Nodes) { List <StateConnection> cs = new List <StateConnection>(); foreach (var con in stateController.StateTree.Connections) { if (con.StateNodeFrom == nod) { cs.Add(con); } } nod.ConnectionsFromThis = cs.ToArray(); } stateController.StateTree.CurrentNode = stateController.StateTree.Nodes[0]; stateController.CurrentState = stateController.StateTree.SetIdleStateAsCurrent(); //stateController.StateTree.LastNode = humanStateModule.StateTree.Nodes[0]; }
//registering adds this script to a list, if it isn't already in the list public void Register() { foreach (StateEffect activeScenario in myActiveScenarios.activeScenarios) { foreach (State state in activeScenario.isActiveWhen) { bool found = false; currentGameState = GameStateManager.instance.gameState; foreach (StateConnection stateConnection in currentGameState.stateConnections) { if (state.stateLabel.ToLowerInvariant() == stateConnection.stateLabel) { found = true; bool existing = false; foreach (MonoBehaviour script in stateConnection.affectedScripts) { if (script == this) { existing = true; } } if (!existing) { stateConnection.affectedScripts.Add(this); } } } if (!found) { myStateConnection = new StateConnection { affectedScripts = new List <MonoBehaviour>() { this }, stateLabel = state.stateLabel.ToLowerInvariant() }; currentGameState.stateConnections.Add(myStateConnection); } } } }