public void CompensationSnapshot(ContextsServerWrapper contextsServerWrapper, SnapshotFactory snapshotFactory) { int snapshotSeq = contextsServerWrapper.GetNextSeq(); int vehicleSimulationTime = contextsServerWrapper.SimulationTimer.CurrentTime; int serverTime = contextsServerWrapper.CurrentTime.CurrentTime; ISnapshot compensationSnapshot = snapshotFactory.GenerateCompensationSnapshot(); compensationSnapshot.ServerTime = serverTime; compensationSnapshot.SnapshotSeq = snapshotSeq; compensationSnapshot.VehicleSimulationTime = vehicleSimulationTime; contextsServerWrapper.SnapshotPool.AddSnapshot(compensationSnapshot); compensationSnapshot.ReleaseReference(); }
public ServerRoom Create(RequestCreateRoomMessage message) { _logger.InfoFormat("Handle CreateRoom Message"); var contextsServerWrapper = new ContextsServerWrapper(_contexts, _assetMananger, _coRouitneManager); var serverRoom = new ServerRoom(new RoomId(1), contextsServerWrapper, _dispatcher, _tokenGenerator); ResetEventDispacther(); if (message != null) { HallRoom hallRoom = new HallRoom(_dispatcher, _contexts); hallRoom.HallRoomId = message.HallRoomId; hallRoom.ModeId = message.ModeId; hallRoom.TeamCapacity = message.TeamCapacity; hallRoom.MapId = message.MapId; hallRoom.RevivalTime = message.RevivalTime; hallRoom.MultiAngleStatus = message.MultiAngleStatus; hallRoom.WatchStatus = message.WatchStatus; hallRoom.HelpStatus = message.HelpStatus; hallRoom.HasFriendHarm = message.HasFriendHarm; hallRoom.WaitTimeNum = message.WaitTimeNum; hallRoom.OverTime = message.OverTime; hallRoom.ConditionValue = message.ConditionValue; hallRoom.ConditionType = message.ConditionType; hallRoom.ChannelName = message.ChannelName; hallRoom.RoomName = message.CustomRoomName; hallRoom.RoomCapacity = message.CustomRoomCapacity; hallRoom.RoomDisplayId = (int)message.CustomRoomDisplayId; hallRoom.AllowReConnect = message.AllowReConnect; hallRoom.Init(); serverRoom.SetHallRoom(hallRoom); serverRoom.SetRoomInfo(hallRoom); serverRoom.SetGameMode(message.ModeId, message.MapId); _logger.InfoFormat("Create Room {0}", message); } else { HallRoom hallRoom = new DummyHallRoom(_dispatcher, _contexts); serverRoom.SetGameMode(RuleMap.GetRuleId(SingletonManager.Get <ServerFileSystemConfigManager>().BootConfig.Rule), SingletonManager.Get <ServerFileSystemConfigManager>().BootConfig.MapId); //hallRoom.Init(); //本地测试无需发战报 serverRoom.SetHallRoom(hallRoom); } return(serverRoom); }
public ServerRoom(RoomId id, ContextsServerWrapper contextsServerWrapper, RoomEventDispatcher dispatcher, IPlayerTokenGenerator playerTokenGenerator) { state = RoomState.Initialized; isDisposed = false; RoomId = id; ContextsWrapper = contextsServerWrapper; MessageDispatcher = CreateNetworMessageHandlers(); tokenGenerator = playerTokenGenerator; eventDispatcher = dispatcher; snapshotFactory = new SnapshotFactory(ContextsWrapper.GameContexts); sessionStateMachine = new ServerSessionStateMachine(ContextsWrapper.contexts, this); damager = new SimplePlayerDamager(this); compensationManager = new CompensationManager(); VehicleDamageUtility._damager = damager; sendSnapshotManager = new SendSnapshotManager(ContextsWrapper.contexts); }