-
Notifications
You must be signed in to change notification settings - Fork 92
[Port] Respawn Button / Кнопка Респавна #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e608d63
add: respawn button
Spatison ec107d5
fix: Loc
Spatison fbbb092
fix
Spatison 5734b49
fix
Spatison 1f84c4b
fix
Spatison 67c6eb6
fix
Spatison 315ba53
Merge branch 'master' into ghost-respawn
Spatison 980e442
Update CVars.cs
Spatison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
108 changes: 108 additions & 0 deletions
108
Content.Server/_White/Ghost/GhostReturnToRoundSystem.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| using Content.Server.Administration.Logs; | ||
| using Content.Server.Chat.Managers; | ||
| using Content.Server.GameTicking; | ||
| using Content.Shared._White; | ||
| using Content.Shared.Database; | ||
| using Content.Shared.GameTicking; | ||
| using Content.Shared.Ghost; | ||
| using Robust.Server.Player; | ||
| using Robust.Shared.Configuration; | ||
| using Robust.Shared.Network; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Server._White.Ghost; | ||
|
|
||
| public sealed class GhostReturnToRoundSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly IChatManager _chatManager = default!; | ||
| [Dependency] private readonly IAdminLogManager _adminLogger = default!; | ||
| [Dependency] private readonly IPlayerManager _playerManager = default!; | ||
| [Dependency] private readonly IGameTiming _gameTiming = default!; | ||
|
|
||
| public readonly Dictionary<NetUserId, TimeSpan> DeathTime = new(); | ||
|
|
||
Spatison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public override void Initialize() | ||
| { | ||
| SubscribeNetworkEvent<GhostReturnToRoundRequest>(OnGhostReturnToRoundRequest); | ||
| SubscribeLocalEvent<RoundRestartCleanupEvent>(ResetDeathTimes); | ||
| } | ||
|
|
||
| private void OnGhostReturnToRoundRequest(GhostReturnToRoundRequest msg, EntitySessionEventArgs args) | ||
| { | ||
| var cfg = IoCManager.Resolve<IConfigurationManager>(); | ||
Spatison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var maxPlayers = cfg.GetCVar(WhiteCVars.GhostRespawnMaxPlayers); | ||
| var connectedClient = args.SenderSession.ConnectedClient; | ||
| if (_playerManager.PlayerCount >= maxPlayers) | ||
| { | ||
| var message = Loc.GetString("ghost-respawn-max-players", ("players", maxPlayers)); | ||
| var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
| _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, | ||
| message, | ||
| wrappedMessage, | ||
| default, | ||
| false, | ||
| connectedClient, | ||
| Color.Red); | ||
| return; | ||
| } | ||
|
|
||
| var userId = args.SenderSession.UserId; | ||
| if (!DeathTime.TryGetValue(userId, out var deathTime)) | ||
| { | ||
| var message = Loc.GetString("ghost-respawn-bug"); | ||
| var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
| _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, | ||
| message, | ||
| wrappedMessage, | ||
| default, | ||
| false, | ||
| connectedClient, | ||
| Color.Red); | ||
| DeathTime[userId] = _gameTiming.CurTime; | ||
| return; | ||
| } | ||
|
|
||
| var timeUntilRespawn = (double) cfg.GetCVar(WhiteCVars.GhostRespawnTime); | ||
Spatison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var timePast = (_gameTiming.CurTime - deathTime).TotalMinutes; | ||
| if (timePast >= timeUntilRespawn) | ||
| { | ||
| var ticker = Get<GameTicker>(); | ||
| var playerMgr = IoCManager.Resolve<IPlayerManager>(); | ||
Spatison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| playerMgr.TryGetSessionById(userId, out var targetPlayer); | ||
|
|
||
| if (targetPlayer != null) | ||
| ticker.Respawn(targetPlayer); | ||
| DeathTime.Remove(userId); | ||
|
|
||
| _adminLogger.Add(LogType.Mind, LogImpact.Medium, $"{Loc.GetString("ghost-respawn-log-return-to-lobby", ("userName", connectedClient.UserName))}"); | ||
|
|
||
| var message = Loc.GetString("ghost-respawn-window-rules-footer"); | ||
| var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
| _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, | ||
| message, | ||
| wrappedMessage, | ||
| default, | ||
| false, | ||
| connectedClient, | ||
| Color.Red); | ||
|
|
||
| } | ||
| else | ||
| { | ||
Spatison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var message = Loc.GetString("ghost-respawn-time-left", ("time", (int) (timeUntilRespawn - timePast))); | ||
| var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
| _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, | ||
| message, | ||
| wrappedMessage, | ||
| default, | ||
| false, | ||
| connectedClient, | ||
| Color.Red); | ||
| } | ||
| } | ||
|
|
||
| private void ResetDeathTimes(RoundRestartCleanupEvent ev) | ||
| { | ||
| DeathTime.Clear(); | ||
| } | ||
| } | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ghost-gui-return-to-round-button = Return to round |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ghost-respawn-time-left = Before the opportunity to return to the round { $time } | ||
| { $time -> | ||
| [one] minute | ||
| *[other] minutes | ||
| } | ||
| ghost-respawn-max-players = The function is not available, there should be fewer players on the server { $players }. | ||
| ghost-respawn-window-title = Rules for returning to the round | ||
| ghost-respawn-window-rules-footer = By using this feature, you [color=#ff7700]agree[/color] [color=#ff0000]not to transfer[/color] the knowledge of your past character to a new one. For violation of the clause specified here, [color=#ff0000]a ban in the amount of 3 days or more follows[/color]. | ||
| ghost-respawn-bug = There is no time of death. The standard value is set. | ||
| ghost-respawn-same-character = You cannot enter the round for the same character. Change it in the character settings. | ||
|
|
||
| ghost-respawn-log-character-almost-same = Player { $player } { $try -> | ||
| [true] join | ||
| *[false] tried to join | ||
| } in the round after the respawn with a similar name. Past name: { $oldName }, current: { $newName }. | ||
| ghost-respawn-log-return-to-lobby = { $userName } returned to the lobby. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ghost-gui-return-to-round-button = Вернуться в раунд |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ghost-respawn-time-left = До возможности вернуться в раунд { $time } | ||
| { $time -> | ||
| [one] минута | ||
| [few] минуты | ||
| *[other] минут | ||
| } | ||
| ghost-respawn-max-players = Функция недоступна, игроков на сервере должно быть меньше { $players }. | ||
| ghost-respawn-window-title = Правила возвращения в раунд | ||
| ghost-respawn-window-rules-footer = Пользуясь это функцией, вы [color=#ff7700]обязуетесь[/color] [color=#ff0000]не переносить[/color] знания своего прошлого персонажа в нового. За нарушение пункта, указанного здесь, следует [color=#ff0000]бан в размере от 3-ех дней[/color]. | ||
| ghost-respawn-bug = Нет времени смерти. Установлено стандартное значение. | ||
| ghost-respawn-same-character = Нельзя заходить в раунд за того же персонажа. Поменяйте его в настройках персонажей. | ||
|
|
||
| ghost-respawn-log-character-almost-same = Игрок { $player } { $try -> | ||
| [true] зашёл | ||
| *[false] попытался зайти | ||
| } в раунд после возвращения в лобби с похожим именем. Прошлое имя: { $oldName }, текущее: { $newName }. | ||
| ghost-respawn-log-return-to-lobby = { $userName } вернулся в лобби. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.