Skip to content

Commit

Permalink
Merge pull request #409 from coloursofnoise/patch-basebase
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ade authored Jan 23, 2022
2 parents 251cf56 + b1eab71 commit 27da129
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 33 deletions.
21 changes: 10 additions & 11 deletions Celeste.Mod.mm/Patches/BounceBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@
using MonoMod;

namespace Celeste {
// : Solid because base.Added
class patch_BounceBlock : Solid {
class patch_BounceBlock : BounceBlock {

// We're effectively in BounceBlock, but still need to "expose" private fields to our mod.
private bool iceMode;
private bool iceModeNext;

private bool notCoreMode;

public patch_BounceBlock(EntityData data, Vector2 offset)
: base(data.Position + offset, data.Width, data.Height, false) {
// no-op. MonoMod ignores this - we only need this to make the compiler shut up.
}
[MonoModIgnore]
public extern patch_BounceBlock(Vector2 position, float width, float height);

public extern void orig_ctor(EntityData data, Vector2 offset);
[MonoModConstructor]
public void ctor(EntityData data, Vector2 offset) {
orig_ctor(data, offset);

[MonoModReplace]
public patch_BounceBlock(EntityData data, Vector2 offset)
: this(data.Position + offset, data.Width, data.Height) {
notCoreMode = data.Bool("notCoreMode");
}

[MonoModLinkTo("Monocle.Entity", "Added")]
[MonoModIgnore]
public extern void base_Added(Scene scene);
[MonoModReplace]
public override void Added(Scene scene) {
base.Added(scene);
base_Added(scene);
iceModeNext = iceMode = SceneAs<Level>().CoreMode == Session.CoreModes.Cold || notCoreMode;
ToggleSprite();
}
Expand Down
13 changes: 11 additions & 2 deletions Celeste.Mod.mm/Patches/Checkpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@

using Microsoft.Xna.Framework;
using Monocle;
using MonoMod;
using System;

namespace Celeste {
class patch_Checkpoint : Entity {
class patch_Checkpoint : Checkpoint {

private string bg;
private Image image;
private Sprite sprite;
private Sprite flash;

public patch_Checkpoint(Vector2 position, string bg = "", Vector2? spawnTarget = null)
: base(position, bg, spawnTarget) {
//no-op
}

[MonoModLinkTo("Monocle.Entity", "Awake")]
[MonoModIgnore]
public extern void base_Awake(Scene scene);
public override void Awake(Scene scene) {
base.Awake(scene);
base_Awake(scene);

Level level = scene as Level;
if (level == null || level.Session.Area.GetLevelSet() == "Celeste")
Expand Down
1 change: 1 addition & 0 deletions Celeste.Mod.mm/Patches/InputMappingInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MonoMod;

namespace Celeste {
// Extend patch_Item so we can override AlwaysRender properly
class patch_InputMappingInfo : patch_TextMenu.patch_Item {
// we want it to always render, as it overlays on top of the menu when scrolling down (so it never goes off-screen).
public override bool AlwaysRender => true;
Expand Down
15 changes: 6 additions & 9 deletions Celeste.Mod.mm/Patches/IntroCrusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,18 @@
using System.Linq;

namespace Celeste {
// : Solid because base.Added
class patch_IntroCrusher : Solid {
class patch_IntroCrusher : IntroCrusher {

// We're effectively in IntroCrusher, but still need to "expose" private fields to our mod.
private Vector2 end;
private TileGrid tilegrid;

public string levelFlags;

public patch_IntroCrusher(Vector2 position, int width, int height, Vector2 node)
: base(position, width, height, true) {
// no-op. MonoMod ignores this - we only need this to make the compiler shut up.
}

[MonoModConstructor]
[MonoModReplace]
public patch_IntroCrusher(EntityData data, Vector2 offset)
: this(data.Position + offset, data.Width, data.Height, data.Nodes[0] + offset) {
: base(data.Position + offset, data.Width, data.Height, data.Nodes[0] + offset) {

levelFlags = data.Attr("flags");

Expand All @@ -38,6 +32,9 @@ public patch_IntroCrusher(EntityData data, Vector2 offset)
}
}

[MonoModLinkTo("Monocle.Entity", "Added")]
[MonoModIgnore]
public extern void base_Added(Scene scene);
public extern void orig_Added(Scene scene);
public override void Added(Scene scene) {
Level level = scene as Level;
Expand All @@ -46,7 +43,7 @@ public override void Added(Scene scene) {
return;
}

base.Added(scene);
base_Added(scene);

if (levelFlags.Split(',').Any(flag => level.Session.GetLevelFlag(flag))) {
Position = end;
Expand Down
1 change: 1 addition & 0 deletions Celeste.Mod.mm/Patches/LevelEnter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Collections;

namespace Celeste {
// LevelEnter has a private .ctor
class patch_LevelEnter : Scene {

/// <summary>
Expand Down
16 changes: 9 additions & 7 deletions Celeste.Mod.mm/Patches/RotateSpinner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
using Microsoft.Xna.Framework;
using Monocle;
using MonoMod;
using System;

namespace Celeste {
// : Entity because there's no original Awake method to hook, thus base.Awake must be Entity::Awake.
class patch_RotateSpinner : Entity {
class patch_RotateSpinner : RotateSpinner {

public float Angle =>
fixAngle ?
MathHelper.Lerp(MathHelper.Pi, -MathHelper.Pi, Easer(rotationPercent)) :
MathHelper.Lerp(4.712389f, -1.57079637f, Easer(rotationPercent));
public new float Angle {
[MonoModReplace]
get => fixAngle ?
MathHelper.Lerp(MathHelper.Pi, -MathHelper.Pi, Easer(rotationPercent)) :
MathHelper.Lerp(MathHelper.Pi + MathHelper.Pi / 2, -MathHelper.Pi / 2, Easer(rotationPercent));
}

private bool fixAngle;

Expand All @@ -24,7 +26,7 @@ class patch_RotateSpinner : Entity {
private Vector2 startPosition;

public patch_RotateSpinner(EntityData data, Vector2 offset)
: base(data.Position + offset) {
: base(data, offset) {
// no-op. MonoMod ignores this - we only need this to make the compiler shut up.
}

Expand Down
13 changes: 9 additions & 4 deletions Celeste.Mod.mm/Patches/StarJumpBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
using System.Collections.Generic;

namespace Celeste {
// : Solid because base.Awake
class patch_StarJumpBlock : Solid {
class patch_StarJumpBlock : StarJumpBlock {
private Level level;

public patch_StarJumpBlock(Vector2 position, float width, float height, bool sinks) : base(position, width, height, sinks) {
// no-op. MonoMod ignores this - we only need this to make the compiler shut up.
}

[MonoModLinkTo("Celeste.Solid", "Awake")]
[MonoModIgnore]
public extern void base_Awake(Scene scene);
public extern void orig_Awake(Scene scene);
public override void Awake(Scene scene) {
if ((scene as Level).Session.Area.GetLevelSet() == "Celeste") {
Expand All @@ -27,7 +29,7 @@ public override void Awake(Scene scene) {

// TODO: Inner corner textures? Or keep them empty as-is?

base.Awake(scene);
base_Awake(scene);

level = SceneAs<Level>();

Expand Down Expand Up @@ -177,6 +179,9 @@ public override void Awake(Scene scene) {
}
}

[MonoModLinkTo("Monocle.Entity", "Render")]
[MonoModIgnore]
public extern void base_Render();
public extern void orig_Render();
public override void Render() {
if (SceneAs<Level>().Session.Area.GetLevelSet() == "Celeste") {
Expand Down Expand Up @@ -208,7 +213,7 @@ public override void Render() {
);
}

base.Render();
base_Render();
}

[MonoModIgnore]
Expand Down

0 comments on commit 27da129

Please sign in to comment.