Typo, redundant string interpolation, namespaces and imports cleanup (#2068)

* Readonly, typos and redundant string interpolations

* Namespaces

* Optimize imports

* Address reviews

* but actually

* Localize missing strings

* Remove redundant vars
This commit is contained in:
DrSmugleaf
2020-09-13 14:23:52 +02:00
committed by GitHub
parent 2e5838bb62
commit 74943a2770
213 changed files with 465 additions and 669 deletions

View File

@@ -1,27 +1,26 @@
using Content.Server.GameTicking.GameRules;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Players;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.PDA;
using Content.Server.GameObjects.Components.Suspicion;
using Content.Server.Mobs.Roles;
using Content.Server.GameTicking.GameRules;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Mobs.Roles.Suspicion;
using Content.Server.Players;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.Components.PDA;
using Content.Shared.Roles;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.GameTicking.GamePresets
{
@@ -68,7 +67,7 @@ namespace Content.Server.GameTicking.GamePresets
if (readyPlayers.Count == 0)
{
_chatManager.DispatchServerAnnouncement($"No players readied up! Can't start Suspicion.");
_chatManager.DispatchServerAnnouncement("No players readied up! Can't start Suspicion.");
return false;
}

View File

@@ -10,6 +10,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Timer = Robust.Shared.Timers.Timer;
namespace Content.Server.GameTicking.GameRules
@@ -32,7 +33,7 @@ namespace Content.Server.GameTicking.GameRules
public override void Added()
{
_chatManager.DispatchServerAnnouncement("The game is now a death match. Kill everybody else to win!");
_chatManager.DispatchServerAnnouncement(Loc.GetString("The game is now a death match. Kill everybody else to win!"));
_entityManager.EventBus.SubscribeEvent<HealthChangedEventArgs>(EventSource.Local, this, OnHealthChanged);
_playerManager.PlayerStatusChanged += PlayerManagerOnPlayerStatusChanged;
@@ -81,19 +82,15 @@ namespace Content.Server.GameTicking.GameRules
winner = playerSession;
}
if (winner == null)
{
_chatManager.DispatchServerAnnouncement("Everybody is dead, it's a stalemate!");
}
else
{
// We have a winner!
_chatManager.DispatchServerAnnouncement($"{winner} wins the death match!");
}
_chatManager.DispatchServerAnnouncement(winner == null
? Loc.GetString("Everybody is dead, it's a stalemate!")
: Loc.GetString("{0} wins the death match!", winner));
_chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
var restartDelay = 10;
Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
_chatManager.DispatchServerAnnouncement(Loc.GetString("Restarting in {0} seconds.", restartDelay));
Timer.Spawn(TimeSpan.FromSeconds(restartDelay), () => _gameTicker.RestartRound());
}
private void PlayerManagerOnPlayerStatusChanged(object sender, SessionStatusEventArgs e)

View File

@@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Suspicion;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Mobs.Roles;
using Content.Server.Mobs.Roles.Suspicion;
using Content.Server.Players;
using Content.Shared.GameObjects.Components.Damage;
@@ -15,6 +14,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Timer = Robust.Shared.Timers.Timer;
namespace Content.Server.GameTicking.GameRules
@@ -36,10 +36,11 @@ namespace Content.Server.GameTicking.GameRules
public override void Added()
{
_chatManager.DispatchServerAnnouncement("There are traitors on the station! Find them, and kill them!");
_chatManager.DispatchServerAnnouncement(Loc.GetString("There are traitors on the station! Find them, and kill them!"));
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Misc/tatoralert.ogg", AudioParams.Default,
(session) => session.ContentData().Mind?.HasRole<SuspicionTraitorRole>() ?? false);
bool Predicate(IPlayerSession session) => session.ContentData()?.Mind?.HasRole<SuspicionTraitorRole>() ?? false;
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Misc/tatoralert.ogg", AudioParams.Default, Predicate);
EntitySystem.Get<DoorSystem>().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal;
@@ -67,7 +68,7 @@ namespace Content.Server.GameTicking.GameRules
{
if (playerSession.AttachedEntity == null
|| !playerSession.AttachedEntity.TryGetComponent(out IDamageableComponent damageable)
|| !playerSession.AttachedEntity.TryGetComponent(out SuspicionRoleComponent suspicionRole))
|| !playerSession.AttachedEntity.HasComponent<SuspicionRoleComponent>())
{
continue;
}
@@ -77,26 +78,28 @@ namespace Content.Server.GameTicking.GameRules
continue;
}
if (playerSession.ContentData().Mind.HasRole<SuspicionTraitorRole>())
var mind = playerSession.ContentData()?.Mind;
if (mind != null && mind.HasRole<SuspicionTraitorRole>())
traitorsAlive++;
else
innocentsAlive++;
}
if ((innocentsAlive + traitorsAlive) == 0)
if (innocentsAlive + traitorsAlive == 0)
{
_chatManager.DispatchServerAnnouncement("Everybody is dead, it's a stalemate!");
_chatManager.DispatchServerAnnouncement(Loc.GetString("Everybody is dead, it's a stalemate!"));
EndRound(Victory.Stalemate);
}
else if (traitorsAlive == 0)
{
_chatManager.DispatchServerAnnouncement("The traitors are dead! The innocents win.");
_chatManager.DispatchServerAnnouncement(Loc.GetString("The traitors are dead! The innocents win."));
EndRound(Victory.Innocents);
}
else if (innocentsAlive == 0)
{
_chatManager.DispatchServerAnnouncement("The innocents are dead! The traitors win.");
_chatManager.DispatchServerAnnouncement(Loc.GetString("The innocents are dead! The traitors win."));
EndRound(Victory.Traitors);
}
}
@@ -115,20 +118,24 @@ namespace Content.Server.GameTicking.GameRules
switch (victory)
{
case Victory.Innocents:
text = "The innocents have won!";
text = Loc.GetString("The innocents have won!");
break;
case Victory.Traitors:
text = "The traitors have won!";
text = Loc.GetString("The traitors have won!");
break;
default:
text = "Nobody wins!";
text = Loc.GetString("Nobody wins!");
break;
}
_gameTicker.EndRound(text);
_chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
var restartDelay = 10;
_chatManager.DispatchServerAnnouncement(Loc.GetString("Restarting in {0} seconds.", restartDelay));
_checkTimerCancel.Cancel();
Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
Timer.Spawn(TimeSpan.FromSeconds(restartDelay), () => _gameTicker.RestartRound());
}
}
}

View File

@@ -22,9 +22,7 @@ using Content.Server.Interfaces.GameTicking;
using Content.Server.Mobs;
using Content.Server.Mobs.Roles;
using Content.Server.Players;
using Content.Shared;
using Content.Shared.Chat;
using Content.Shared.GameObjects.Components.PDA;
using Content.Shared.Network.NetMessages;
using Content.Shared.Preferences;
using Content.Shared.Roles;
@@ -49,7 +47,6 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

View File

@@ -365,7 +365,7 @@ namespace Content.Server.GameTicking
shell.ExecuteCommand(player, $"addmap {mapId} false");
shell.ExecuteCommand(player, $"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\"");
shell.ExecuteCommand(player, $"aghost");
shell.ExecuteCommand(player, "aghost");
shell.ExecuteCommand(player, $"tp 0 0 {mapId}");
var newGridId = mapManager.GetAllGrids().Max(g => (int) g.Index);