-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] Respawn Button / Кнопка Респавна (#56)
* add: respawn button * fix: Loc * fix * fix * fix * fix * Update CVars.cs
- Loading branch information
Showing
14 changed files
with
226 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,81 @@ | ||
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!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeNetworkEvent<GhostReturnToRoundRequest>(OnGhostReturnToRoundRequest); | ||
} | ||
|
||
private void OnGhostReturnToRoundRequest(GhostReturnToRoundRequest msg, EntitySessionEventArgs args) | ||
{ | ||
var uid = args.SenderSession.AttachedEntity; | ||
|
||
if (uid == null) | ||
return; | ||
|
||
var connectedClient = args.SenderSession.ConnectedClient; | ||
var userId = args.SenderSession.UserId; | ||
|
||
TryGhostReturnToRound(uid.Value, connectedClient, userId, out var message, out var wrappedMessage); | ||
|
||
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, | ||
message, | ||
wrappedMessage, | ||
default, | ||
false, | ||
connectedClient, | ||
Color.Red); | ||
} | ||
|
||
private void TryGhostReturnToRound(EntityUid uid, INetChannel connectedClient, NetUserId userId, out string message, out string wrappedMessage) | ||
{ | ||
var maxPlayers = _cfg.GetCVar(WhiteCVars.GhostRespawnMaxPlayers); | ||
if (_playerManager.PlayerCount >= maxPlayers) | ||
{ | ||
message = Loc.GetString("ghost-respawn-max-players", ("players", maxPlayers)); | ||
wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
return; | ||
} | ||
|
||
var deathTime = EnsureComp<GhostComponent>(uid).TimeOfDeath; | ||
var timeUntilRespawn = _cfg.GetCVar(WhiteCVars.GhostRespawnTime); | ||
var timePast = (_gameTiming.CurTime - deathTime).TotalMinutes; | ||
if (timePast >= timeUntilRespawn) | ||
{ | ||
var ticker = Get<GameTicker>(); | ||
_playerManager.TryGetSessionById(userId, out var targetPlayer); | ||
|
||
if (targetPlayer != null) | ||
ticker.Respawn(targetPlayer); | ||
|
||
_adminLogger.Add(LogType.Mind, LogImpact.Medium, $"{Loc.GetString("ghost-respawn-log-return-to-lobby", ("userName", connectedClient.UserName))}"); | ||
|
||
message = Loc.GetString("ghost-respawn-window-rules-footer"); | ||
wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
|
||
return; | ||
} | ||
|
||
message = Loc.GetString("ghost-respawn-time-left", ("time", (int) (timeUntilRespawn - timePast))); | ||
wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message)); | ||
} | ||
} |
This file contains 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 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 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 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,15 @@ | ||
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-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 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 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 = До возможности вернуться в раунд { $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-same-character = Нельзя заходить в раунд за того же персонажа. Поменяйте его в настройках персонажей. | ||
ghost-respawn-log-character-almost-same = Игрок { $player } { $try -> | ||
[true] зашёл | ||
*[false] попытался зайти | ||
} в раунд после возвращения в лобби с похожим именем. Прошлое имя: { $oldName }, текущее: { $newName }. | ||
ghost-respawn-log-return-to-lobby = { $userName } вернулся в лобби. |
This file contains 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