-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix crashes, add type-safe methods for Player/Seeker/Oshiro states
- Loading branch information
Showing
4 changed files
with
157 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.Xna.Framework; | ||
using Monocle; | ||
using System; | ||
using System.Collections; | ||
|
||
namespace Celeste.Patches { | ||
public class patch_AngryOshiro : AngryOshiro { | ||
|
||
// We're effectively in AngryOshiro, but still need to "expose" private fields to our mod. | ||
private StateMachine state; | ||
|
||
public patch_AngryOshiro(EntityData data, Vector2 offset) | ||
: base(data, offset) { | ||
// no-op. MonoMod ignores this - we only need this to make the compiler shut up. | ||
} | ||
|
||
/// <summary> | ||
/// Adds a new state to this oshiro with the given behaviour, and returns the index of the new state. | ||
/// | ||
/// States should always be added at the end of the <c>AngryOshiro(Vector2, bool)</c> constructor. | ||
/// </summary> | ||
/// <param name="name">The name of this state, for display purposes by mods only.</param> | ||
/// <param name="onUpdate">A function to run every frame during this state, returning the index of the state that should be switched to next frame.</param> | ||
/// <param name="coroutine">A function that creates a coroutine to run when this state is switched to.</param> | ||
/// <param name="begin">An action to run when this state is switched to.</param> | ||
/// <param name="end">An action to run when this state ends.</param> | ||
/// <returns>The index of the new state.</returns> | ||
public int AddState(string name, Func<AngryOshiro, int> onUpdate, Func<AngryOshiro, IEnumerator> coroutine = null, Action<AngryOshiro> begin = null, Action<AngryOshiro> end = null){ | ||
return ((patch_StateMachine)state).AddState(name, onUpdate, coroutine, begin, end); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.Xna.Framework; | ||
using Monocle; | ||
using System; | ||
using System.Collections; | ||
|
||
namespace Celeste.Patches { | ||
public class patch_Seeker : Seeker { | ||
|
||
// We're effectively in Seeker, but still need to "expose" private fields to our mod. | ||
private StateMachine State; | ||
|
||
// no-op - only here to make | ||
public patch_Seeker(EntityData data, Vector2 offset) | ||
: base(data, offset) { | ||
// no-op. MonoMod ignores this - we only need this to make the compiler shut up. | ||
} | ||
|
||
/// <summary> | ||
/// Adds a new state to this seeker with the given behaviour, and returns the index of the new state. | ||
/// | ||
/// States should always be added at the end of the <c>Seeker(Vector2, Vector2[])</c> constructor. | ||
/// </summary> | ||
/// <param name="name">The name of this state, for display purposes by mods only.</param> | ||
/// <param name="onUpdate">A function to run every frame during this state, returning the index of the state that should be switched to next frame.</param> | ||
/// <param name="coroutine">A function that creates a coroutine to run when this state is switched to.</param> | ||
/// <param name="begin">An action to run when this state is switched to.</param> | ||
/// <param name="end">An action to run when this state ends.</param> | ||
/// <returns>The index of the new state.</returns> | ||
public int AddState(string name, Func<Seeker, int> onUpdate, Func<Seeker, IEnumerator> coroutine = null, Action<Seeker> begin = null, Action<Seeker> end = null){ | ||
return ((patch_StateMachine)State).AddState(name, onUpdate, coroutine, begin, end); | ||
} | ||
} | ||
} |