Skip to content

Commit c1d046a

Browse files
committed
Rename MelvinTarget to MelvinTargetable to match other components
1 parent 953a6f9 commit c1d046a

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

src/CommunalHelperModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public override void Load()
115115
PoisonGas.Load();
116116
AffectSpriteTrigger.Load();
117117

118-
MelvinTarget.Load();
118+
MelvinTargetable.Load();
119119

120120
#region Imports
121121

@@ -209,7 +209,7 @@ public override void Unload()
209209
PoisonGas.Unload();
210210
AffectSpriteTrigger.Unload();
211211

212-
MelvinTarget.Unload();
212+
MelvinTargetable.Unload();
213213

214214
LaserEmitter.Unload();
215215
}
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
namespace Celeste.Mod.CommunalHelper.Components;
2-
3-
/// <summary>
4-
/// Component to mark entities which should be attacked by Melvins.
5-
/// </summary>
6-
[Tracked]
7-
public class MelvinTarget : Component
8-
{
9-
public MelvinTarget() : base(false, false)
10-
{
11-
}
12-
13-
#region Hooks
14-
15-
internal static void Load()
16-
{
17-
Everest.Events.Player.OnSpawn += OnSpawn;
18-
Everest.Events.AssetReload.OnBeforeReload += OnBeforeReload;
19-
}
20-
21-
internal static void Unload()
22-
{
23-
Everest.Events.Player.OnSpawn -= OnSpawn;
24-
Everest.Events.AssetReload.OnBeforeReload -= OnBeforeReload;
25-
}
26-
27-
private static void OnSpawn(Player player)
28-
{
29-
if (player.Get<MelvinTarget>() is null)
30-
player.Add(new MelvinTarget());
31-
}
32-
33-
private static void OnBeforeReload(bool silent)
34-
{
35-
// Remove component before reload so the player doesn't end up with more than 1
36-
if (Engine.Scene?.Tracker?.GetEntity<Player>() is Player player)
37-
player.Remove(player.Get<MelvinTarget>());
38-
}
39-
40-
#endregion
41-
}
1+
namespace Celeste.Mod.CommunalHelper.Components;
2+
3+
/// <summary>
4+
/// Component to mark entities which should be attacked by Melvins.
5+
/// </summary>
6+
[Tracked]
7+
public class MelvinTargetable : Component
8+
{
9+
public MelvinTargetable() : base(false, false)
10+
{
11+
}
12+
13+
#region Hooks
14+
15+
internal static void Load()
16+
{
17+
Everest.Events.Player.OnSpawn += OnSpawn;
18+
Everest.Events.AssetReload.OnBeforeReload += OnBeforeReload;
19+
}
20+
21+
internal static void Unload()
22+
{
23+
Everest.Events.Player.OnSpawn -= OnSpawn;
24+
Everest.Events.AssetReload.OnBeforeReload -= OnBeforeReload;
25+
}
26+
27+
private static void OnSpawn(Player player)
28+
{
29+
if (player.Get<MelvinTargetable>() is null)
30+
player.Add(new MelvinTargetable());
31+
}
32+
33+
private static void OnBeforeReload(bool silent)
34+
{
35+
// Remove component before reload so the player doesn't end up with more than 1
36+
if (Engine.Scene?.Tracker?.GetEntity<Player>() is Player player)
37+
player.Remove(player.Get<MelvinTargetable>());
38+
}
39+
40+
#endregion
41+
}

src/Entities/Misc/Melvin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ private bool IsPlayerSeen(Rectangle rect, ArrowDir dir)
859859

860860
private IEnumerable<Entity> GetTargetsByDistance()
861861
{
862-
List<Component> targets = SceneAs<Level>().Tracker.GetComponents<MelvinTarget>();
862+
List<Component> targets = SceneAs<Level>().Tracker.GetComponents<MelvinTargetable>();
863863
targets.Sort((target1, target2) => Vector2.DistanceSquared(Center, target1.Entity.Position).CompareTo(Vector2.DistanceSquared(Center, target2.Entity.Position)));
864864
return targets.Select(t => t.Entity);
865865
}

src/Exports.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public static class Entities
6363

6464
#region Melvin
6565

66-
public static Component MelvinTarget()
66+
public static Component MelvinTargetable()
6767
{
68-
return new MelvinTarget();
68+
return new MelvinTargetable();
6969
}
7070

7171
#endregion

0 commit comments

Comments
 (0)