[ARCH] Introduce ZoneManager with OnZoneChanged event #41

Merged
lavarius merged 1 commit from fix/16-zone-manager into master 2026-03-29 18:15:43 +00:00
Collaborator

Closes #16

What changed

Replaces the implicit SendMessage("SetZone", zone) scatter pattern with a single, explicit C# event in a new ZoneManager static class.

ZoneManager.cs (new)

public static event Action<ZoneInfluenced.zoneTypes> OnZoneChanged;
public static void NotifyZoneChanged(ZoneInfluenced.zoneTypes zone) => OnZoneChanged?.Invoke(zone);

ZoneInfluenced.cs

Added OnEnable/OnDisable to subscribe/unsubscribe every subclass automatically:

protected virtual void OnEnable()  => ZoneManager.OnZoneChanged += SetZone;
protected virtual void OnDisable() => ZoneManager.OnZoneChanged -= SetZone;

MovementManager and AnimationController inherit this for free — no changes needed in those files.

CharacterZoneChanger.cs

// before
other.SendMessage("SetZone", zone);
// after
ZoneManager.NotifyZoneChanged(zone);

Why

  • Eliminates tight implicit coupling via SendMessage
  • Single source of truth for zone-change broadcasting
  • Clean subscribe/unsubscribe lifecycle prevents stale listeners
Closes #16 ## What changed Replaces the implicit `SendMessage("SetZone", zone)` scatter pattern with a single, explicit C# event in a new `ZoneManager` static class. ### `ZoneManager.cs` (new) ```csharp public static event Action<ZoneInfluenced.zoneTypes> OnZoneChanged; public static void NotifyZoneChanged(ZoneInfluenced.zoneTypes zone) => OnZoneChanged?.Invoke(zone); ``` ### `ZoneInfluenced.cs` Added `OnEnable`/`OnDisable` to subscribe/unsubscribe every subclass automatically: ```csharp protected virtual void OnEnable() => ZoneManager.OnZoneChanged += SetZone; protected virtual void OnDisable() => ZoneManager.OnZoneChanged -= SetZone; ``` `MovementManager` and `AnimationController` inherit this for free — no changes needed in those files. ### `CharacterZoneChanger.cs` ```csharp // before other.SendMessage("SetZone", zone); // after ZoneManager.NotifyZoneChanged(zone); ``` ## Why - Eliminates tight implicit coupling via `SendMessage` - Single source of truth for zone-change broadcasting - Clean subscribe/unsubscribe lifecycle prevents stale listeners
feat: introduce ZoneManager with OnZoneChanged event (#16)
All checks were successful
Tests / Run EditMode Tests (pull_request) Successful in 14m20s
9239f5d357
Replace scattered SendMessage zone dispatch with a central ZoneManager
static event. All ZoneInfluenced subclasses (MovementManager,
AnimationController) subscribe/unsubscribe via OnEnable/OnDisable
inherited from ZoneInfluenced, eliminating the implicit SendMessage
coupling in CharacterZoneChanger.

- Add ZoneManager.cs with static OnZoneChanged event and NotifyZoneChanged()
- ZoneInfluenced.OnEnable/OnDisable wires every subclass to the event
- CharacterZoneChanger: replace SendMessage with ZoneManager.NotifyZoneChanged()

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lavarius approved these changes 2026-03-29 18:15:38 +00:00
lavarius merged commit ecbd37d1da into master 2026-03-29 18:15:43 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lavarius/ProjectOverlay!41
No description provided.