public void AddCharacterActor(LobbyPlayerInfo playerInfo) { CharacterResourceLink resourceLink = GameWideData.Get().GetCharacterResourceLink(playerInfo.CharacterType); Log.Info($"Add Character {resourceLink.GetDisplayName()} for player {playerInfo.Handle}"); GameObject atsdObject = SpawnObject("ActorTeamSensitiveData_Friendly", false); GameObject character = GameObject.Instantiate(resourceLink.ActorDataPrefab); ActorData actorData = character.GetComponent <ActorData>(); ActorTeamSensitiveData atsd = atsdObject.GetComponent <ActorTeamSensitiveData>(); actorData.SetupAbilityMods(playerInfo.CharacterInfo.CharacterMods); //# actorData.PlayerIndex = playerInfo.PlayerId; actorData.ActorIndex = playerInfo.PlayerId; atsd.SetActorIndex(actorData.ActorIndex); // PATCH private -> public ActorTeamSensitiveData.SetActorIndex PlayerData playerData = character.GetComponent <PlayerData>(); playerData.PlayerIndex = playerInfo.PlayerId; actorData.SetTeam(playerInfo.TeamId); actorData.UpdateDisplayName(playerInfo.Handle); actorData.SetClientFriendlyTeamSensitiveData(atsd); NetworkServer.Spawn(atsdObject); NetworkServer.Spawn(character); // For some reason, when you spawn atsd first, you see enemy characters, and when you spawn character first, you don't // They get lost because enemies are not YET registered in GameFlowData actors when TeamSensitiveDataMatchmaker.SetTeamSensitiveDataForUnhandledActors is called // TODO add hostile atsds and connect friendly/hostile ones to respective clients (Patch in ATSD.OnCheck/RebuildObservers) }
public void ResolveMovement() { Dictionary <int, BoardSquarePathInfo> paths = new Dictionary <int, BoardSquarePathInfo>(); foreach (ActorData actor in GameFlowData.Get().GetActors()) { paths.Add(actor.ActorIndex, ResolveMovement(actor)); } Dictionary <int, BoardSquarePathInfo> nodes = new Dictionary <int, BoardSquarePathInfo>(paths); bool finished = false; for (float time = 0; !finished; time += RESOLUTION_STEP) { if (!ResolveSubstep(nodes, time, out finished)) { // TODO optimize time = -RESOLUTION_STEP; nodes = new Dictionary <int, BoardSquarePathInfo>(paths); Log.Info("Restarting movement resolution loop"); } } var movementActions = ArtemisServerBarrierManager.Get().OnMovement(paths); ArtemisServerResolutionManager.Get().SendMovementActions(movementActions); // TODO ClientMovementManager.MsgServerMovementStarting foreach (ActorData actor in GameFlowData.Get().GetActors()) { BoardSquarePathInfo start = paths[actor.ActorIndex]; BoardSquarePathInfo end = start; while (end.next != null) { end = end.next; } ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority; // TODO GetPathEndpoint everywhere // TODO movement camera bounds actor.MoveFromBoardSquare = end.square; actor.InitialMoveStartSquare = end.square; atsd.CallRpcMovement( GameEventManager.EventType.Invalid, GridPosProp.FromGridPos(start.square.GetGridPosition()), GridPosProp.FromGridPos(end.square.GetGridPosition()), MovementUtils.SerializePath(start), ActorData.MovementType.Normal, false, false); atsd.MovementLine?.m_positions.Clear(); } Log.Info("Movement resolved"); }
private BoardSquarePathInfo ResolveMovement(ActorData actor) { ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority; ActorMovement actorMovement = actor.GetActorMovement(); BoardSquare start = actor.InitialMoveStartSquare; BoardSquare end = actor.MoveFromBoardSquare; BoardSquarePathInfo path; if (atsd.MovementLine != null) { path = BuildPathAlongMovementLine(actor); } else { path = actorMovement.BuildPathTo(start, end); } if (path == null) { path = actorMovement.BuildPathTo(start, start); } for (var pathNode = path; pathNode.next != null; pathNode = pathNode.next) { pathNode.m_unskippable = true; // so that aestetic path is not optimized (see CreateRunAndVaultAesteticPath) } var path2 = path; while (path2.next != null) { Log.Info($"FINAL PATH {path2.square.GetGridPosition()}"); path2 = path2.next; } Log.Info($"FINAL PATH {path2.square.GetGridPosition()}"); return(path); }
private static BoardSquarePathInfo BuildPathAlongMovementLine(ActorData actor) { ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority; ActorMovement actorMovement = actor.GetActorMovement(); BoardSquare start = actor.InitialMoveStartSquare; BoardSquare end = actor.MoveFromBoardSquare; // TODO refactor this atrocity BoardSquarePathInfo path = actorMovement.BuildPathTo(start, start); BoardSquarePathInfo node = path; foreach (var curPos in atsd.MovementLine.m_positions) { node.next = actorMovement.BuildPathTo(node.square, Board.Get().GetSquare(curPos)).next; if (node.next == null) { continue; } node.next.moveCost += node.moveCost; node.next.prev = node; node = node.next; } return(path); }
private void HandleGameLoaded() { Log.Print(LogType.Debug, "All players loaded"); GameFlowData.gameState = GameState.SpawningPlayers; foreach (GameObject netObj in NetworkGameObjects.Values) { NetworkIdentity networkIdentity = netObj.GetComponent <NetworkIdentity>(); networkIdentity.UNetUpdate(); } foreach (var playerInfo in TeamPlayerInfo) { SpawnPlayerCharacter(playerInfo); // actors get synclist updates for currentCardIds and modifiedStats } // check for owning player // TODO lock (this.GamePlayersByPlayerId) { foreach ((int playerID, GamePlayer player) in this.GamePlayersByPlayerId) { foreach (ActorData actor in GameFlowData.GetAllActorsForPlayer(playerID)) { player.Connection.Send(4, new OwnerMessage { netId = actor.netId, playerControllerId = (short)player.PlayerId }); } } } // The following should be sent after all players have loaded foreach (GameObject netObj in NetworkGameObjects.Values) { ActorTeamSensitiveData actorTeamSensitiveData = netObj.GetComponent <ActorTeamSensitiveData>(); if (actorTeamSensitiveData == null) { continue; } // Just send the play to an arbitrary location for now actorTeamSensitiveData.CallRpcMovement(GameEventManager.EventType.Invalid, new GridPosProp(11, 10, 6), new GridPosProp(11, 10, 5), null, ActorData.MovementType.Teleport, false, false); } GameFlowData.gameState = GameState.StartingGame; UpdateAllNetObjs(); GameFlowData.gameState = GameState.Deployment; UpdateAllNetObjs(); GameFlowData.gameState = GameState.BothTeams_Decision; GameFlowData.Networkm_currentTurn = 1; GameFlowData.Networkm_willEnterTimebankMode = true; GameFlowData.Networkm_timeRemainingInDecisionOverflow = 5; UpdateAllNetObjs(); GameFlow.CallRpcSetMatchTime(0); // kRpcRpcApplyAbilityModById foreach (ActorData actor in GameFlowData.GetActors()) { var turnSm = actor.gameObject.GetComponent <ActorTurnSM>(); turnSm.CallRpcTurnMessage(TurnMessage.TURN_START, 0); } BarrierManager.CallRpcUpdateBarriers(); GameFlowData.CallRpcUpdateTimeRemaining(21); PrintAllNetworkGameObjects(); }