Beispiel #1
0
 public void SetReliesOn(SubMove subMove)
 {
     if (subMove != null)
     {
         reliesOn.Add(subMove);
     }
 }
Beispiel #2
0
        /// <param name="agentBase">The agent getting moved.</param>
        /// <param name="requiresValidSubMove">Leave null for default validity check. Otherwise, the subMove is only valid if this given submove is also valid. </param>
        /// <param name="criticalToMove">should an invalid move here invalidate the ENTIRE move</param>
        /// <param name="criticalForSubMove">if the submove gets invalidated, should THIS submove also get invalidated?</param>
        public SubMove AddAgentToMove(AgentBase agentBase, Vector3Int dir, bool criticalToMove = true, SubMove criticalForSubMove = null, SubMove reliesOnsubMove = null, int subMovePriority = 0)
        {
            SubMove subMove = null;

            if (agentBase.puzzleManager.tilemapNavigation.GetNode(agentBase.CurrentNode.cellPos + dir, out NavNode destinationNode))
            {
                if (agentBase.CanWalkOnNode(destinationNode))
                {
                    subMove = new SubMove(agentBase, agentBase.CurrentNode, agentBase.GetLocationData(), destinationNode, dir, criticalToMove, criticalForSubMove, reliesOnsubMove, subMovePriority);

                    if (_allSubMoves.ContainsKey(agentBase))
                    {
                        if (subMovePriority > _allSubMoves[agentBase].subMovePriority)
                        {
                            _allSubMoves[agentBase].Invalidate();
                            _allSubMoves[agentBase] = subMove;
                            _puzzleManager.CallNewSubMove(this, subMove);
                        }
                    }
                    else
                    {
                        _allSubMoves[agentBase] = subMove;
                        _puzzleManager.CallNewSubMove(this, subMove);
                    }
                }
            }
            //after the move has been configured (here), it needs to be executed (by the command manager).
            //this is for undo/redo support.
            return(subMove);
        }
Beispiel #3
0
 public SubMove(AgentBase agentBase, NavNode startingNode, object agentStartingData, NavNode destinationNode, Vector3Int dir, bool moveCritical = true, SubMove criticalFor = null, SubMove reliesOn = null, int subMovePriority = 0)
 {
     this.agentStartingData = agentStartingData;
     this.subMovePriority   = subMovePriority;
     this.criticalFor       = criticalFor;
     SetReliesOn(reliesOn);
     finishedExecuting    = false; //todo change this language to finishedAnimation or something more clear, inconsistent use of the word executing.
     this.moveCritical    = moveCritical;
     this.dir             = dir;   //uh, we can just calculate this from destination-starting? I wont jic teleportation becomes like, a move? so we would pass in the previous ... direction entering the teleporter?
     this.agent           = agentBase;
     this.startingNode    = startingNode;
     this.destinationNode = destinationNode;
 }
Beispiel #4
0
        public bool GetValidSubMove(AgentBase agentBase, out SubMove subMove)
        {
            if (_allSubMoves.ContainsKey(agentBase))
            {
                if (_allSubMoves[agentBase].Valid)
                {
                    subMove = _allSubMoves[agentBase];
                    return(true);
                }
            }

            subMove = null;
            return(false);
        }