float getSpeed(TimeSpeed sp) { if (sp == TimeSpeed.speedX075) { return(0.75f); } else if (sp == TimeSpeed.speedX1) { return(1); } else if (sp == TimeSpeed.speedX125) { return(1.25f); } else if (sp == TimeSpeed.speedX15) { return(1.5f); } else if (sp == TimeSpeed.speedX2) { return(2f); } Debug.Log("time speed error"); return(1); }
public DiaNode GetAirStrikeDetailsDiaNode(DiaNode parentNode, AirStrikeDef strikeDef) { DiaNode airStrikeDetailsDiaNode = new DiaNode(strikeDef.LabelCap + "\n\n" + strikeDef.description + "\n\n" + "Runs number: " + strikeDef.runsNumber + "\n\n" + "Cost: " + strikeDef.costInSilver + " silvers"); DiaOption airStrikeConfirmDiaOption = new DiaOption("Confirm"); airStrikeConfirmDiaOption.action = delegate { this.previousTimeSpeed = Find.TickManager.CurTimeSpeed; Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; this.selectedStrikeDef = strikeDef; Util_Misc.SelectAirStrikeTarget(this.Map, SpawnAirStrikeBeacon); }; airStrikeConfirmDiaOption.resolveTree = true; if (TradeUtility.ColonyHasEnoughSilver(this.Map, strikeDef.costInSilver) == false) { airStrikeConfirmDiaOption.Disable("not enough silver"); } airStrikeDetailsDiaNode.options.Add(airStrikeConfirmDiaOption); DiaOption airStrikeBackDiaOption = new DiaOption("Back"); airStrikeBackDiaOption.link = parentNode; airStrikeDetailsDiaNode.options.Add(airStrikeBackDiaOption); return(airStrikeDetailsDiaNode); }
private void TimeSpeedUpdate(GameTime gameTime) { int t = gameTime.ElapsedGameTime.Milliseconds; switch (timeSpeed) { case TimeSpeed.VERYSLOW: verySlowTimeTimer -= t; slowTimeTimer -= t * (int)TimeSpeed.SLOW / (int)TimeSpeed.VERYSLOW; halfTimeTimer -= t * (int)TimeSpeed.HALF / (int)TimeSpeed.VERYSLOW; if (verySlowTimeTimer < 0) { timeSpeed = TimeSpeed.SLOW; } break; case TimeSpeed.SLOW: slowTimeTimer -= t; halfTimeTimer -= t * (int)TimeSpeed.HALF / (int)TimeSpeed.SLOW; if (slowTimeTimer < 0) { timeSpeed = TimeSpeed.HALF; } break; case TimeSpeed.HALF: halfTimeTimer -= t; if (halfTimeTimer < 0) { timeSpeed = TimeSpeed.NORMAL; } break; } }
public static void ForcePauseFromVehicles(ref TimeSpeed __result) { if (LandingTargeter.Instance.ForcedTargeting || StrafeTargeter.Instance.ForcedTargeting) { __result = TimeSpeed.Paused; } }
static void Prefix(ref ITickable __state) { if (Multiplayer.Client == null) { return; } if (!WorldRendererUtility.WorldRenderedNow && Find.CurrentMap == null) { return; } ITickable tickable = Multiplayer.WorldComp; if (!WorldRendererUtility.WorldRenderedNow && Multiplayer.WorldComp.asyncTime) { tickable = Find.CurrentMap.AsyncTime(); } TimeSpeed speed = tickable.TimeSpeed; if (Multiplayer.IsReplay) { speed = TickPatch.replayTimeSpeed; } savedSpeed = Find.TickManager.CurTimeSpeed; Find.TickManager.CurTimeSpeed = speed; prevSpeed = speed; keyPressed = Event.current.isKey; __state = tickable; }
private float TickRate(TimeSpeed currTimeSpeed) { switch ((int)currTimeSpeed) { case 0: return(0f); case 1: return(1f); case 2: return(3f); case 3: if (Current.Game.CurrentMap == null) { return(150f); } if (this.NothingHappeningInGame()) { return(12f); } return(6f); case 4: if (Current.Game.CurrentMap == null) { return(250f); } return(15f); default: return(-1f); } }
private float TickRate(TimeSpeed currTimeSpeed) { switch (currTimeSpeed) { case TimeSpeed.Paused: return(0f); case TimeSpeed.Normal: return(1f); case TimeSpeed.Fast: return(3f); case TimeSpeed.Superfast: if (Find.VisibleMap == null) { return(150f); } if (NothingHappeningInGame()) { return(12f); } return(6f); case TimeSpeed.Ultrafast: if (Find.VisibleMap == null) { return(250f); } return(15f); default: return(-1f); } }
private static void PlaySoundOf(TimeSpeed speed) { SoundDef soundDef = null; switch (speed) { case TimeSpeed.Paused: soundDef = SoundDefOf.Clock_Stop; break; case TimeSpeed.Normal: soundDef = SoundDefOf.Clock_Normal; break; case TimeSpeed.Fast: soundDef = SoundDefOf.Clock_Fast; break; case TimeSpeed.Superfast: soundDef = SoundDefOf.Clock_Superfast; break; case TimeSpeed.Ultrafast: soundDef = SoundDefOf.Clock_Superfast; break; } if (soundDef != null) { soundDef.PlayOneShotOnCamera(null); } }
public float TimePerTick(TimeSpeed speed) { if (TickRateMultiplier(speed) == 0f) { return(0f); } return(1f / TickRateMultiplier(speed)); }
public void Awake() { SimulationManager.RegisterSimulationManager(this); speed = new TimeSpeed() { num = 1, den = 1 }; // TimeSpeeds[speedIndex]; }
public static float TimePerTick(this ITickable tickable, TimeSpeed speed) { if (tickable.ActualRateMultiplier(speed) == 0f) { return(0f); } return(1f / tickable.ActualRateMultiplier(speed)); }
public static float ActualRateMultiplier(this ITickable tickable, TimeSpeed speed) { if (Multiplayer.WorldComp.asyncTime) { return(tickable.TickRateMultiplier(speed)); } return(Find.Maps.Select(m => (ITickable)m.AsyncTime()).Concat(Multiplayer.WorldComp).Select(t => t.TickRateMultiplier(speed)).Min()); }
public static void SendTimeChange(ITickable tickable, TimeSpeed newSpeed) { if (tickable is MultiplayerWorldComp) { Multiplayer.Client.SendCommand(CommandType.WorldTimeSpeed, ScheduledCommand.Global, (byte)newSpeed); } else if (tickable is MapAsyncTimeComp comp) { Multiplayer.Client.SendCommand(CommandType.MapTimeSpeed, comp.map.uniqueID, (byte)newSpeed); } }
static bool Prefix(ref float __result, ITickable tickable, TimeSpeed speed) { if (MultiplayerWorldComp.asyncTime) { __result = tickable.TickRateMultiplier(speed) / RefcellRespeedConfig.currentTimeMultiplier; return(false); } __result = Find.Maps.Select(m => (ITickable)m.AsyncTime()).Concat(Multiplayer.Client.Multiplayer.WorldComp).Select(t => t.TickRateMultiplier(speed)).Min() / RefcellRespeedConfig.currentTimeMultiplier; return(false); }
public static void Postfix(ref TimeSpeed currTimeSpeed, ref float __result) { if (__result == 15f) // its 4x speed { int speed = Settings.Get().CoreSK_Max4Speed; if (speed == 900 || speed <= 0) // default 4x max { return; } __result = speed / 60f; } }
public void timeTurnFast() { if (timeSpeed == TimeSpeed.speedX2) { timeSpeed = TimeSpeed.speedX2; } else { timeSpeed++; } currentTimeScale = getSpeed(timeSpeed); }
public void timeTurnSlow() { if (timeSpeed == TimeSpeed.speedX075) { timeSpeed = TimeSpeed.speedX075; } else { timeSpeed--; } currentTimeScale = getSpeed(timeSpeed); }
public static void setTimeSettingForTimeSpeed(TimeSpeed timeSpeed) { if (timeSpeed == TimeSpeed.Paused) { #if DEBUG Log.Message("Paused It"); #endif timeSetting = 0f; return; } timeSetting = keyPoints[Math.Min(5, (int)timeSpeed) + 1].x; }
public void TogglePaused() { if (curTimeSpeed != 0) { prePauseTimeSpeed = curTimeSpeed; curTimeSpeed = TimeSpeed.Paused; } else if (prePauseTimeSpeed != curTimeSpeed) { curTimeSpeed = prePauseTimeSpeed; } else { curTimeSpeed = TimeSpeed.Normal; } }
public void TogglePaused() { if (this.curTimeSpeed != 0) { this.prePauseTimeSpeed = this.curTimeSpeed; this.curTimeSpeed = TimeSpeed.Paused; } else if (this.prePauseTimeSpeed != this.curTimeSpeed) { this.curTimeSpeed = this.prePauseTimeSpeed; } else { this.curTimeSpeed = TimeSpeed.Normal; } }
public float TickRateMultiplier(TimeSpeed speed) { var comp = map.MpComp(); var enforcePause = comp.transporterLoading != null || comp.caravanForming != null || comp.ritualSession != null || comp.mapDialogs.Any() || Multiplayer.WorldComp.AnyTradeSessionsOnMap(map) || Multiplayer.WorldComp.splitSession != null; if (enforcePause) { return(0f); } if (mapTicks < slower.forceNormalSpeedUntil) { return(speed == TimeSpeed.Paused ? 0 : 1); } switch (speed) { case TimeSpeed.Paused: return(0f); case TimeSpeed.Normal: return(1f); case TimeSpeed.Fast: return(3f); case TimeSpeed.Superfast: if (nothingHappeningCached) { return(12f); } return(6f); case TimeSpeed.Ultrafast: return(15f); default: return(-1f); } }
static void Postfix(ITickable __state, Rect timerRect) { if (__state == null) { return; } Rect rect = new Rect(timerRect.x, timerRect.y, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); float normalSpeed = __state.ActualRateMultiplier(TimeSpeed.Normal); float fastSpeed = __state.ActualRateMultiplier(TimeSpeed.Fast); if (normalSpeed == 0f) // Completely paused { Widgets.DrawLineHorizontal(rect.x + rect.width, rect.y + rect.height / 2f, rect.width * 3f); } else if (normalSpeed == fastSpeed) // Slowed down { Widgets.DrawLineHorizontal(rect.x + rect.width * 2f, rect.y + rect.height / 2f, rect.width * 2f); } TimeSpeed newSpeed = Find.TickManager.CurTimeSpeed; Find.TickManager.CurTimeSpeed = savedSpeed; if (prevSpeed == newSpeed) { return; } if (Multiplayer.IsReplay) { TickPatch.replayTimeSpeed = newSpeed; } // Prevent multiple players changing the speed too quickly if (keyPressed && Time.realtimeSinceStartup - MultiplayerWorldComp.lastSpeedChange < 0.4f) { return; } TimeControl.SendTimeChange(__state, newSpeed); }
public Battle(GameMain gameMain) : base(gameMain) { timeSpeed = TimeSpeed.NORMAL; time = 0; enemyIndex = 0; enemyPopTimer = 0; halfTimeTimer = 0; slowTimeTimer = 0; verySlowTimeTimer = 0; player = new Player.TestPlayer(this); enemies = new List <VirtualEnemy>(); enemyBullets = new List <VirtualEnemyBullet>(); items = new List <Item.Item>(); effectSystems = new List <EffectSystem.VirtualEffectSystem>(); EnemyTimeLineSet(); }
internal void SetTimeSpeed(TimeSpeed ts, int t) { switch (ts) { case TimeSpeed.HALF: timeSpeed = (ts > timeSpeed) ? ts : timeSpeed; halfTimeTimer = (t > halfTimeTimer) ? t : halfTimeTimer; break; case TimeSpeed.SLOW: timeSpeed = (ts > timeSpeed) ? ts : timeSpeed; slowTimeTimer = (t > slowTimeTimer) ? t : slowTimeTimer; break; case TimeSpeed.VERYSLOW: timeSpeed = (ts > timeSpeed) ? ts : timeSpeed; verySlowTimeTimer = (t > verySlowTimeTimer) ? t : verySlowTimeTimer; break; } }
public float TickRateMultiplier(TimeSpeed speed) { if (Multiplayer.GameComp.asyncTime) { var enforcePause = Multiplayer.WorldComp.splitSession != null; if (enforcePause) { return(0f); } } return(speed switch { TimeSpeed.Paused => 0f, TimeSpeed.Normal => 1f, TimeSpeed.Fast => 3f, TimeSpeed.Superfast => 6f, TimeSpeed.Ultrafast => 15f, _ => - 1f });
public float TickRateMultiplier(TimeSpeed speed) { var comp = map.MpComp(); if (comp.transporterLoading != null || comp.caravanForming != null || comp.mapDialogs.Any() || Multiplayer.WorldComp.trading.Any(t => t.playerNegotiator.Map == map)) { return(0f); } if (mapTicks < slower.forceNormalSpeedUntil) { return(speed == TimeSpeed.Paused ? 0 : 1); } switch (speed) { case TimeSpeed.Paused: return(0f); case TimeSpeed.Normal: return(1f); case TimeSpeed.Fast: return(3f); case TimeSpeed.Superfast: if (nothingHappeningCached) { return(12f); } return(6f); case TimeSpeed.Ultrafast: return(15f); default: return(-1f); } }
static void Postfix(ITickable __state) { if (__state == null) { return; } TimeSpeed newSpeed = Find.TickManager.CurTimeSpeed; Find.TickManager.CurTimeSpeed = savedSpeed; if (prevSpeed == newSpeed) { return; } if (Multiplayer.IsReplay) { TickPatch.replayTimeSpeed = newSpeed; } TimeControl.SendTimeChange(__state, newSpeed); }
public float TickRateMultiplier(TimeSpeed speed) { switch (speed) { case TimeSpeed.Paused: return(0f); case TimeSpeed.Normal: return(1f); case TimeSpeed.Fast: return(3f); case TimeSpeed.Superfast: return(6f); case TimeSpeed.Ultrafast: return(15f); default: return(-1f); } }
private static void PlaySoundOf(TimeSpeed speed) { SoundStarter.PlayOneShotOnCamera(SoundDef.Named(TimeControls.SpeedSounds[(int)speed].ToString()), null); }
public static void DoTimeControlsGUI(Rect timerRect) { TickManager tickManager = Find.TickManager; GUI.BeginGroup(timerRect); Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y); for (int i = 0; i < TimeControls.CachedTimeSpeedValues.Length; i++) { TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[i]; if (timeSpeed != TimeSpeed.Ultrafast) { if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed])) { if (timeSpeed == TimeSpeed.Paused) { tickManager.TogglePaused(); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); } else { tickManager.CurTimeSpeed = timeSpeed; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); } TimeControls.PlaySoundOf(tickManager.CurTimeSpeed); } if (tickManager.CurTimeSpeed == timeSpeed) { GUI.DrawTexture(rect, TexUI.HighlightTex); } rect.x += rect.width; } } if (Find.TickManager.slower.ForcedNormalSpeed) { Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); } GUI.EndGroup(); GenUI.AbsorbClicksInRect(timerRect); UIHighlighter.HighlightOpportunity(timerRect, "TimeControls"); if (Event.current.type == EventType.KeyDown) { if (KeyBindingDefOf.TogglePause.KeyDownEvent) { Find.TickManager.TogglePaused(); TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Normal.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Fast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Fast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (KeyBindingDefOf.TimeSpeed_Superfast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction); Event.current.Use(); } if (Prefs.DevMode) { if (KeyBindingDefOf.TimeSpeed_Ultrafast.KeyDownEvent) { Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast; TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed); Event.current.Use(); } if (KeyBindingDefOf.Dev_TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused) { tickManager.DoSingleTick(); SoundDefOf.Clock_Stop.PlayOneShotOnCamera(null); } } } }