public void Update(Game_PlayerController player) { player.Level.GameMap.OverlapActorsSquare(player.transform.position, ViewDistance, newEntities); for (int i = newEntities.Count; i-- > 0;) { if (ReferenceEquals(newEntities[i], player)) { newEntities.RemoveAt(i); continue; } if (!syncedEntities.Contains(newEntities[i])) { IntroduceRelevanceEntity(player, newEntities[i]); syncedEntities.Add(newEntities[i]); } oldEntities.Remove(newEntities[i]); } for (int i = 0; i < oldEntities.Count; i++) { player.ActiveSession.S2C_BASE_PAWN_REMOVE(oldEntities[i].Pawn as Base_Pawn); syncedEntities.Remove(oldEntities[i]); } oldEntities.Clear(); var ce = oldEntities; oldEntities = newEntities; newEntities = ce; }
public GameSession Get(Game_PlayerController controller) { for (int i = 0; i < sessions.Count; i++) { var gs = sessions[i] as GameSession; if (gs != null && gs.ActiveController == controller) { return(gs); } } throw new Exception("Session not found for controller: " + controller); }
public void S2C_PLAYER_ADD(Game_PlayerController pc) { var msg = GameHeader.S2C_PLAYER_ADD.CreatePacket(); pc.WriteAddStream(msg); var pawn = pc.Pawn as Game_PlayerPawn; pawn.WriteAddStream(msg); pawn.Appearance.WriteAddStream(msg); pawn.BaseAppearance.WriteAddStream(msg); pawn.Character.WriteAddStream(msg); pawn.CharacterStats.WriteAddStream(msg); pawn.combatState.WriteAddStream(msg); pawn.Effects.WriteAddStream(msg); Connection.SendMessage(msg); }
void IntroduceRelevanceEntity(Game_PlayerController player, Game_Controller other) { var pc = other as Game_PlayerController; if (pc != null) { player.ActiveSession.S2C_PLAYER_ADD(pc); return; } var npc = other as Game_NPCController; if (npc != null) { player.ActiveSession.S2C_NPC_ADD(npc); return; } Debug.LogWarning("Relevance ADD type not implemented: " + other.GetType()); }
public void cl_OnPlayerTick(float aDeltaTime, Game_PlayerController outer) { //Game_PlayerPawn gpp = (Game_PlayerPawn)outer.Pawn; outer.TickMovement(aDeltaTime); }