public void SetManagerTempo(float Tempo) { // let me speak to your manager... to change the tempo CassetteBlockManager manager = Scene.Tracker.GetEntity <CassetteBlockManager>(); if (manager != null) { DynData <CassetteBlockManager> data = new DynData <CassetteBlockManager>(manager); data.Set("tempoMult", Tempo); } }
private int modGameSpeed(int gameSpeed) { if (previousGameSpeed > Settings.GameSpeed) { Logger.Log("ExtendedVariantMode/GameSpeed", "Game speed slowed down, ensuring cassette blocks and sprites are sane..."); if (Engine.Scene is Level level) { // go across all entities in the screen foreach (Entity entity in level.Entities) { // ... and all sprites in them foreach (Sprite sprite in entity.Components.GetAll <Sprite>()) { if (sprite.Animating) { // if the current animation is waaaay over, bring it to a more sane value. DynData <Sprite> data = new DynData <Sprite>(sprite); if (Math.Abs(data.Get <float>("animationTimer")) >= data.Get <Sprite.Animation>("currentAnimation").Delay * 2) { data["animationTimer"] = data.Get <Sprite.Animation>("currentAnimation").Delay; Logger.Log(LogLevel.Info, "ExtendedVariantMode/GameSpeed", $"Sanified animation for {sprite.Texture?.AtlasPath}"); } } } } CassetteBlockManager manager = level.Tracker.GetEntity <CassetteBlockManager>(); if (manager != null) { // check if the beatTimer of the cassette block manager went overboard or not. DynData <CassetteBlockManager> data = new DynData <CassetteBlockManager>(manager); if (data.Get <float>("beatTimer") > 0.166666672f * 2) { // this is madness! data["beatTimer"] = 0.166666672f; Logger.Log(LogLevel.Info, "ExtendedVariantMode/GameSpeed", "Sanified cassette block beat timer"); } } } } previousGameSpeed = Settings.GameSpeed; return(gameSpeed * Settings.GameSpeed / 10); }
// public for TAS Mod // ReSharper disable once MemberCanBePrivate.Global UnusedMethodReturnValue.Global public bool SaveState() { if (!(Engine.Scene is Level level)) { return(false); } if (!IsAllowSave(level, level.GetPlayer())) { return(false); } ClearState(false); savedLevel = level.ShallowClone(); savedLevel.Session = level.Session.DeepClone(); savedLevel.Camera = level.Camera.DeepClone(); savedEntities = DeepCloneEntities(GetEntitiesExcludingGlobal(level)); savedCassetteBlockManager = level.Entities.FindFirst <CassetteBlockManager>()?.ShallowClone(); // External savedFreezeTimer = Engine.FreezeTimer; savedTimeRate = Engine.TimeRate; savedGlitchValue = Glitch.Value; savedDistortAnxiety = Distort.Anxiety; savedDistortGameRate = Distort.GameRate; // Mod SaveLoadAction.OnSaveState(level); // save all mod sessions savedModSessions = new Dictionary <EverestModule, EverestModuleSession>(); foreach (EverestModule module in Everest.Modules) { if (module._Session != null) { savedModSessions[module] = module._Session.DeepCloneYaml(module.SessionType); } } return(LoadState()); }
private void ClearState(bool clearEndPoint = true) { if (Engine.Scene is Level level && IsNotCollectingHeart(level)) { level.Frozen = false; level.PauseLock = false; } try { RoomTimerManager.Instance.ClearPbTimes(clearEndPoint); } catch (NullReferenceException) { } savedModSessions = null; savedLevel = null; savedEntities = null; savedCassetteBlockManager = null; // Mod SaveLoadAction.OnClearState(); state = States.None; }
private IEnumerator CollectRoutine(Player player) { collecting = true; Level level = Scene as Level; CassetteBlockManager cbm = Scene.Tracker.GetEntity <CassetteBlockManager>(); level.PauseLock = true; level.Frozen = true; Tag = Tags.FrozenUpdate; // TODO: attribute for setting this? level.Session.Cassette = true; level.Session.RespawnPoint = level.GetSpawnPoint(nodes[1]); level.Session.UpdateLevelStartDashes(); if (!string.IsNullOrEmpty(altSideToUnlock)) { AltSidesHelperModule.AltSidesSaveData.UnlockedAltSideIDs.Add(altSideToUnlock); } cbm?.StopBlocks(); Depth = -1000000; level.Shake(); level.Flash(Color.White); level.Displacement.Clear(); Vector2 camWas = level.Camera.Position; Vector2 camTo = (Position - new Vector2(160f, 90f)).Clamp(level.Bounds.Left - 64, level.Bounds.Top - 32, level.Bounds.Right + 64 - 320, level.Bounds.Bottom + 32 - 180); level.Camera.Position = camTo; level.ZoomSnap((Position - level.Camera.Position).Clamp(60f, 60f, 260f, 120f), 2f); sprite.Play("spin", restart: true); sprite.Rate = 2f; for (float p3 = 0f; p3 < 1.5f; p3 += Engine.DeltaTime) { sprite.Rate += Engine.DeltaTime * 4f; yield return(null); } sprite.Rate = 0f; sprite.SetAnimationFrame(0); scaleWiggler.Start(); yield return(0.25f); Vector2 from = Position; Vector2 to = new Vector2(X, level.Camera.Top - 16f); float duration2 = 0.4f; for (float p3 = 0f; p3 < 1f; p3 += Engine.DeltaTime / duration2) { sprite.Scale.X = MathHelper.Lerp(1f, 0.1f, p3); sprite.Scale.Y = MathHelper.Lerp(1f, 3f, p3); Position = Vector2.Lerp(from, to, Ease.CubeIn(p3)); yield return(null); } Visible = false; remixSfx = Audio.Play("event:/game/general/cassette_preview", "remix", level.Session.Area.ID); UnlockedAltSideCutscene message = new UnlockedAltSideCutscene(unlockText, menuSprite); Scene.Add(message); yield return(message.EaseIn()); while (message.textIndex < message.text.Length) { while (!Input.MenuConfirm.Pressed) { yield return(null); } if (message.textIndex != message.text.Length - 1) { yield return(message.NextText()); } else { break; } } Audio.SetParameter(remixSfx, "end", 1f); yield return(message.EaseOut()); duration2 = 0.25f; Add(new Coroutine(level.ZoomBack(duration2 - 0.05f))); for (float p3 = 0f; p3 < 1f; p3 += Engine.DeltaTime / duration2) { level.Camera.Position = Vector2.Lerp(camTo, camWas, Ease.SineInOut(p3)); yield return(null); } if (!player.Dead && nodes != null && nodes.Length >= 2) { Audio.Play("event:/game/general/cassette_bubblereturn", level.Camera.Position + new Vector2(160f, 90f)); player.StartCassetteFly(nodes[1], nodes[0]); } foreach (SandwichLava item in level.Entities.FindAll <SandwichLava>()) { item.Leave(); } level.Frozen = false; yield return(0.25f); cbm?.Finish(); level.PauseLock = false; level.ResetZoom(); RemoveSelf(); }