private void removeSequencer(State state) { if (state.Owner != null && state.Trigger != null) { SharedActionGraphState component = state.Trigger.GetComponent <SharedActionGraphState>(); if (component != null) { component.Interactors.Remove(state.Owner); } } sequencerDict.Remove(state.OwnerInstanceId); sequencerList.Remove(state); }
private void addSequencer(GameObject owner, State state) { if (owner == null) { Log.LogErrorFormatted(this, "Owner is null when trying to add a state to the sequencer. State: {0}", state); return; } int instanceID = owner.GetInstanceID(); if (state.Trigger != null) { SharedActionGraphState component = state.Trigger.GetComponent <SharedActionGraphState>(); if (component != null) { component.Interactors.Add(owner); } } sequencerDict.Add(instanceID, state); sequencerList.Add(state); }
public bool StartSequence(GameObject owner, GameObject trigger) { bool result = false; if (owner == null) { Log.LogErrorFormatted(this, "owner is null when starting a sequence for trigger {0}", trigger); return(result); } int instanceID = owner.GetInstanceID(); if (sequencerDict.ContainsKey(instanceID)) { State state = sequencerDict[instanceID]; if (!state.Trigger.IsDestroyed()) { } } else { ClubPenguin.Actions.Action[] components = trigger.GetComponents <ClubPenguin.Actions.Action>(); if (components.Length > 0) { SharedActionGraphState sharedActionGraphState = trigger.GetComponent <SharedActionGraphState>(); if (sharedActionGraphState == null) { sharedActionGraphState = trigger.AddComponent <SharedActionGraphState>(); } if (sharedActionGraphState.MaxInteractors > -1 && sharedActionGraphState.Interactors.Count >= sharedActionGraphState.MaxInteractors) { result = false; } else { State state2 = new State(owner, trigger); int num = components.Length; state2.Actions.Capacity = num; for (int i = 0; i < num; i++) { GameObject gameObject = components[i].GetTarget(); if (gameObject == null) { gameObject = owner; } if (!gameObject.IsDestroyed()) { if (state2.Targets.Add(gameObject)) { sequenceStarted(state2); } ClubPenguin.Actions.Action action = components[i].AddToGameObject(gameObject); action.Owner = owner; state2.Actions.Add(action); } } addSequencer(owner, state2); enableRootActions(state2); result = true; if (owner.CompareTag("Player")) { Service.Get <EventDispatcher>().DispatchEvent(new ActionSequencerEvents.ActionSequenceStarted(trigger)); } } } } return(result); }