|
| 1 | +using Microsoft.Xna.Framework; |
| 2 | +using Monocle; |
| 3 | +using System.Linq; |
| 4 | + |
| 5 | +namespace Celeste.Mod.SpringCollab2020.Entities { |
| 6 | + /// <summary> |
| 7 | + /// This is a replica of the "water zipping fix" from Isa's Grab Bag. |
| 8 | + /// This has side effects so this is technically a bug, but these side effects are used in ProXas's entry |
| 9 | + /// to give insane amounts of speed to the player with small spots of water. |
| 10 | + /// So this should stay in the collab where needed, even if fixed on Isa's side. |
| 11 | + /// </summary> |
| 12 | + public class WaterRocketLaunchingComponent : Component { |
| 13 | + public static void Load() { |
| 14 | + On.Celeste.Player.Added += onPlayerAdded; |
| 15 | + } |
| 16 | + |
| 17 | + public static void Unload() { |
| 18 | + On.Celeste.Player.Added -= onPlayerAdded; |
| 19 | + } |
| 20 | + |
| 21 | + private static void onPlayerAdded(On.Celeste.Player.orig_Added orig, Player self, Scene scene) { |
| 22 | + orig(self, scene); |
| 23 | + |
| 24 | + string mapSID = self.SceneAs<Level>().Session.Area.GetSID(); |
| 25 | + if (!self.Components.Any(component => component.GetType().ToString() == "Celeste.Mod.IsaGrabBag.WaterFix") && |
| 26 | + (mapSID == "SpringCollab2020/2-Intermediate/ProXas" || mapSID == "SpringCollab2020/2-Intermediate/ZZ-HeartSide")) { |
| 27 | + |
| 28 | + // Isa's Grab Bag didn't add the "water fix" and the current map needs it, so add it ourselves. |
| 29 | + self.Add(new WaterRocketLaunchingComponent(true, false)); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + public WaterRocketLaunchingComponent(bool active, bool visible) : base(active, visible) { } |
| 34 | + |
| 35 | + private Player player; |
| 36 | + |
| 37 | + public override void Update() { |
| 38 | + player = Entity as Player; |
| 39 | + if (player == null || !player.Collidable) { |
| 40 | + return; |
| 41 | + } |
| 42 | + |
| 43 | + Vector2 posOffset = player.Position + player.Speed * Engine.DeltaTime * 2; |
| 44 | + |
| 45 | + bool isInWater = player.CollideCheck<Water>(posOffset) || player.CollideCheck<Water>(posOffset + Vector2.UnitY * -8f); |
| 46 | + |
| 47 | + if (!isInWater && player.StateMachine.State == 3 && (player.Speed.Y < 0 || Input.MoveY.Value == -1 || Input.Jump.Check)) { |
| 48 | + player.Speed.Y = (Input.MoveY.Value == -1 || Input.Jump.Check) ? -110 : 0; |
| 49 | + if (player.Speed.Y < -1) { |
| 50 | + player.Speed.X *= 1.1f; |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments