示例#1
0
    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);
    }
示例#2
0
 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;
 }
示例#3
0
 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);
     }
 }