Extract the map transitions of the player and its spawn gate selection - #884
Open
sven-n wants to merge 1 commit into
Open
Extract the map transitions of the player and its spawn gate selection#884sven-n wants to merge 1 commit into
sven-n wants to merge 1 commit into
Conversation
Moves teleport, warp, respawn and the client handshake after a map change into a PlayerMapTransitions component. The spawn gate is now determined by the new IPlayerSpawnGateSelectionPlugIn point, so the player doesn't know about duels and guild war soccer matches anymore: both are plugins now, and mini games or castle siege can add their own without touching the player. Fixes a null reference which could happen when a player arrived at a blocked position and had a summon: the warp to the safezone sets the current map to null, and the summon was added to it afterwards. The summon is added by the map change which the warp starts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5grV5oveZNhhjK1mazM2B
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 of the
Playerrefactoring (docs/PlayerRefactoringPlan.md).The player doesn't know about duels and soccer matches anymore
GetSpawnGateOfCurrentMapAsynchardcoded two game features: duel rooms and the guild war soccer ground. Both are now plugins of the newIPlayerSpawnGateSelectionPlugInpoint —DuelSpawnGatePlugInandSoccerSpawnGatePlugIn, both active by default. Mini games and castle siege can add their own spawn gate the same way, without touchingPlayer.The point passes a mutable
SpawnGateSelectionArgs, because plugin points can't return values. A plugin only fills the gate when no other plugin selected one, so the result doesn't depend on the (undefined) plugin order. When nothing selects a gate, the safezone gate of the current map is used, exactly as before.The component
PlayerMapTransitionstakes overTeleportAsync,TeleportToMapAsync,WarpToAsync,WarpToSafezoneAsync,RespawnAtAsync,ClientReadyAfterMapChangeAsyncand the helpers around them. The public members ofPlayerdelegate, so no call site changes.Playergained threeinternalmembers for it —SetCurrentMapSilently,ClearRespawnAfterDeathTokenandClearObservingObjectsListAsync— and the setters ofCurrentMapandIsTeleportingbecameinternalinstead ofprivate. The death handling itself (and its cancellation token) stays inPlayeruntil phase 5.Bug fix
The null reference I flagged in #872 is fixed here, since this phase restructures the method: in
ClientReadyAfterMapChangeAsync, a player arriving at a blocked position is warped to the safezone, which setsCurrentMapto null — and the summon was then added to that null map. It only hit players who had a summon. The warp starts its own map change, which adds the summon when it completes, so the method now returns after the warp.Player.cs: 2,058 → 1,828 lines (3,098 before this refactoring started).
Tests
New
SpawnGateSelectionTestswith four cases: a plugin defines the spawn gate, the first selected gate wins over a second plugin, the map's safezone gate is used when no plugin selects one, and a player arriving at a blocked position ends up at its spawn gate. The last one creates a summon and fails with the null reference described above when the fix is reverted — I checked.PlayerTestHelpernow sets up the exit gates of its map mock, which the third case needs.Full suite: 720 of 720 pass, solution builds with no errors.
Generated by Claude Code