public void SetUp() { GameSceneFactory gameSceneFactory = new GameSceneFactory(); Scene matchScene = gameSceneFactory.Create(); ArrangeTransformSystem[] arrangeCollidersSystems = { new WithHpArrangeTransformSystem(contexts) }; PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems); PhysicsVelocityManager physicsVelocityManager = new PhysicsVelocityManager(); PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager(); SnapshotFactory snapshotFactory = new SnapshotFactory(contexts.serverGame); playerPredictor = new PlayerPredictor(physicsRollbackManager, matchScene, contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory); playerEntity = contexts.serverGame.CreateEntity(); ClientPrefabsStorage clientPrefabsStorage = new ClientPrefabsStorage(); GameObject warshipPrefab = clientPrefabsStorage.GetPrefab(ViewTypeEnum.StarSparrow1); GameObject go = Object.Instantiate(warshipPrefab, Vector3.zero, Quaternion.identity); SceneManager.MoveGameObjectToScene(go, matchScene); ushort playerEntityId = 100; playerEntity.AddId(playerEntityId); playerEntity.AddView(go); playerEntity.AddRigidbody(go.GetComponent <Rigidbody>()); LogAssert.ignoreFailingMessages = true; }
public override object Deserialize(Stream inStream) { var rc = _snapshotReplicator.Deserialize(inStream); #pragma warning disable RefCounter002 ISnapshot old = (ISnapshot)rc; #pragma warning restore RefCounter002 ISnapshot copy = SnapshotFactory.CloneSnapshot(old); old.ReleaseReference(); // boost performance { var a = copy.LatestEntityMap; var b = copy.CompensationEntityMap; var c = copy.NonSelfEntityMap; var d = copy.SelfEntityMap; foreach (var entity in copy.EntityMap.Values) { var e = entity.SortedComponentList; var h = entity.PlayBackComponentDictionary; var j = entity.SyncLatestComponentDictionary; } } return(copy); }
public PredictedSnapshotHistoryUpdater(Contexts contexts, PredictedSnapshotsStorage predictedSnapshotsStorage, IMatchTimeStorage matchTimeStorage, ILastInputIdStorage lastInputIdStorage) { this.predictedSnapshotsStorage = predictedSnapshotsStorage; this.matchTimeStorage = matchTimeStorage; this.lastInputIdStorage = lastInputIdStorage; snapshotFactory = new SnapshotFactory(contexts.serverGame); }
public void SendSnapshot(int interval, SnapshotFactory snapshotFactory, Dictionary <INetworkChannel, PlayerEntity> channelToPlayer) { var sessionObjects = _contexts.session.serverSessionObjects; Bin2DConfig bin2DConfig = sessionObjects.Bin2DConfig; IBin2DManager bin = sessionObjects.Bin2dManager; int snapshotSeq = sessionObjects.GetNextSnapshotSeq(); int vehicleSimulationTime = sessionObjects.SimulationTimer.CurrentTime; int serverTime = _contexts.session.currentTimeObject.CurrentTime; _sendSnapshotTasks.Clear(); var freeMoveEntitys = _globalFreeMoveEntities.GetEntities(); var weaponEntities = _globalWeaponEntities.GetEntities(); foreach (var entry in channelToPlayer) { INetworkChannel channel = entry.Key; PlayerEntity player = entry.Value; if (player.hasStage && player.stage.CanSendSnapshot() && channel.IsConnected && !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime)) { var p = ObjectAllocatorHolder <CreateSnapshotParams> .Allocate().Build(snapshotFactory, player, bin2DConfig, bin, serverTime, snapshotSeq, vehicleSimulationTime, channel); var entitys = p.PreEnitys; AddTeamPlayers(player, entitys, _contexts); AddGlobalFreeMove(player, entitys, freeMoveEntitys); AddWeapon(player, entitys, weaponEntities); _sendSnapshotTasks.Add(p); } else { player.network.NetworkChannel.Serializer.MessageTypeInfo.IncSendSnapShot(); _logger.DebugFormat("channel:{2} skip SendSnapshot :{0} {1}!", channel.IsConnected, !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime), channel.IdInfo()); } } if (SharedConfig.MutilThread) { #if ENABLE_NEW_SENDSNAPSHOT_THREAD ConsumerExecute(); #else MutilExecute(); #endif } else { MainExecute(); } _logger.DebugFormat("SendSnapshot Threads Done;"); }
public PlayerPredictor(PhysicsRollbackManager physicsRollbackManager, Scene scene, ServerGameContext gameContext, PhysicsVelocityManager physicsVelocityManager, PhysicsRotationManager physicsRotationManager, SnapshotFactory snapshotFactory) { this.scene = scene; this.gameContext = gameContext; this.snapshotFactory = snapshotFactory; this.physicsRollbackManager = physicsRollbackManager; this.physicsVelocityManager = physicsVelocityManager; this.physicsRotationManager = physicsRotationManager; }
public CreateSnapshotParams Build(SnapshotFactory snapshotFactory, PlayerEntity player, Bin2DConfig bin2DConfig, IBin2DManager bin, int serverTime, int snapshotSeq, int vehicleSimulationTime, INetworkChannel channel) { SnapshotFactory = snapshotFactory; Player = player; Bin2DConfig = bin2DConfig; Bin = bin; ServerTime = serverTime; SnapshotSeq = snapshotSeq; VehicleSimulationTime = vehicleSimulationTime; Channel = channel; PreEnitys.Clear(); return(this); }
protected override void OnCleanUp() { Snapshot = null; SnapshotFactory = null; Player = null; Bin2DConfig = null; Bin = null; ServerTime = 0; SnapshotSeq = 0; VehicleSimulationTime = 0; Channel = null; PreEnitys.Clear(); ObjectAllocatorHolder <CreateSnapshotParams> .Free(this); }
internal LinterTagger( TaggerProvider provider, ITextBuffer buffer, ITextDocument document) { _provider = provider; _buffer = buffer; _document = document; _currentSnapshot = buffer.CurrentSnapshot; _dirtySpans = new NormalizedSnapshotSpanCollection(); FilePath = document.FilePath; Factory = new SnapshotFactory(new LinterSnapshot(FilePath, 0, new List <MessageMarker>())); Initialize(); }
public async Task Test6() { var provider = new HareDuConfigProvider(); var config1 = provider.Configure(x => { x.Broker(y => { y.ConnectTo("http://localhost:15672"); y.UsingCredentials("guest", "guest"); }); x.Diagnostics(y => { y.Probes(z => { z.SetMessageRedeliveryThresholdCoefficient(0.60M); z.SetSocketUsageThresholdCoefficient(0.60M); z.SetConsumerUtilizationThreshold(0.65M); z.SetQueueHighFlowThreshold(90); z.SetQueueLowFlowThreshold(10); z.SetRuntimeProcessUsageThresholdCoefficient(0.65M); z.SetFileDescriptorUsageThresholdCoefficient(0.65M); z.SetHighConnectionClosureRateThreshold(90); z.SetHighConnectionCreationRateThreshold(60); }); }); }); var factory1 = new SnapshotFactory(config1); var lens = factory1.Lens <BrokerConnectivitySnapshot>(); var result = await lens.TakeSnapshot(); var factory2 = new ScannerFactory(config1, new KnowledgeBaseProvider()); IScanner scanner = new Scanner(factory2); var report = scanner.Scan(result.Snapshot); var formatter = new DiagnosticReportTextFormatter(); string formattedReport = formatter.Format(report); Console.WriteLine(formattedReport); }
public ServerRoom(IRoomId roomId, Contexts contexts, IRoomEventDispatchter eventDispatcher, ICoRoutineManager coRoutineManager, IUnityAssetManager assetManager, IPlayerTokenGenerator tokenGenerator) { //SingletonManager.Get<ServerFileSystemConfigManager>().Reload(); _state = RoomState.Initialized; _tokenGenerator = tokenGenerator; _coRoutineManager = coRoutineManager; var entityIdGenerator = new EntityIdGenerator(EntityIdGenerator.GlobalBaseId); var equipmentEntityIdGenerator = new EntityIdGenerator(EntityIdGenerator.EquipmentBaseId); var ruleId = RuleMap.GetRuleId(SingletonManager.Get <ServerFileSystemConfigManager>().BootConfig.Rule); RoomId = roomId; _contexts = contexts; #if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR) _contexts.InitializeContexObservers(); #endif SingletonManager.Get <MyProfilerManager>().Contexts = _contexts; _eventDispatcher = eventDispatcher; _bin2DManager = CreateBin2DManager(); IniCurrentTimeSession(); InitEntityFactorySession(entityIdGenerator, equipmentEntityIdGenerator); _assetManager = assetManager; InitCommonSession(entityIdGenerator, equipmentEntityIdGenerator, ruleId); InitServerSession(_bin2DManager, ruleId); _contexts.vehicle.SetSimulationTime(0); MessageDispatcher = CreateNetworMessageHandlers(); _snapshotFactory = new SnapshotFactory(_contexts.session.commonSession.GameContexts); _sessionStateMachine = new ServerSessionStateMachine(_contexts, this); _damager = new SimplePlayerDamager(this); VehicleDamageUtility._damager = _damager; _sendSnapshotManager = new SendSnapshotManager(_contexts); InitialWeaponSkill(); }
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); }
public CompareSnapshotsUseCase(SnapshotFactory snapshotFactory) { this.snapshotFactory = snapshotFactory ?? throw new ArgumentNullException(nameof(snapshotFactory)); }
private Entitas.Systems CreateSystems(UdpSendUtils udpSendUtils, BattleRoyaleClientMatchModel matchModel, PingStatisticsStorage statisticsStorage) { GameSceneFactory gameSceneFactory = new GameSceneFactory(); var matchScene = gameSceneFactory.Create(); PhysicsSpawner physicsSpawner = new PhysicsSpawner(matchScene); contexts = Contexts.sharedInstance; var updatePlayersSystem = new UpdatePlayersSystem(contexts, matchModel); playersStorage = updatePlayersSystem; var healthUpdaterSystem = new HealthUpdaterSystem(contexts); healthPointsStorage = healthUpdaterSystem; var maxHealthUpdaterSystem = new MaxHealthUpdaterSystem(contexts); maxHealthPointsMessagePackStorage = maxHealthUpdaterSystem; Vector3 cameraShift = new Vector3(0, 60, -30); ushort playerTmpId = matchModel.PlayerTemporaryId; int matchId = matchModel.MatchId; Text pingText = battleUiController.GetPingText(); pingSystem = new PingSystem(pingText, statisticsStorage); ClientInputMessagesHistory clientInputMessagesHistory = new ClientInputMessagesHistory(playerTmpId, matchId); ClientPrefabsStorage clientPrefabsStorage = new ClientPrefabsStorage(); PhysicsVelocityManager physicsVelocityManager = new PhysicsVelocityManager(); ArrangeTransformSystem[] arrangeCollidersSystems = { new WithHpArrangeTransformSystem(contexts) }; PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems); PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager(); SnapshotFactory snapshotFactory = new SnapshotFactory(contexts.serverGame); PlayerPredictor playerPredictor = new PlayerPredictor(physicsRollbackManager, matchScene, contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory); PlayerEntityComparer playerEntityComparer = new PlayerEntityComparer(); PredictedSnapshotsStorage predictedSnapshotsStorage = new PredictedSnapshotsStorage(); AverageInputManager averageInputManager = new AverageInputManager(); PredictionChecker predictionChecker = new PredictionChecker(playerEntityComparer, predictedSnapshotsStorage); SimulationCorrector simulationCorrector = new SimulationCorrector(playerPredictor, averageInputManager, clientInputMessagesHistory, predictedSnapshotsStorage); var predictionManager = new PredictionManager(predictionChecker, simulationCorrector); Joystick movementJoystick = battleUiController.GetMovementJoystick(); Joystick attackJoystick = battleUiController.GetAttackJoystick(); LastInputIdStorage lastInputIdStorage = new LastInputIdStorage(); SnapshotBuffer snapshotBuffer = new SnapshotBuffer(); var snapshotInterpolator = new SnapshotInterpolator(snapshotBuffer); var consoleStub = new ConsoleNetworkProblemWarningView(); NetworkTimeManager timeManager = new NetworkTimeManager(pingStatisticsStorage, snapshotBuffer, consoleStub); INetworkTimeManager networkTimeManager = timeManager; ITimeUpdater timeUpdater = timeManager; snapshotManager = new SnapshotManager(snapshotBuffer, snapshotInterpolator); transformStorage = new TransformMessageHandler(snapshotBuffer, timeUpdater); MatchTimeSystem matchTimeSystem = new MatchTimeSystem(networkTimeManager); IMatchTimeStorage matchTimeStorage = matchTimeSystem; var updateTransformSystem = new UpdateTransformSystem(contexts, snapshotManager, matchTimeStorage); SpawnManager spawnManager = new SpawnManager(clientPrefabsStorage, physicsSpawner); var killsIndicatorSystem = new KillsIndicatorSystem(battleUiController.GetKillMessage(), battleUiController.GetKillIndicator(), battleUiController.GetKillsText(), battleUiController.GetAliveText(), matchModel.PlayerModels.Length, new PlayerNameHelper(matchModel)); killMessageStorage = killsIndicatorSystem; systems = new Entitas.Systems() .Add(matchTimeSystem) .Add(new ServerGameStateDebugSystem(snapshotBuffer, clientPrefabsStorage)) .Add(new PredictionСheckSystem(snapshotBuffer, predictionManager)) .Add(updateTransformSystem) .Add(updatePlayersSystem) .Add(new PrefabSpawnerSystem(contexts, spawnManager)) .Add(new InputSystem(movementJoystick, attackJoystick, clientInputMessagesHistory, snapshotManager, matchTimeStorage, lastInputIdStorage)) .Add(new PlayerStopSystem(contexts)) .Add(new PlayerPredictionSystem(contexts, clientInputMessagesHistory, playerPredictor)) .Add(new CameraMoveSystem(contexts, battleUiController.GetMainCamera(), cameraShift)) .Add(new LoadingImageSwitcherSystem(contexts, battleUiController.GetLoadingImage())) .Add(killsIndicatorSystem) .Add(healthUpdaterSystem) .Add(maxHealthUpdaterSystem) .Add(new HealthBarSpawnSystem(contexts, new HealthBarStorage())) .Add(new HealthBarSliderUpdaterSystem(contexts)) .Add(new HealthBarPositionUpdaterSystem(contexts)) .Add(new HealthBarRotatingSystem(contexts, cameraShift)) .Add(new HealthTextUpdatingSystem(contexts)) .Add(new HealthBarDestroyHelperSystem(contexts)) .Add(new DestroyViewSystem(contexts)) .Add(new InputSenderSystem(udpSendUtils, clientInputMessagesHistory)) .Add(new RudpMessagesSenderSystem(udpSendUtils)) .Add(new GameContextClearSystem(contexts)) .Add(new PredictedSnapshotHistoryUpdater(contexts, predictedSnapshotsStorage, matchTimeStorage, lastInputIdStorage)) ; return(systems); }
public PresentSnapshotUseCase(SnapshotFactory snapshotFactory) { this.snapshotFactory = snapshotFactory ?? throw new ArgumentNullException(nameof(snapshotFactory)); }
public OfflineSnapshotSelector(EntityKey self, IGameContexts gameContexts) { _self = self; _snapshotFac = new SnapshotFactory(gameContexts); }
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 void SendSnapshot(int interval, SnapshotFactory snapshotFactory) { _logger.InfoFormat("SendSnapShot"); this.snapshotFactory = snapshotFactory; var sessionObjects = _contexts.session.serverSessionObjects; Bin2DConfig bin2DConfig = sessionObjects.Bin2DConfig; IBin2DManager bin = sessionObjects.Bin2dManager; int snapshotSeq = sessionObjects.GetNextSnapshotSeq(); int vehicleSimulationTime = sessionObjects.SimulationTimer.CurrentTime; int serverTime = _contexts.session.currentTimeObject.CurrentTime; snapshotSendTasks.Clear(); var freeMoveEntitys = _globalFreeMoveEntities.GetEntities(); var weaponEntities = _globalWeaponEntities.GetEntities(); foreach (var player in _playerEntities.GetEntities()) { if (player.hasStage && player.stage.CanSendSnapshot() && player.network.NetworkChannel.IsConnected && !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime)) { var p = ObjectAllocatorHolder <CreateSnapshotTask> .Allocate().Build(player, bin2DConfig, bin, serverTime, snapshotSeq, vehicleSimulationTime, player.network.NetworkChannel, _contexts); AddTeamPlayers(player, p.PreEntitas, _contexts); AddGlobalFreeMove(player, p.PreEntitas, freeMoveEntitys); AddWeapon(player, p.PreEntitas, weaponEntities); snapshotSendTasks.Add(p); #if ENABLE_NEW_SENDSNAPSHOT_THREAD if (SharedConfig.MutilThread) { _queue.AddRef(); _queue.Enqueue(p); } #endif //_logger.InfoFormat("SendSnapshot:{0} {1}",player.entityKey.Value, player.position.Value); } else { player.network.NetworkChannel.Serializer.MessageTypeInfo.IncSendSnapShot(); _logger.DebugFormat("channel:{2} skip SendSnapshot :{0} {1}!", player.network.NetworkChannel.IsConnected, !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime), player.network.NetworkChannel.IdInfo()); } } if (SharedConfig.MutilThread) { #if ENABLE_NEW_SENDSNAPSHOT_THREAD ConsumerExecute(); #else MutilExecute(); #endif } else { MainExecute(); } _logger.DebugFormat("SendSnapshot Threads Done;"); }