Ejemplo n.º 1
0
        public void ExecutePlan()
        {
            if (m_ActiveAction == null)
            {
                return;
            }

            if (m_ActiveAction.GetActionState() == ActionState.Inactive)
            {
                m_ActiveAction.Initalise(OnActionCompleted, OnActionFailed);
                m_ActiveAction.Enter(this);
            }

            if (m_ActiveAction.GetActionState() == ActionState.Running)
            {
                m_ActiveAction.Execute();
            }

            switch (m_ActiveAction.GetActionState())
            {
            case ActionState.Running:
                return;

            case ActionState.Completed:
                m_ActiveAction.Exit();
                ++m_IndexInPlan;
                OnWorkingMemoryChanged?.Invoke(GetWorkingMemory());
                break;

            case ActionState.Failed:
                m_ActiveAction.Cancel();
                break;
            }
        }
Ejemplo n.º 2
0
        public void UpdateSensors()
        {
            for (int i = 0; i < m_Sensors.Count; ++i)
            {
                ISensor <TKey, TValue> sensor = m_Sensors[i];
                if (sensor.GetShouldBeTicked() || Time.frameCount % (sensor.GetTickRate() + i) != 0)
                {
                    continue;
                }

                m_UnhandledSensorChanges |= sensor.DetectWorldStateChange(this);
            }

            if (m_UnhandledSensorChanges)
            {
                OnWorkingMemoryChanged?.Invoke(m_WorkingMemory);
            }
        }
Ejemplo n.º 3
0
 public void ClearWorkingMemory()
 {
     m_WorkingMemory.Clear();
     OnWorkingMemoryChanged?.Invoke(m_WorkingMemory);
 }
Ejemplo n.º 4
0
 public void AddOrUpdateWorkingMemory(TKey _targetKey, TValue _value)
 {
     m_WorkingMemory.AddOrUpdate(_targetKey, _value);
     OnWorkingMemoryChanged?.Invoke(m_WorkingMemory);
 }