private bool LoadAIDesign(ProtoBuf.AIDesign design, BasePlayer player) { if (design == null) { Debug.LogError(GetEntity().gameObject.name + " failed to load AI design!"); return(false); } if (player != null) { AIDesignScope scope = (AIDesignScope)design.scope; if (scope == AIDesignScope.Default && !player.IsDeveloper) { return(false); } if (scope == AIDesignScope.EntityServerWide && !player.IsDeveloper && !player.IsAdmin) { return(false); } } if (AIDesign == null) { return(false); } AIDesign.Load(design, base.baseEntity); AIStateContainer defaultStateContainer = AIDesign.GetDefaultStateContainer(); if (defaultStateContainer != null) { SwitchToState(defaultStateContainer.State, defaultStateContainer.ID); } return(true); }
public void Init(IAIEventListener listener, AIStateContainer stateContainer, BaseEntity owner, AIBrainSenses senses) { CurrentInputMemorySlot = stateContainer.InputMemorySlot; eventListener = listener; RemoveAll(); AddStateEvents(stateContainer.Events, owner); Memory.Entity.Set(owner, 4); this.senses = senses; }
public void EventTriggeredStateChange(int newStateContainerID, int sourceEventID) { if (AIDesign != null && newStateContainerID != -1) { AIStateContainer stateContainerByID = AIDesign.GetStateContainerByID(newStateContainerID); int previousStateID = currentStateContainerID; SwitchToState(stateContainerByID.State, newStateContainerID); SendStateChangeEvent(previousStateID, currentStateContainerID, sourceEventID); } }