// Do a bounce check and bounce if possible public bool AttemptBounce(Player player) { if (BounceOnCollision) { Vector2 moveCheckVector = player.Speed * Engine.DeltaTime; player.NaiveMove(moveCheckVector); DreamBlock dreamBlock = player.CollideFirst <DreamBlock>(); if (dreamBlock == null) { bool inSolid = (bool)playerDreamDashedIntoSolid.Invoke(player, new Object[] { }); if (inSolid) { // Move the player out of the wall properly, then bounce player.NaiveMove(-moveCheckVector); BouncePlayer(player); return(true); } } // Make sure we undo the check movement player.NaiveMove(-moveCheckVector); } return(false); }
private static void DreamBlockRender(On.Celeste.DreamBlock.orig_Render orig, DreamBlock self) { if (!AdventureHelperModule.Settings.CombineDreamBlocks || AdventureHelperModule.Session.DreamBlocksNotToCombine.Contains(self)) { orig(self); } }
private static void DreamBlock_Added(On.Celeste.DreamBlock.orig_Added orig, DreamBlock self, Scene scene) { if (MadelinePartyModule.IsSIDMadelineParty((scene as Level).Session.Area.GetSID()) && (scene as Level).Session.LevelData.Entities.Any((data) => data.Name.Equals("madelineparty/dreamBlockRNGSyncer"))) { DynData <Scene> sceneData = new DynData <Scene>(); var seed = sceneData.Get <int?>("madelinePartyRandomSeed"); if (seed == null) { seed = Calc.Random.Next(); sceneData["madelinePartyRandomSeed"] = seed; } DynData <DreamBlock> selfData = new DynData <DreamBlock>(self); selfData["madelinePartyRandom"] = new Random(seed.Value); Random oldRand = Calc.Random; Calc.Random = selfData.Get <Random>("madelinePartyRandom"); orig(self, scene); Calc.Random = oldRand; } else { orig(self, scene); } }
private float DreamBlock_Lerp(On.Celeste.DreamBlock.orig_Lerp orig, DreamBlock self, float a, float b, float percent) { if (Settings.SimplifiedGraphics) { return(0f); } return(orig(self, a, b, percent)); }
private static void DreamBlock_Setup(On.Celeste.DreamBlock.orig_Setup orig, DreamBlock self) { if (self is DreamBlockDummy dummy && dummy.OnSetup != null) { dummy.OnSetup(); return; } orig(self); }
public Edge(DreamBlock parent, Vector2 a, Vector2 b) { Parent = parent; Visible = true; A = a; B = b; Min = new Vector2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); Max = new Vector2(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); }
private static void DreamBlock_Setup(On.Celeste.DreamBlock.orig_Setup orig, DreamBlock self) { DreamDashController controller = self.Scene.Tracker.GetEntity <DreamDashController>(); bool playerHasDreamdash = (bool)dreamBlockPlayerHasDreamDash.GetValue(self); orig(self); if (playerHasDreamdash) { controller?.changeDreamBlockParticleColors(self); } }
private static void DreamBlockAdded(On.Celeste.DreamBlock.orig_Added orig, DreamBlock self, Monocle.Scene scene) { orig(self, scene); if (AdventureHelperModule.Settings.CombineDreamBlocks && !AdventureHelperModule.Session.DreamBlocksNotToCombine.Contains(self)) { AdventureHelperModule.Session.DreamBlocksToCombine.Add(self); DreamBlockCombiner combiner = self.Scene.Tracker.GetEntity <DreamBlockCombiner>(); if (combiner == null) { self.Scene.Add(combiner = new DreamBlockCombiner()); } } }
private void changeDreamBlockParticleColors(DreamBlock dreamBlock) { Array particles = dreamBlockParticles.GetValue(dreamBlock) as Array; if (particles != null) { for (int i = 0; i < particles.Length; i++) { var particle = particles.GetValue(i); int layer = (int)dreamBlockParticleLayer.GetValue(particle); Color color = Calc.Random.Choose(particleLayerColors[layer]); dreamBlockParticleColor.SetValue(particle, color); particles.SetValue(particle, i); } } }
private Vector2 PutInside(DreamBlock block, Vector2 pos) { while (pos.X < block.X) { pos.X += block.Width; } while (pos.X > block.X + block.Width) { pos.X -= block.Width; } while (pos.Y < block.Y) { pos.Y += block.Height; } while (pos.Y > block.Y + block.Height) { pos.Y -= block.Height; } return(pos); }
public DreamParticle(DreamBlock block, int idx) : this() { dreamBlock = block; this.idx = idx; }
private static void DreamBlockConstructor(On.Celeste.DreamBlock.orig_ctor_EntityData_Vector2 orig, DreamBlock self, EntityData data, Vector2 offset) { orig(self, data, offset); if (data.Nodes.Length > 0) { AdventureHelperModule.Session.DreamBlocksNotToCombine.Add(self); } }
private static IEnumerator DreamBlock_FastActivate(On.Celeste.DreamBlock.orig_FastActivate orig, DreamBlock self) { if (self is DreamBlockDummy dummy && dummy.OnFastActivate != null) { dummy.Data["playerHasDreamDash"] = true; dummy.Entity.Add(new Coroutine(dummy.OnFastActivate())); return(null); } return(orig(self)); }
private static void DreamBlock_DeactivateNoRoutine(On.Celeste.DreamBlock.orig_DeactivateNoRoutine orig, DreamBlock self) { if (self is DreamBlockDummy dummy && dummy.OnDeactivateNoRoutine != null) { dummy.Data["playerHasDreamDash"] = false; dummy.OnDeactivateNoRoutine(); return; } orig(self); }
private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background) { CassetteBlock.Blocks.Clear(); using (Graphics g = Graphics.FromImage(map)) { List <Entity> ents = new List <Entity>(); for (int i = entities.Children.Count - 1; i >= 0; i--) { MapElement child = entities.Children[i]; Entity entity = null; if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Spikes.FromElement(child) : null; } else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? TriggerSpikes.FromElement(child) : null; } else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterCabinet.FromElement(child) : null; } else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase)) { entity = background ? IntroCar.FromElement(child) : null; } else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClothesLine.FromElement(child) : null; } else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? ColorSwitch.FromElement(child) : null; } else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bonfire.FromElement(child) : null; } else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrapDoor.FromElement(child) : null; } else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? MovingPlatform.FromElement(child) : null; } else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? SinkingPlatform.FromElement(child) : null; } else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterDoor.FromElement(child) : null; } else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bridge.FromElement(child) : null; } else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase)) { entity = background ? BridgeFixed.FromElement(child) : null; } else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase)) { entity = background ? JumpThru.FromElement(child) : null; } else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase)) { entity = background ? Door.FromElement(child) : null; } else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase)) { entity = background ? BlockField.FromElement(child) : null; } else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? Lamp.FromElement(child) : null; } else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase)) { entity = background ? Haha.FromElement(child) : null; } else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase)) { entity = background ? WaterFall.FromElement(child) : null; } else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase)) { entity = background ? Water.FromElement(child) : null; } else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase)) { entity = background ? Key.FromElement(child) : null; } else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase)) { entity = background ? ResortLantern.FromElement(child) : null; } else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bird.FromElement(child) : null; } else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase)) { entity = background ? Memorial.FromElement(child) : null; } else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase)) { entity = background ? PlayerSpawn.FromElement(child) : null; } else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase)) { entity = background ? ZipMover.FromElement(child) : null; } else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Wire.FromElement(child) : null; } else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CrumbleBlock.FromElement(child) : null; } else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase)) { entity = background ? Refill.FromElement(child) : null; } else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spring.FromElement(child) : null; } else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase)) { entity = background ? LightBeam.FromElement(child) : null; } else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cobweb.FromElement(child) : null; } else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cassette.FromElement(child) : null; } else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase)) { entity = background ? FlutterBird.FromElement(child) : null; } else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase)) { entity = background ? Checkpoint.FromElement(child) : null; } else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CassetteBlock.FromElement(child) : null; } else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DashBlock.FromElement(child) : null; } else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? CoverupWall.FromElement(child) : null; } else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase)) { entity = background ? NPC.FromElement(child) : null; } else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? ForsakenCityGem.FromElement(child) : null; } else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase)) { entity = background ? SoundSource.FromElement(child) : null; } else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase)) { entity = background ? FriendlyGhost.FromElement(child) : null; } else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase)) { entity = background ? FloatingDebris.FromElement(child) : null; } else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? HangingLamp.FromElement(child) : null; } else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? LockBlock.FromElement(child) : null; } else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamMirror.FromElement(child) : null; } else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase)) { entity = background ? DarkChaser.FromElement(child) : null; } else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamBlock.FromElement(child) : null; } else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? TouchSwitch.FromElement(child) : null; } else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase)) { entity = background ? SwitchGate.FromElement(child) : null; } else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase)) { entity = background ? InvisibleBarrier.FromElement(child) : null; } else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase)) { entity = background ? Payphone.FromElement(child) : null; } else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spinner.FromElement(child) : null; } else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? RotateSpinner.FromElement(child) : null; } else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrackSpinner.FromElement(child) : null; } else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase)) { entity = background ? TowerViewer.FromElement(child) : null; } else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase)) { entity = !background?ForegroundDebris.FromElement(child) : null; } else if (background) { Console.WriteLine(child.Name); } if (entity != null) { ents.Add(entity); } } ents.Sort(delegate(Entity one, Entity two) { int comp = two.Depth.CompareTo(one.Depth); return(comp == 0 ? one.ID.CompareTo(two.ID) : comp); }); for (int i = 0; i < ents.Count; i++) { Entity entity = ents[i]; entity.Render(g, solids); } } }
public void StickPlayer(Player player) { DreamBlock dreamBlock = player.CollideFirst <DreamBlock>(); if (dreamBlock == null) { return; } wallPlayerSpeed.AddOrUpdate(player, new ValueHolder <Vector2>(player.Speed)); Collider playerCollider = player.Collider; Collider dreamBlockCollider = dreamBlock.Collider; Vector2 horizontalMoveCheckVector = new Vector2(player.Speed.X * Engine.DeltaTime, 0f); Vector2 verticalMoveCheckVector = new Vector2(0f, player.Speed.Y * Engine.DeltaTime); bool horizontal = outsideAfterMove(player, horizontalMoveCheckVector); bool vertical = outsideAfterMove(player, verticalMoveCheckVector); player.StateMachine.State = Player.StNormal; player.Ducking = true; float moveOffsetX = 0f; float moveOffsetY = 0f; float renderOffsetX = 0f; float renderOffsetY = 0f; double rotation = 0.0; if (horizontal) { if (player.Speed.X < 0) { rotation = Math.PI / 2; moveOffsetX = dreamBlockCollider.AbsoluteLeft - player.X + playerCollider.Width / 2.0f; renderOffsetX = -playerCollider.Width / 2.0f; renderOffsetY = -playerCollider.Height / 2.0f; } else { rotation = Math.PI * 3 / 2; moveOffsetX = dreamBlockCollider.AbsoluteRight - player.X - playerCollider.Width / 2.0f; renderOffsetX = playerCollider.Width / 2.0f; renderOffsetY = -playerCollider.Height / 2.0f; } } if (vertical) { if (player.Speed.Y < 0) { rotation = Math.PI; moveOffsetY = dreamBlockCollider.AbsoluteTop - player.Y + playerCollider.Height - 1; renderOffsetY = -playerCollider.Height; } else { rotation = 0.0; moveOffsetY = dreamBlockCollider.AbsoluteBottom - player.Y + 1; } } wallPlayerRotations.AddOrUpdate(player, new ValueHolder <float>((float)rotation)); wallPlayerRenderOffset.AddOrUpdate(player, new ValueHolder <Vector2>(new Vector2(renderOffsetX, renderOffsetY))); player.NaiveMove(new Vector2(moveOffsetX, moveOffsetY)); }
private static void DreamBlock_Update(On.Celeste.DreamBlock.orig_Update orig, DreamBlock self) { Scene scene = self.Scene; if (MadelinePartyModule.IsSIDMadelineParty((scene as Level).Session.Area.GetSID()) && scene.Entities.FindFirst <DreamBlockRNGSyncer>() != null) { DynData <DreamBlock> selfData = new DynData <DreamBlock>(self); Random oldRand = Calc.Random; Calc.Random = selfData.Get <Random>("madelinePartyRandom"); orig(self); Calc.Random = oldRand; } else { orig(self); } }
private static bool DreamTunnelDashCheck(this Player player, Vector2 dir) { if (dreamTunnelDashAttacking && player.DashAttacking && (dir.X == Math.Sign(player.DashDir.X) || dir.Y == Math.Sign(player.DashDir.Y))) { Rectangle bounds = player.SceneAs <Level>().Bounds; if (player.Left + dir.X < bounds.Left || player.Right + dir.X > bounds.Right || player.Top + dir.Y < bounds.Top || player.Bottom + dir.Y > bounds.Bottom) { return(false); } Solid solid = null; // Check for dream blocks first, then for solids DreamBlock block = player.CollideFirst <DreamBlock>(player.Position + dir); if (block != null) { Vector2 side = new Vector2(Math.Abs(dir.Y), Math.Abs(dir.X)); bool dashedIntoDreamBlock = true; bool checkNegative = dir.X != 0f ? player.Speed.Y <= 0f : player.Speed.X <= 0f; bool checkPositive = dir.X != 0f ? player.Speed.Y >= 0f : player.Speed.X >= 0f; if (checkNegative) { for (int i = -1; i >= -Player_DashCornerCorrection; i--) { Vector2 at = player.Position + dir + side * i; if (!player.CollideCheck <DreamBlock>(at) && (solid = player.CollideFirst <Solid, DreamBlock>(at)) != null) { player.Position += side * i; dashedIntoDreamBlock = false; goto CheckDreamBlock; } } } if (checkPositive) { for (int i = 1; i <= Player_DashCornerCorrection; i++) { Vector2 at = player.Position + dir + side * i; if (!player.CollideCheck <DreamBlock>(at) && (solid = player.CollideFirst <Solid, DreamBlock>(at)) != null) { player.Position += side * i; dashedIntoDreamBlock = false; goto CheckDreamBlock; } } } CheckDreamBlock: if (dashedIntoDreamBlock) { if (new DynData <DreamBlock>(block).Get <bool>("playerHasDreamDash")) { player.Die(-dir); } dreamTunnelDashAttacking = false; overrideDreamDashCheck = true; return(false); } } solid ??= player.CollideFirst <Solid, DreamBlock>(player.Position + dir); if (solid != null) { DynData <Player> playerData = player.GetData(); player.StateMachine.State = StDreamTunnelDash; solid.Components.GetAll <DreamTunnelInteraction>().ToList().ForEach(i => i.OnPlayerEnter(player)); playerData[Player_solid] = solid; playerData["dashAttackTimer"] = 0; playerData["gliderBoostTimer"] = 0; return(true); } } return(false); }