Exemplo n.º 1
0
        public void StartAction(GameAction action, ActionPriority priority)
        {
            D("DoAction: {0}", action);

            Debug.Assert(!this.HasAction);
            Debug.Assert(priority != ActionPriority.Undefined);
            Debug.Assert(action.GUID.IsNull == false);

            this.CurrentAction    = action;
            this.ActionPriority   = priority;
            this.ActionTotalTicks = 0;
            this.ActionTicksUsed  = 0;

            var e = new ActionStartEvent()
            {
                Action   = action,
                Priority = priority,
            };

            if (m_ai != null)
            {
                m_ai.ActionStarted(e);
            }

            var c = new ActionStartedChange(this)
            {
                ActionStartEvent = e,
            };

            this.World.AddChange(c);
        }
Exemplo n.º 2
0
        public void ActionStarted(ActionStartEvent e)
        {
            trace.TraceVerbose("ActionStarted({0}): Worker.Action = {1}, CurrentAssignment {2}, CurrentAssignment.Action = {3}",
                               e.Action,
                               this.Worker.HasAction ? this.Worker.CurrentAction.ToString() : "<none>",
                               this.HasAssignment ? this.CurrentAssignment.ToString() : "<none>",
                               this.HasAssignment && this.CurrentAssignment.CurrentAction != null ? this.CurrentAssignment.CurrentAction.ToString() : "<none>");

            if (this.HasAssignment == false)
            {
                trace.TraceVerbose("ActionStarted: no assignment, so not for me");
                return;
            }

            if (this.CurrentAssignment.CurrentAction == null)
            {
                trace.TraceVerbose("ActionStarted: action started by someone else, cancel our current assignment");
                this.CurrentAssignment.Abort();
                ClearCurrentAssignment();
                return;
            }

            if (this.CurrentAssignment.CurrentAction.GUID != e.Action.GUID)
            {
                trace.TraceVerbose("ActionStarted: action started by someone else, cancel our current assignment");
                throw new Exception();
            }

            // otherwise, it's an action started by us, all ok.
        }
Exemplo n.º 3
0
        void IAI.ActionStarted(ActionStartEvent e)
        {
            if (m_currentAction == null)
            {
                return;
            }

            if (e.Action.GUID != m_currentAction.GUID)
            {
                m_currentAction = null;
            }
        }
Exemplo n.º 4
0
        public void HandleActionStartEvent(ActionStartEvent e)
        {
            Debug.Assert(!this.HasAction);

            this.CurrentAction  = e.Action;
            this.ActionPriority = e.Priority;

            if (this.AI != null)
            {
                this.AI.ActionStarted(e);
            }
        }
Exemplo n.º 5
0
        public void StartAction(GameAction action, ActionPriority priority, int userID)
        {
            D("DoAction: {0}, uid: {1}", action, userID);

            Debug.Assert(!this.HasAction);
            Debug.Assert(priority != ActionPriority.Undefined);
            Debug.Assert(action.MagicNumber != 0);

            this.CurrentAction = action;
            this.ActionPriority = priority;
            this.ActionTotalTicks = 0;
            this.ActionTicksUsed = 0;
            this.ActionUserID = userID;

            var e = new ActionStartEvent()
            {
                Action = action,
                Priority = priority,
                UserID = userID,
            };

            if (m_ai != null)
                m_ai.ActionStarted(e);

            var c = new ActionStartedChange(this)
            {
                ActionStartEvent = e,
            };

            this.World.AddChange(c);
        }
Exemplo n.º 6
0
        public void StartAction(GameAction action, ActionPriority priority)
        {
            D("DoAction: {0}", action);

            Debug.Assert(!this.HasAction);
            Debug.Assert(priority != ActionPriority.Undefined);
            Debug.Assert(action.GUID.IsNull == false);

            this.CurrentAction = action;
            this.ActionPriority = priority;
            this.ActionTotalTicks = 0;
            this.ActionTicksUsed = 0;

            var e = new ActionStartEvent()
            {
                Action = action,
                Priority = priority,
            };

            if (m_ai != null)
                m_ai.ActionStarted(e);

            var c = new ActionStartedChange(this)
            {
                ActionStartEvent = e,
            };

            this.World.AddChange(c);
        }
Exemplo n.º 7
0
        public void HandleActionStartEvent(ActionStartEvent e)
        {
            Debug.Assert(!this.HasAction);

            this.CurrentAction = e.Action;
            this.ActionPriority = e.Priority;
            this.ActionUserID = e.UserID;

            if (this.AI != null)
                this.AI.ActionStarted(e);
        }
Exemplo n.º 8
0
        void IAI.ActionStarted(ActionStartEvent e)
        {
            if (m_currentAction == null)
                return;

            if (e.Action.GUID != m_currentAction.GUID)
                m_currentAction = null;
        }
Exemplo n.º 9
0
        void IAI.ActionStarted(ActionStartEvent e)
        {
            if (m_currentAction == null)
                return;

            if (e.Action.MagicNumber != m_currentAction.MagicNumber)
                m_currentAction = null;
        }
Exemplo n.º 10
0
        public void ActionStarted(ActionStartEvent e)
        {
            trace.TraceVerbose("ActionStarted({0}): Worker.Action = {1}, CurrentAssignment {2}, CurrentAssignment.Action = {3}",
                e.Action,
                this.Worker.HasAction ? this.Worker.CurrentAction.ToString() : "<none>",
                this.HasAssignment ? this.CurrentAssignment.ToString() : "<none>",
                this.HasAssignment && this.CurrentAssignment.CurrentAction != null ? this.CurrentAssignment.CurrentAction.ToString() : "<none>");

            if (this.HasAssignment == false)
            {
                trace.TraceVerbose("ActionStarted: no assignment, so not for me");
                return;
            }

            if (this.CurrentAssignment.CurrentAction == null)
            {
                trace.TraceVerbose("ActionStarted: action started by someone else, cancel our current assignment");
                this.CurrentAssignment.Abort();
                ClearCurrentAssignment();
                return;
            }

            if (this.CurrentAssignment.CurrentAction.MagicNumber != e.Action.MagicNumber)
            {
                trace.TraceVerbose("ActionStarted: action started by someone else, cancel our current assignment");
                throw new Exception();
            }

            // otherwise, it's an action started by us, all ok.
        }