Skip to content

Saving player postion on quit#114

Merged
ktos merged 5 commits into
mainfrom
PlayerPostionOnQuit
Jun 4, 2026
Merged

Saving player postion on quit#114
ktos merged 5 commits into
mainfrom
PlayerPostionOnQuit

Conversation

@KacperZ402

Copy link
Copy Markdown
Collaborator

When player click on logout or shut down browser, his last location will be saved to DB, in addition each player's position saves every two minutes (this is protection against server shutdown). There is condition checking if player's position is on walkable node. (when map has changed, player won't be spawned on NonWalkable node)


public int CurrentX { get; private set; }
public int CurrentY { get; private set; }
public int CurrentX { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to stay private

}

private void Logout()
private async Task LoadPlayerPositionAsync()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to MovementService

if (UserService.User != null && MovementService.CurrentMap != null)
{
var position = $"{MovementService.CurrentX},{MovementService.CurrentY}";
await UserService.UpdatePlayerPositionAsync(UserService.User.Id, position);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather not directly, use method from MovementService

@ktos ktos merged commit f495a39 into main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants