/// <summary> /// Public so it can be used by other behaviours if needed (NOTHING ELSE!) /// </summary> public void UpdateFleeMovement(Ghost pGhost) { CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule; if (pVariablesModule.GetVariableAsBool(c_sVariableName_bReceivedBehaviourWhileInPrison)) { GetOutOfPrison(pGhost); return; } Tile pCurrentTile = MapManager.Instance.GetTileFromPosition(pGhost.transform.position); UpdateSavedTiles(pGhost, pCurrentTile); Tile pTileWeJustLeft = (Tile)(pVariablesModule.GetVariable(c_sVariableName_pTileWeJustLeft)); Tile pTileFurtherFromPlayer = MapManager.Instance.GetAdjacentTileFurtherFromPosition(PlayerCharacter.Instance.transform.position, pCurrentTile, pTileWeJustLeft); if (pTileFurtherFromPlayer != null) { pGhost.m_pNavMeshAgent.SetDestination(pTileFurtherFromPlayer.transform.position); } if (pTileFurtherFromPlayer == null || pTileWeJustLeft == null) { pVariablesModule.SetVariable(c_sVariableName_pTileWeJustLeft, pCurrentTile); // If no further tile, should allow backtrack if needed, and if no tile just left, prevent backtracking by putting the current one just in case } }
private void UpdateSavedTiles(Ghost pGhost, Tile pCurrentTile) { CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule; Tile pTileLastFrame = (Tile)(pVariablesModule.GetVariable(c_sVariableName_pTileLastFrame)); if (pCurrentTile != pTileLastFrame) { pVariablesModule.SetVariable(c_sVariableName_pTileWeJustLeft, pTileLastFrame); } pVariablesModule.SetVariable(c_sVariableName_pTileLastFrame, pCurrentTile); }