/// <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); }