public void Execute() { if (infosWasChanged) { _cannonCooldownsController.Load(weaponInfos); var dict = new Dictionary <ushort, float>(weaponInfos.Length); for (ushort i = 0; i < weaponInfos.Length; i++) { dict.Add(i, 0f); } approximator.Set(dict, Time.time); infosWasChanged = false; } _cannonCooldownsController.SetCooldowns(approximator.Get(Time.time).Values.ToArray()); if (cooldownsWasChanged) { var dict = new Dictionary <ushort, float>(cooldowns.Length); for (ushort i = 0; i < cooldowns.Length; i++) { dict.Add(i, cooldowns[i]); } approximator.Set(dict, Time.time); cooldownsWasChanged = false; } }
public AbilityUpdaterSystem(CooldownInfo abilityCooldownInfo, IApproximator <float> abilityCooldownApproximator) { if (abilityCooldownInfo == null) { throw new NullReferenceException($"{nameof(AbilityUpdaterSystem)} {nameof(abilityCooldownInfo)} was null"); } approximator = abilityCooldownApproximator; approximator.Set(new Dictionary <ushort, float> { { 0, float.PositiveInfinity } }, Time.time - Time.deltaTime); approximator.Set(new Dictionary <ushort, float> { { 0, float.PositiveInfinity } }, Time.time); _cooldownInfo = abilityCooldownInfo; }
public TimeSpeedSystem(Contexts contexts, IApproximator <float> timeApproximator) { gameContext = contexts.game; _lastMessageId = 0; WasChanged = false; approximator = timeApproximator; _serverDeltaTime = ServerTimeConstants.MinDeltaTime; defaultFixedDeltaTime = Time.fixedDeltaTime; approximator.Set(new Dictionary <ushort, float>(1) { { 0, ServerTimeConstants.MinDeltaTime } }, Time.time - Time.deltaTime); approximator.Set(new Dictionary <ushort, float>(1) { { 0, ServerTimeConstants.MinDeltaTime } }, Time.time); }
public void Execute() { if (maxCooldownWasChanged) { _cooldownInfo.Load(maxCooldown); maxCooldownWasChanged = false; } _cooldownInfo.SetCooldown(approximator.Get(Time.time)[0]); if (currentCooldownWasChanged) { approximator.Set(new Dictionary <ushort, float> { { 0, currentCooldown } }, Time.time); currentCooldownWasChanged = false; } }
public void Execute() { lock (LockObj) { var radiuses = approximator.Get(Time.time); if (!wasProcessed) { approximator.Set(new Dictionary <ushort, float>(UpdateRadiusSystem.radiuses), Time.time); wasProcessed = true; } foreach (var radiusPair in radiuses) { var entity = gameContext.GetEntityWithId(radiusPair.Key); if (entity != null && entity.hasCircle) { entity.ReplaceCircle(radiusPair.Value); entity.isHidden = false; UpdateRadiusSystem.radiuses.Remove(radiusPair.Key); } else { //DebugLogWarning("Пришла информация об объекте, которого нет на карте: " + radiusPair.Key); } } //Зона всегда является объектом с id = 0 if (radiuses.TryGetValue(0, out var zoneRadius)) { if (gameContext.hasZoneInfo) { gameContext.zoneInfo.radius = zoneRadius; } } wasProcessed = UpdateRadiusSystem.radiuses.Count == 0; } }
public void Execute() { var dict = approximator.Get(Time.time); var serverDeltaTime = dict[0]; lock (LockObj) { if (WasChanged) { //log.Debug("Server FPS: " + 1f / _serverDeltaTime); approximator.Set(new Dictionary <ushort, float>(1) { { 0, _serverDeltaTime } }, Time.time); WasChanged = false; } } var timeScale = ServerTimeConstants.MinDeltaTime / serverDeltaTime; Time.timeScale = timeScale; Time.fixedDeltaTime = defaultFixedDeltaTime * timeScale; }