diff --git a/.addon b/.addon index 826f97dcf..a51edd40a 100644 --- a/.addon +++ b/.addon @@ -3,17 +3,18 @@ "Type": "game", "Org": "neox", "Ident": "tttreborn", + "Tags": "", "Schema": 1, "HasAssets": true, "AssetsPath": "", "ResourcePaths": [ "/weapons/*", "/sounds/*", - "/materials/*" + "/materials/*", + "/lang/*" ], "HasCode": true, "CodePath": "code", - "RootNamespace": "TTTReborn", "Metadata": { "MapList": [ "tbt.minecraftcity_v4", @@ -26,6 +27,49 @@ "RankType": 0, "MapSelect": 0, "GameNetworkType": 0, - "MaxPlayers": 16 + "MaxPlayers": 16, + "Collision": { + "Defaults": { + "solid": "Collide", + "trigger": "Trigger", + "ladder": "Ignore", + "water": "Trigger", + "corpse": "Collide", + "debris": "Unset", + "player": "Unset" + }, + "Pairs": [ + { + "a": "solid", + "b": "solid", + "r": "Collide" + }, + { + "a": "trigger", + "b": "playerclip", + "r": "Ignore" + }, + { + "a": "trigger", + "b": "solid", + "r": "Trigger" + }, + { + "a": "solid", + "b": "trigger", + "r": "Collide" + }, + { + "a": "playerclip", + "b": "solid", + "r": "Collide" + }, + { + "a": "corpse", + "b": "player", + "r": "Ignore" + } + ] + } } -} +} \ No newline at end of file diff --git a/code/CameraMode.cs b/code/CameraMode.cs new file mode 100644 index 000000000..e35d9066f --- /dev/null +++ b/code/CameraMode.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox +{ + public class CameraMode : EntityComponent + { + public Vector3 Position + { + get + { + return Camera.Position; + } + set + { + Camera.Position = value; + } + } + public Rotation Rotation + { + get + { + return Camera.Rotation; + } + set + { + Camera.Rotation = value; + } + } + + public float FieldOfView + { + get + { + return Camera.FieldOfView; + } + set + { + Camera.FieldOfView = value; + } + } + + public Entity Viewer + { + get + { + return Camera.FirstPersonViewer as Entity; + } + set + { + Camera.FirstPersonViewer = value; + } + } + public virtual void Deactivated() { } + public virtual void Activated() { } + + public virtual void Build() + { + Update(); + } + + public virtual void BuildInput() { } + + public virtual void Update() + { + + } + } +} diff --git a/code/gameevents/base/ClientGameEvent.cs b/code/gameevents/base/ClientGameEvent.cs index 79de946e2..0a60e196d 100644 --- a/code/gameevents/base/ClientGameEvent.cs +++ b/code/gameevents/base/ClientGameEvent.cs @@ -12,16 +12,16 @@ public partial class ClientGameEvent : NetworkableGameEvent public string PlayerName { get; set; } [JsonIgnore] - public Client Client + public IClient Client { - get => Client.All.First((cl) => cl.PlayerId == PlayerId); + get => Sandbox.Game.Clients.First((cl) => cl.SteamId == PlayerId); } - public ClientGameEvent(Client client) : base() + public ClientGameEvent(IClient client) : base() { if (client != null) { - PlayerId = client.PlayerId; + PlayerId = client.SteamId; PlayerName = client.Name; } } diff --git a/code/gameevents/base/GameEvent.cs b/code/gameevents/base/GameEvent.cs index 9af314547..37cee1d7c 100644 --- a/code/gameevents/base/GameEvent.cs +++ b/code/gameevents/base/GameEvent.cs @@ -37,7 +37,7 @@ public GameEvent() Name = attribute.Name; } - BaseRound baseRound = Gamemode.Game.Instance.Round; + BaseRound baseRound = Gamemode.TTTGame.Instance.Round; CreatedAt = baseRound.RoundEndTime - baseRound.StartedAt - baseRound.TimeLeft; } @@ -54,9 +54,9 @@ protected virtual void OnRegister() internal void ProcessRegister() { - if (Host.IsServer) + if (Game.IsServer) { - Gamemode.Game.Instance.Round?.GameEvents.Add(this); + Gamemode.TTTGame.Instance.Round?.GameEvents.Add(this); OnRegister(); } @@ -105,7 +105,7 @@ public GameEventScoring(Player player) { if (player != null && player.Client != null) { - PlayerId = player.Client.PlayerId; + PlayerId = player.Client.SteamId; } } } diff --git a/code/gameevents/base/ILoggedGameEvent.cs b/code/gameevents/base/ILoggedGameEvent.cs index 3e2c599c8..89a5a8252 100644 --- a/code/gameevents/base/ILoggedGameEvent.cs +++ b/code/gameevents/base/ILoggedGameEvent.cs @@ -13,8 +13,8 @@ public interface ILoggedGameEvent public float CreatedAt { get; set; } - public virtual Sandbox.UI.Panel GetEventPanel(Client client = null) => new UI.EventPanel(this); + public virtual Sandbox.UI.Panel GetEventPanel(IClient client = null) => new UI.EventPanel(this); - public virtual bool Contains(Client client) => false; + public virtual bool Contains(IClient client) => false; } } diff --git a/code/gameevents/base/NetworkableGameEvent.cs b/code/gameevents/base/NetworkableGameEvent.cs index b074a82f6..649913ef5 100644 --- a/code/gameevents/base/NetworkableGameEvent.cs +++ b/code/gameevents/base/NetworkableGameEvent.cs @@ -19,7 +19,7 @@ public virtual void RunNetworked(To to) base.Run(); - if (Host.IsServer) + if (Game.IsServer) { ServerCallNetworked(to); } diff --git a/code/gameevents/base/PlayerGameEvent.cs b/code/gameevents/base/PlayerGameEvent.cs index 5aab924e7..c03c30973 100644 --- a/code/gameevents/base/PlayerGameEvent.cs +++ b/code/gameevents/base/PlayerGameEvent.cs @@ -20,7 +20,7 @@ public PlayerGameEvent(TTTReborn.Player player) : base() { if (player != null && player.Client != null) { - PlayerId = player.Client.PlayerId; + PlayerId = player.Client.SteamId; PlayerName = player.Client.Name; } } diff --git a/code/gameevents/game/FinishEvent.cs b/code/gameevents/game/FinishEvent.cs index c56bcbfde..776ede390 100644 --- a/code/gameevents/game/FinishEvent.cs +++ b/code/gameevents/game/FinishEvent.cs @@ -77,6 +77,6 @@ protected override void OnRegister() } } - public bool Contains(Client client) => true; + public bool Contains(IClient client) => true; } } diff --git a/code/gameevents/player/ConnectedEvent.cs b/code/gameevents/player/ConnectedEvent.cs index 8a2e05360..f2daa8897 100644 --- a/code/gameevents/player/ConnectedEvent.cs +++ b/code/gameevents/player/ConnectedEvent.cs @@ -9,6 +9,6 @@ public partial class ConnectedEvent : ClientGameEvent /// Occurs when a player connects. /// The instance of the player who connected. /// - public ConnectedEvent(Client client) : base(client) { } + public ConnectedEvent(IClient client) : base(client) { } } } diff --git a/code/gameevents/player/DiedEvent.cs b/code/gameevents/player/DiedEvent.cs index 23dbc769f..18cf96334 100644 --- a/code/gameevents/player/DiedEvent.cs +++ b/code/gameevents/player/DiedEvent.cs @@ -84,6 +84,6 @@ protected override void OnRegister() }; } - public bool Contains(Client client) => PlayerName == client.Name || LastAttackerName == client.Name; + public bool Contains(IClient client) => PlayerName == client.Name || LastAttackerName == client.Name; } } diff --git a/code/gameevents/player/InitialSpawnEvent.cs b/code/gameevents/player/InitialSpawnEvent.cs index 74609c607..693832989 100644 --- a/code/gameevents/player/InitialSpawnEvent.cs +++ b/code/gameevents/player/InitialSpawnEvent.cs @@ -7,8 +7,8 @@ public partial class InitialSpawnEvent : ClientGameEvent { /// /// Occurs when a player initializes. - /// The instance of the player who spawned initially. + /// The instance of the player who spawned initially. /// - public InitialSpawnEvent(Client client) : base(client) { } + public InitialSpawnEvent(IClient client) : base(client) { } } } diff --git a/code/gameevents/player/SpawnEvent.cs b/code/gameevents/player/SpawnEvent.cs index d032864d5..976df2ea1 100644 --- a/code/gameevents/player/SpawnEvent.cs +++ b/code/gameevents/player/SpawnEvent.cs @@ -15,6 +15,6 @@ public partial class SpawnEvent : PlayerGameEvent, ILoggedGameEvent /// public SpawnEvent(TTTReborn.Player player) : base(player) { } - public bool Contains(Client client) => PlayerName == client.Name; + public bool Contains(IClient client) => PlayerName == client.Name; } } diff --git a/code/gameevents/player/TakeDamageEvent.cs b/code/gameevents/player/TakeDamageEvent.cs index 114a81306..20f6395e3 100644 --- a/code/gameevents/player/TakeDamageEvent.cs +++ b/code/gameevents/player/TakeDamageEvent.cs @@ -54,7 +54,7 @@ public TakeDamageEvent(TTTReborn.Player player, float damage, Entity attacker) : if (attacker is TTTReborn.Player) { AttackerName = attacker.Client.Name; - AttackerPlayerId = attacker.Client.PlayerId; + AttackerPlayerId = attacker.Client.SteamId; } else { @@ -121,7 +121,7 @@ public static void OnLoggedGameEventEvaluate(List gameEvents) } } - public bool Contains(Client client) => PlayerName == client.Name || AttackerName == client.Name; + public bool Contains(IClient client) => PlayerName == client.Name || AttackerName == client.Name; protected override void OnRegister() { @@ -136,7 +136,7 @@ protected override void OnRegister() { new(attacker) { - Karma = Gamemode.Game.Instance.Karma.CalculatePenalty(Math.Min(Damage, Player.Health)) + Karma = Gamemode.TTTGame.Instance.Karma.CalculatePenalty(Math.Min(Damage, Player.Health)) } }; } diff --git a/code/gameevents/player/role/SelectEvent.cs b/code/gameevents/player/role/SelectEvent.cs index e6f056968..953a457cf 100644 --- a/code/gameevents/player/role/SelectEvent.cs +++ b/code/gameevents/player/role/SelectEvent.cs @@ -23,6 +23,6 @@ public SelectEvent(TTTReborn.Player player) : base(player) } } - public bool Contains(Client client) => PlayerName == client.Name; + public bool Contains(IClient client) => PlayerName == client.Name; } } diff --git a/code/gamemode/Karma.cs b/code/gamemode/Karma.cs index 577404284..85adb2b4f 100644 --- a/code/gamemode/Karma.cs +++ b/code/gamemode/Karma.cs @@ -27,7 +27,7 @@ public partial class KarmaSystem // [ServerVar("ttt_karma_penalty_max", Help = "The maximum amount of karma loss per player.")] // public static int TTTKarmaPenaltyMax { get; set; } = 100; - public void RegisterPlayer(Client client) + public void RegisterPlayer(IClient client) { client.SetInt("karma", 1000); } @@ -47,7 +47,7 @@ public void RegisterPlayerDamage(Player attacker, Player victim, float damage) public void UpdatePlayerKarma(Player player, int delta) { - UpdatePlayerIdKarma(player.Client.PlayerId, delta); + UpdatePlayerIdKarma(player.Client.SteamId, delta); } public void UpdatePlayerIdKarma(long playerId, int delta) @@ -84,7 +84,7 @@ public void ResolveKarma() // DamageRecords = new(); } - public bool IsBanned(Client client) + public bool IsBanned(IClient client) { // TODO: Once network dictionaries are supported, implement. Return false meanwhile... // return (KarmaRecords[player.PlayerId] < TTTKarmaMin && TTTKarmaBan); diff --git a/code/gamemode/Game.Precache.cs b/code/gamemode/TTTGame.Precache.cs similarity index 92% rename from code/gamemode/Game.Precache.cs rename to code/gamemode/TTTGame.Precache.cs index 64a688e4c..ab20ff978 100644 --- a/code/gamemode/Game.Precache.cs +++ b/code/gamemode/TTTGame.Precache.cs @@ -6,11 +6,11 @@ namespace TTTReborn.Gamemode { - public partial class Game + public partial class TTTGame { public static void PrecacheFiles() { - Host.AssertServer(); + Game.AssertServer(); Precache.Add("particles/impact.generic.vpcf"); Precache.Add("particles/impact.flesh.vpcf"); diff --git a/code/gamemode/Game.cs b/code/gamemode/TTTGame.cs similarity index 72% rename from code/gamemode/Game.cs rename to code/gamemode/TTTGame.cs index 3f589fc03..b2750c0df 100644 --- a/code/gamemode/Game.cs +++ b/code/gamemode/TTTGame.cs @@ -1,6 +1,7 @@ using System; using Sandbox; +using Sandbox.Diagnostics; using TTTReborn.Globalization; using TTTReborn.Map; @@ -10,9 +11,9 @@ namespace TTTReborn.Gamemode { - public partial class Game : Sandbox.Game + public partial class TTTGame : Sandbox.GameManager { - public static Game Instance { get; private set; } + public static TTTGame Instance { get; private set; } [Net, Change] public BaseRound Round { get; private set; } = new Rounds.WaitingRound(); @@ -24,14 +25,14 @@ public partial class Game : Sandbox.Game public MapHandler MapHandler { get; private set; } - // [ConVar.Replicated("ttt_debug")] + [ConVar.Replicated("ttt_debug")] public bool Debug { get; set; } = true; - public Game() + public TTTGame() { Instance = this; - if (IsServer) + if (Game.IsServer) { PrecacheFiles(); } @@ -40,7 +41,7 @@ public Game() SettingsManager.Load(); _ = MapSelection.Load(); - if (IsServer) + if (Game.IsServer) { ShopManager.Load(); } @@ -72,7 +73,7 @@ public void ChangeRound(BaseRound round) /// The round to change to. public void ForceRoundChange(BaseRound round) { - Host.AssertServer(); + Game.AssertServer(); Round.Finish(); @@ -84,18 +85,18 @@ public void ForceRoundChange(BaseRound round) Round.Start(); } - public override void DoPlayerNoclip(Client client) - { - // Do nothing. The player can't noclip in this mode. - } + //public override void DoPlayerNoclip(IClient client) + //{ + // // Do nothing. The player can't noclip in this mode. + //} - public override void DoPlayerSuicide(Client client) - { - if (client.Pawn is Player player && player.LifeState == LifeState.Alive) - { - base.DoPlayerSuicide(client); - } - } + //public override void DoPlayerSuicide(IClient client) + //{ + // if (client.Pawn is Player player && player.LifeState == LifeState.Alive) + // { + // base.DoPlayerSuicide(client); + // } + //} public override void OnKilled(Entity entity) { @@ -107,7 +108,7 @@ public override void OnKilled(Entity entity) } } - public override void ClientJoined(Client client) + public override void ClientJoined(IClient client) { Karma.RegisterPlayer(client); @@ -129,20 +130,20 @@ public override void ClientJoined(Client client) base.ClientJoined(client); } - public override void ClientDisconnect(Client client, NetworkDisconnectionReason reason) + public override void ClientDisconnect(IClient client, NetworkDisconnectionReason reason) { Log.Info(client.Name + " left, checking minimum player count..."); Round.OnPlayerLeave(client.Pawn as Player); - NetworkableGameEvent.RegisterNetworked(new Events.Player.DisconnectedEvent(client.PlayerId, reason)); + NetworkableGameEvent.RegisterNetworked(new Events.Player.DisconnectedEvent(client.SteamId, reason)); base.ClientDisconnect(client, reason); } - public override bool CanHearPlayerVoice(Client source, Client dest) + public override bool CanHearPlayerVoice(IClient source,IClient dest) { - Host.AssertServer(); + Game.AssertServer(); if (source.Name.Equals(dest.Name) || source.Pawn is not Player sourcePlayer || dest.Pawn is not Player destPlayer) { @@ -166,32 +167,32 @@ public override bool CanHearPlayerVoice(Client source, Client dest) /// Someone is speaking via voice chat. This might be someone in your game, /// or in your party, or in your lobby. /// - public override void OnVoicePlayed(long playerId, float level) - { - Client client = null; - - foreach (Client loopClient in Client.All) - { - if (loopClient.PlayerId == playerId) - { - client = loopClient; - - break; - } - } - - if (client == null || !client.IsValid()) - { - return; - } - - if (client.Pawn is Player player) - { - player.IsSpeaking = true; - } - - UI.VoiceChatDisplay.Instance?.OnVoicePlayed(client, level); - } + //public override void OnVoicePlayed(long playerId, float level) + //{ + // Client client = null; + + // foreach (Client loopClient in Game.Clients) + // { + // if (loopClient.PlayerId == playerId) + // { + // client = loopClient; + + // break; + // } + // } + + // if (client == null || !client.IsValid()) + // { + // return; + // } + + // if (client.Pawn is Player player) + // { + // player.IsSpeaking = true; + // } + + // UI.VoiceChatDisplay.Instance?.OnVoicePlayed(client, level); + //} public override void PostLevelLoaded() { diff --git a/code/global/LoggerExtension.cs b/code/global/LoggerExtension.cs index 4ab1ac0a9..1e557f303 100644 --- a/code/global/LoggerExtension.cs +++ b/code/global/LoggerExtension.cs @@ -1,4 +1,5 @@ using Sandbox; +using Sandbox.Diagnostics; namespace TTTReborn.Globals { @@ -6,12 +7,12 @@ public static class LoggerExtension { public static void Debug(this Logger log, params object[] obj) { - if (!Gamemode.Game.Instance?.Debug ?? true) + if (!Gamemode.TTTGame.Instance?.Debug ?? true) { return; } - string host = Host.IsServer ? "SERVER" : "CLIENT"; + string host = Game.IsServer ? "SERVER" : "CLIENT"; log.Info($"[DEBUG][{host}] {string.Join(',', obj)}"); } diff --git a/code/global/RPCs.cs b/code/global/RPCs.cs index 670dd2afe..6c5d422e8 100644 --- a/code/global/RPCs.cs +++ b/code/global/RPCs.cs @@ -24,7 +24,7 @@ public static void ClientSetRole(Player player, string roleName, string teamName player.SetRole(Utils.GetObjectByType(Utils.GetTypeByLibraryName(roleName)), TeamFunctions.GetTeam(teamName)); - Client client = player.Client; + IClient client = player.Client; if (client == null || !client.IsValid()) { @@ -75,7 +75,7 @@ public static void ClientConfirmPlayer(Player confirmPlayer, PlayerCorpse player return; } - Client confirmClient = confirmPlayer.Client; + IClient confirmClient = confirmPlayer.Client; // TODO improve if (deadPlayer.IsValid()) @@ -95,7 +95,7 @@ public static void ClientConfirmPlayer(Player confirmPlayer, PlayerCorpse player ); } - if (confirmPlayer == Local.Pawn as Player && data.Credits > 0) + if (confirmPlayer == Game.LocalPawn as Player && data.Credits > 0) { InfoFeed.Current?.AddEntry( confirmClient, diff --git a/code/global/Utils.cs b/code/global/Utils.cs index 9fd20f4fe..6451b2474 100644 --- a/code/global/Utils.cs +++ b/code/global/Utils.cs @@ -12,11 +12,11 @@ public static partial class Utils { public readonly static Random RNG = new(); - public static List GetClients(Func predicate = null) + public static List GetClients(Func predicate = null) { - List clients = new(); + List clients = new(); - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player && (predicate == null || predicate.Invoke(player))) { @@ -31,7 +31,7 @@ public static List GetPlayers(Func predicate = null) { List players = new(); - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player && (predicate == null || predicate.Invoke(player))) { @@ -46,7 +46,7 @@ public static List GetPlayers(Func predicate = null) public static Player GetPlayerById(long playerId) { - Client client = Client.All.FirstOrDefault((cl) => cl.PlayerId == playerId, null); + IClient client = Game.Clients.FirstOrDefault((cl) => cl.SteamId == playerId, null); if (client != null && client.Pawn is Player player) { @@ -71,7 +71,7 @@ public static Player GetPlayerById(long playerId) /// List of all available and matching types of the given type public static List GetTypes(Func predicate) { - IEnumerable types = TypeLibrary.GetTypes().Where(t => !t.IsAbstract && !t.ContainsGenericParameters); + IEnumerable types = TypeLibrary.GetTypes().Where(t => !t.IsAbstract && !t.TargetType.ContainsGenericParameters).Select(t => t.TargetType); if (predicate != null) { @@ -115,7 +115,7 @@ public static Type GetTypeByLibraryName(string name) /// /// A `Type` that has a `Sandbox.LibraryAttribute` /// `Sandbox.LibraryAttribute`'s `Name` - public static string GetLibraryName(Type type) => TypeLibrary.GetDescription(type).ClassName.ToLower(); + public static string GetLibraryName(Type type) => TypeLibrary.GetType(type).ClassName.ToLower(); public static T GetAttribute(Type type) where T : Attribute => TypeLibrary.GetAttribute(type); @@ -181,7 +181,7 @@ public static void Enabled(this Panel panel, bool enabled) public static bool IsEnabled(this Panel panel) => !panel.HasClass("disabled"); - public static string GetTypeName(Type type) => type.FullName.Replace(type.Namespace, "").TrimStart('.'); + public static string GetTypeName(Type type) => type.FullName/*.Replace(type.Namespace, "")*/.TrimStart('.'); public enum Realm { @@ -241,37 +241,37 @@ public static void AddIfDoesNotContain(this IList list, T item) public static void SetPropertyValue(object obj, string propertyName, T value) { - PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName); - - if (propertyInfo != null && propertyInfo.CanWrite) - { - try - { - propertyInfo.SetValue(obj, Convert.ChangeType(value, propertyInfo.GetValue(obj).GetType())); - } - catch (Exception ex) - { - Log.Error($"Tried to write property '{propertyName}' of '{obj}' with '{value}' ({ex.Message})"); - } - } - else - { - Log.Warning($"Tried to write property '{propertyName}' of '{obj}' with '{value}'"); - } + //PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName); + + //if (propertyInfo != null && propertyInfo.CanWrite) + //{ + // try + // { + // propertyInfo.SetValue(obj, Convert.ChangeType(value, propertyInfo.GetValue(obj).GetType())); + // } + // catch (Exception ex) + // { + // Log.Error($"Tried to write property '{propertyName}' of '{obj}' with '{value}' ({ex.Message})"); + // } + //} + //else + //{ + // Log.Warning($"Tried to write property '{propertyName}' of '{obj}' with '{value}'"); + //} } - public static T GetPropertyValue(object obj, string propertyName) - { - PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName); + public static T GetPropertyValue(object obj, string propertyName) { + + //PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName); - if (propertyInfo == null || !propertyInfo.CanRead) - { - Log.Warning($"Tried to read non-existing property '{propertyName}' of '{obj}'"); + //if (propertyInfo == null || !propertyInfo.CanRead) + //{ + // Log.Warning($"Tried to read non-existing property '{propertyName}' of '{obj}'"); return default; - } + //} - return (T) propertyInfo.GetValue(obj); + //return (T) propertyInfo.GetValue(obj); } public static object GetPropertyValue(object obj, string propertyName) => GetPropertyValue(obj, propertyName); diff --git a/code/items/IItem.cs b/code/items/IItem.cs index 00f0cac5e..e4d6f637e 100644 --- a/code/items/IItem.cs +++ b/code/items/IItem.cs @@ -25,7 +25,7 @@ public interface IItem void Delete(); - void Simulate(Client owner); + void Simulate(IClient owner); void OnPurchase(Player player) { diff --git a/code/items/ShopItemData.cs b/code/items/ShopItemData.cs index 00725ea13..6b4280a14 100644 --- a/code/items/ShopItemData.cs +++ b/code/items/ShopItemData.cs @@ -43,7 +43,7 @@ public ShopItemData Clone() public static ShopItemData CreateItemData(Type type) { - TypeDescription typeDescription = TypeLibrary.GetDescription(type); + TypeDescription typeDescription = TypeLibrary.GetType(type); bool buyable = false; ShopItemData shopItemData = new(typeDescription.ClassName) @@ -51,7 +51,7 @@ public static ShopItemData CreateItemData(Type type) Type = type }; - foreach (object obj in type.GetCustomAttributes(false)) + foreach (object obj in typeDescription.GetAttributes()) { if (obj is BuyableAttribute buyableAttribute) { diff --git a/code/items/ammo/Ammo.cs b/code/items/ammo/Ammo.cs index f93c6ea95..744c451ed 100644 --- a/code/items/ammo/Ammo.cs +++ b/code/items/ammo/Ammo.cs @@ -58,8 +58,7 @@ public override void Spawn() SetModel(ModelPath); SetupPhysicsFromModel(PhysicsMotionType.Dynamic); - CollisionGroup = CollisionGroup.Weapon; - SetInteractsAs(CollisionLayer.Debris); + Tags.Add("debris"); AmmoEntMax = Amount; CurrentAmmo = Amount; @@ -88,7 +87,7 @@ public override void TakeDamage(DamageInfo info) body = PhysicsBody; } - if (body.IsValid() && !info.Flags.HasFlag(DamageFlags.PhysicsImpact)) + if (body.IsValid() && !info.HasTag("physicsimpact")) { body.ApplyImpulseAt(info.Position, info.Force * 100); } @@ -122,7 +121,7 @@ public virtual void PickupEndTouch(Entity other) public void HintTick(Player player) { - if (IsClient || player.LifeState != LifeState.Alive) + if (Game.IsClient || player.LifeState != LifeState.Alive) { return; } diff --git a/code/items/ammo/AmmoRandom.cs b/code/items/ammo/AmmoRandom.cs index 90cdcd68f..a78b6a81d 100644 --- a/code/items/ammo/AmmoRandom.cs +++ b/code/items/ammo/AmmoRandom.cs @@ -35,7 +35,7 @@ public void Activate() if (weaponAttribute != null && weaponAttribute.Category == Category) { - if (weaponAttribute.PrimaryAmmoType != null && TypeLibrary.GetDescription(weaponAttribute.PrimaryAmmoType) != null && (weaponAttribute.PrimaryAmmoType != null ? Utils.GetLibraryName(weaponAttribute.PrimaryAmmoType) : null) == Utils.GetLibraryName(ammoType)) + if (weaponAttribute.PrimaryAmmoType != null && TypeLibrary.GetType(weaponAttribute.PrimaryAmmoType) != null && (weaponAttribute.PrimaryAmmoType != null ? Utils.GetLibraryName(weaponAttribute.PrimaryAmmoType) : null) == Utils.GetLibraryName(ammoType)) { if (!filteredTypes.Contains(ammoType)) { diff --git a/code/items/equipments/C4Equipment.cs b/code/items/equipments/C4Equipment.cs index 6145edae0..efcd8c4ab 100644 --- a/code/items/equipments/C4Equipment.cs +++ b/code/items/equipments/C4Equipment.cs @@ -18,9 +18,9 @@ public partial class C4Equipment : Equipment private const int PLACE_DISTANCE = 200; - public override void Simulate(Client client) + public override void Simulate(IClient client) { - if (!IsServer || Owner is not Player owner) + if (!Game.IsServer || Owner is not Player owner) { return; } @@ -29,7 +29,7 @@ public override void Simulate(Client client) { if (Input.Pressed(InputButton.PrimaryAttack)) { - TraceResult placementTrace = Trace.Ray(Owner.EyePosition, Owner.EyePosition + Owner.EyeRotation.Forward * PLACE_DISTANCE) + TraceResult placementTrace = Trace.Ray(Owner.AimRay.Position, Owner.AimRay.Position + Owner.AimRay.Forward * PLACE_DISTANCE) .Ignore(owner) .UseHitboxes() .Run(); diff --git a/code/items/equipments/Equipment.cs b/code/items/equipments/Equipment.cs index 2d3e973ed..0ffbb65bc 100644 --- a/code/items/equipments/Equipment.cs +++ b/code/items/equipments/Equipment.cs @@ -116,11 +116,11 @@ public override void OnCarryDrop(Entity dropper) } } - public override void Simulate(Client client) + public override void Simulate(IClient client) { base.Simulate(client); - if (!IsServer || Owner is not Player owner || !CanDrop) + if (!Game.IsServer || Owner is not Player owner || !CanDrop) { return; } diff --git a/code/items/equipments/Hands.GrabbableCorpse.cs b/code/items/equipments/Hands.GrabbableCorpse.cs index ddb2fc122..3d18617e4 100644 --- a/code/items/equipments/Hands.GrabbableCorpse.cs +++ b/code/items/equipments/Hands.GrabbableCorpse.cs @@ -1,4 +1,5 @@ using Sandbox; +using Sandbox.Physics; namespace TTTReborn.Items { @@ -23,7 +24,7 @@ public GrabbableCorpse(Player player, PlayerCorpse corpse, PhysicsBody physicsBo _corpsePhysicsBody = physicsBodyCorpse; _corpseBone = corpseBone; - _handPhysicsBody = new(Sandbox.Internal.GlobalGameNamespace.Map.Physics) + _handPhysicsBody = new(Game.PhysicsWorld) { BodyType = PhysicsBodyType.Keyframed }; diff --git a/code/items/equipments/Hands.GrabbableProp.cs b/code/items/equipments/Hands.GrabbableProp.cs index 285de9e3f..617512334 100644 --- a/code/items/equipments/Hands.GrabbableProp.cs +++ b/code/items/equipments/Hands.GrabbableProp.cs @@ -78,7 +78,7 @@ public void PrimaryAction() Drop(); - grabbedEntity.Velocity += Owner.EyeRotation.Forward * THROW_FORCE; + grabbedEntity.Velocity += Owner.AimRay.Forward * THROW_FORCE; } } } diff --git a/code/items/equipments/Hands.cs b/code/items/equipments/Hands.cs index 1c96939ec..730f7ea81 100644 --- a/code/items/equipments/Hands.cs +++ b/code/items/equipments/Hands.cs @@ -32,11 +32,11 @@ public partial class Hands : Equipment private bool IsHoldingEntity => GrabbedEntity != null && (GrabbedEntity?.IsHolding ?? false); private bool IsPushingEntity = false; - public override void Simulate(Client client) + public override void Simulate(IClient client) { base.Simulate(client); - if (!IsServer || Owner is not Player player) + if (!Game.IsServer || Owner is not Player player) { return; } @@ -130,7 +130,7 @@ private void TryGrabEntity(Player player) TraceResult tr = Trace.Ray(eyePos, eyePos + eyeDir * MAX_INTERACT_DISTANCE) .UseHitboxes() .Ignore(player) - .HitLayer(CollisionLayer.Debris) + //.HitLayer(CollisionLayer.Debris) .EntitiesOnly() .Run(); @@ -186,21 +186,21 @@ protected override void OnDestroy() base.OnDestroy(); } - public override void SimulateAnimator(PawnAnimator anim) + public override void SimulateAnimator(CitizenAnimationHelper anim) { - if (!IsServer || IsPushingEntity) + if (!Game.IsServer || IsPushingEntity) { return; } if (IsHoldingEntity) { - anim.SetAnimParameter("holdtype", 4); - anim.SetAnimParameter("holdtype_handedness", 0); + anim.HoldType = CitizenAnimationHelper.HoldTypes.HoldItem; + anim.Handedness = CitizenAnimationHelper.Hand.Both; } else { - anim.SetAnimParameter("holdtype", 0); + anim.HoldType = CitizenAnimationHelper.HoldTypes.None; } } } diff --git a/code/items/equipments/entities/C4Entity.cs b/code/items/equipments/entities/C4Entity.cs index 45c59d393..fe31933f3 100644 --- a/code/items/equipments/entities/C4Entity.cs +++ b/code/items/equipments/entities/C4Entity.cs @@ -93,7 +93,7 @@ public override void Spawn() SetupPhysicsFromModel(PhysicsMotionType.Dynamic); } - [Event.Frame] + //[Event.Frame] private void UpdateDisplayTransform() { if (!CreatedDisplay) @@ -228,7 +228,7 @@ private async Task Explode() float force = BOMB_FORCE * distanceMul * ent.PhysicsBody.Mass; Vector3 forceDir = (targetPos - sourcePos).Normal; - ent.TakeDamage(DamageInfo.Explosion(sourcePos, forceDir * force, damage) + ent.TakeDamage(DamageInfo.FromExplosion(sourcePos, forceDir * force, damage) .WithAttacker(this)); } } @@ -299,7 +299,7 @@ public static void PickUp(int c4EntityIdent, int playerIdent) public void HintTick(Player player) { - if (IsClient) + if (Game.IsClient) { return; } @@ -347,7 +347,7 @@ public void ClientOpenC4Menu(C4Entity c4Entity) [ClientRpc] public void ClientCloseC4Menu(C4Entity c4Entity) { - Host.AssertClient(); + Game.AssertClient(); CloseC4Menu(c4Entity); } diff --git a/code/items/equipments/entities/HealthstationEntity.cs b/code/items/equipments/entities/HealthstationEntity.cs index f815a75f0..a580cdc2f 100644 --- a/code/items/equipments/entities/HealthstationEntity.cs +++ b/code/items/equipments/entities/HealthstationEntity.cs @@ -63,7 +63,7 @@ private bool HealPlayer(Player player) public void HintTick(Player player) { - if (IsClient || player.LifeState != LifeState.Alive) + if (Game.IsClient || player.LifeState != LifeState.Alive) { return; } diff --git a/code/items/perks/Perk.cs b/code/items/perks/Perk.cs index e1a838ad8..908bb2a62 100644 --- a/code/items/perks/Perk.cs +++ b/code/items/perks/Perk.cs @@ -27,7 +27,7 @@ public void Equip(Player player) public virtual void OnEquip() { - if (Host.IsClient) + if (Game.IsClient) { InventoryWrapper.Instance.Effects.AddEffect(this); } @@ -47,12 +47,12 @@ public virtual void OnRemove() public void Delete() { - if (Host.IsClient) + if (Game.IsClient) { InventoryWrapper.Instance.Effects.RemoveEffect(this); } } - public virtual void Simulate(Client owner) { } + public virtual void Simulate(IClient owner) { } } } diff --git a/code/items/perks/radar/Radar.cs b/code/items/perks/radar/Radar.cs index a5537ef4c..cc35a617f 100644 --- a/code/items/perks/radar/Radar.cs +++ b/code/items/perks/radar/Radar.cs @@ -29,7 +29,7 @@ public struct RadarPointData public override void OnRemove() { - if (Host.IsClient) + if (Game.IsClient) { ClearRadarPoints(); } @@ -39,7 +39,7 @@ public override void OnRemove() private void UpdatePositions() { - if (Host.IsServer) + if (Game.IsServer) { if (Info.Owner is not Player owner) { @@ -50,7 +50,7 @@ private void UpdatePositions() foreach (Player player in Utils.GetAlivePlayers()) { - if (player.Client.PlayerId == owner.Client.PlayerId) + if (player.Client.SteamId == owner.Client.SteamId) { continue; } @@ -93,7 +93,7 @@ public override void OnEquip() { base.OnEquip(); - if (Host.IsServer) + if (Game.IsServer) { UpdatePositions(); } @@ -101,7 +101,7 @@ public override void OnEquip() public override void OnCountdown() { - if (Host.IsServer) + if (Game.IsServer) { UpdatePositions(); } @@ -120,7 +120,7 @@ private void ClearRadarPoints() [ClientRpc] public static void ClientSendRadarPositions(Player player, RadarPointData[] points) { - if (!player.IsValid() || player != Local.Pawn) + if (!player.IsValid() || player != Game.LocalPawn) { return; } diff --git a/code/items/perks/radar/RadarPoint.cs b/code/items/perks/radar/RadarPoint.cs index cb7542817..a75e96273 100644 --- a/code/items/perks/radar/RadarPoint.cs +++ b/code/items/perks/radar/RadarPoint.cs @@ -41,7 +41,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/items/weapons/NewtonLauncher.cs b/code/items/weapons/NewtonLauncher.cs index c8d5f556e..22118410c 100644 --- a/code/items/weapons/NewtonLauncher.cs +++ b/code/items/weapons/NewtonLauncher.cs @@ -73,7 +73,7 @@ public void ReleaseCharge() { (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); - if (IsClient) + if (Game.IsClient) { ShootEffects(GetClipInfoIndex(Primary)); } @@ -84,15 +84,15 @@ public void ReleaseCharge() IsCharging = false; } - public override void ShootBullet(float spread, float force, float damage, float bulletSize, string impactEffect = null, DamageFlags damageType = DamageFlags.Crush) + public override void ShootBullet(float spread, float force, float damage, float bulletSize, string impactEffect = null, params string[] damageTags) { - Vector3 forward = Owner.EyeRotation.Forward; + Vector3 forward = Owner.AimRay.Forward; forward += (Vector3.Random + Vector3.Random + Vector3.Random + Vector3.Random) * spread * 0.25f; forward = forward.Normal; - foreach (TraceResult trace in TraceBullet(Owner.EyePosition, Owner.EyePosition + forward * 5000, bulletSize)) + foreach (TraceResult trace in TraceBullet(Owner.AimRay.Position, Owner.AimRay.Position + forward * 5000, bulletSize)) { - if (!IsServer || !trace.Entity.IsValid() || trace.Entity.IsWorld) + if (!Game.IsServer || !trace.Entity.IsValid() || trace.Entity.IsWorld) { continue; } @@ -101,7 +101,7 @@ public override void ShootBullet(float spread, float force, float damage, float { DamageInfo damageInfo = new DamageInfo() .WithPosition(trace.EndPosition) - .WithFlag(damageType) + .WithTags(damageTags ?? new[] { "crush" }) .WithForce(forward * 100f * force) .UsingTraceResult(trace) .WithAttacker(Owner) @@ -120,7 +120,7 @@ public override void ShootBullet(float spread, float force, float damage, float } } - public override void Simulate(Client owner) + public override void Simulate(IClient owner) { base.Simulate(owner); diff --git a/code/items/weapons/base/ClipInfo.cs b/code/items/weapons/base/ClipInfo.cs index 2e20fbc40..f520f25f5 100644 --- a/code/items/weapons/base/ClipInfo.cs +++ b/code/items/weapons/base/ClipInfo.cs @@ -82,7 +82,7 @@ public virtual int BulletsPerReload public virtual string ImpactEffect { get; set; } = null; - public virtual DamageFlags DamageType { get; set; } = DamageFlags.Bullet; + //public virtual DamageFlags DamageType { get; set; } = DamageFlags.Bullet; public virtual Dictionary ShootEffectList { get; set; } = new() { @@ -92,5 +92,6 @@ public virtual int BulletsPerReload public virtual ShakeEffect ShakeEffect { get; set; } = null; public virtual FiringType FiringType { get; set; } = FiringType.SEMI; + public string[] DamageType { get; internal set; } } } diff --git a/code/items/weapons/base/MeleeWeapon.cs b/code/items/weapons/base/MeleeWeapon.cs index c50040da2..57fcab441 100644 --- a/code/items/weapons/base/MeleeWeapon.cs +++ b/code/items/weapons/base/MeleeWeapon.cs @@ -8,10 +8,10 @@ public abstract partial class MeleeWeapon : Weapon public virtual void MeleeStrike(float damage, float force) { - Vector3 forward = Owner.EyeRotation.Forward; + Vector3 forward = Owner.AimRay.Forward; forward = forward.Normal; - foreach (TraceResult tr in TraceBullet(Owner.EyePosition, Owner.EyePosition + forward * MeleeDistance, 10f)) + foreach (TraceResult tr in TraceBullet(Owner.AimRay.Position, Owner.AimRay.Position + forward * MeleeDistance, 10f)) { if (!tr.Entity.IsValid()) { @@ -20,7 +20,7 @@ public virtual void MeleeStrike(float damage, float force) tr.Surface.DoBulletImpact(tr); - if (!IsServer) + if (!Game.IsServer) { continue; } @@ -41,7 +41,7 @@ public override void Attack(ClipInfo clipInfo) { (Owner as AnimatedEntity).SetAnimParameter("b_attack", true); - if (IsClient) + if (Game.IsClient) { ShootEffects(GetClipInfoIndex(clipInfo)); } diff --git a/code/items/weapons/base/ViewModel.cs b/code/items/weapons/base/ViewModel.cs index 6077e6e66..4957f26d1 100644 --- a/code/items/weapons/base/ViewModel.cs +++ b/code/items/weapons/base/ViewModel.cs @@ -7,29 +7,5 @@ namespace TTTReborn.Items public partial class ViewModel : BaseViewModel { private float _walkBob = 0; - - public override void PostCameraSetup(ref CameraSetup camSetup) - { - base.PostCameraSetup(ref camSetup); - - AddCameraEffects(ref camSetup); - } - - private void AddCameraEffects(ref CameraSetup camSetup) - { - Rotation = Local.Pawn.EyeRotation; - - float speed = Owner.Velocity.Length.LerpInverse(0, 320); - Vector3 left = camSetup.Rotation.Left; - Vector3 up = camSetup.Rotation.Up; - - if (Owner.GroundEntity != null) - { - _walkBob += Time.Delta * 25.0f * speed; - } - - Position += up * MathF.Sin(_walkBob) * speed * -1; - Position += left * MathF.Sin(_walkBob * 0.6f) * speed * -0.5f; - } } } diff --git a/code/items/weapons/base/Weapon.Attack.cs b/code/items/weapons/base/Weapon.Attack.cs index f551edd05..4bfd28cde 100644 --- a/code/items/weapons/base/Weapon.Attack.cs +++ b/code/items/weapons/base/Weapon.Attack.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Sandbox; @@ -70,7 +71,7 @@ public virtual void Attack(ClipInfo clipInfo) PlaySound(clipInfo.ShootSound).SetPosition(Position).SetVolume(0.8f); } - Rand.SetSeed(Time.Tick); + Game.SetRandomSeed(Time.Tick); // ?? ShootEffects(GetClipInfoIndex(clipInfo)); @@ -96,7 +97,7 @@ public virtual void ResetBurstFireCount(ClipInfo clipInfo, InputButton inputButt [ClientRpc] public virtual void ShootEffects(int clipInfoIndex) { - Host.AssertClient(); + Game.AssertClient(); if (clipInfoIndex < 0 || clipInfoIndex >= ClipInfos.Length) { @@ -135,13 +136,13 @@ public virtual void ShootBullet(ClipInfo clipInfo) ShootBullet(clipInfo.Spread, clipInfo.Force, clipInfo.Damage, clipInfo.BulletSize, clipInfo.ImpactEffect, clipInfo.DamageType); } - public virtual void ShootBullet(float spread, float force, float damage, float bulletSize, string impactEffect = null, DamageFlags damageType = DamageFlags.Bullet) + public virtual void ShootBullet(float spread, float force, float damage, float bulletSize, string impactEffect = null, params string[] damageType) { - Vector3 forward = Owner.EyeRotation.Forward; + Vector3 forward = Owner.AimRay.Forward; forward += (Vector3.Random + Vector3.Random + Vector3.Random + Vector3.Random) * spread * 0.25f; forward = forward.Normal; - foreach (TraceResult trace in TraceBullet(Owner.EyePosition, Owner.EyePosition + forward * BulletRange, bulletSize)) + foreach (TraceResult trace in TraceBullet(Owner.AimRay.Position, Owner.AimRay.Position + forward * BulletRange, bulletSize)) { Vector3 endPos = trace.EndPosition + trace.Direction * bulletSize; @@ -154,7 +155,7 @@ public virtual void ShootBullet(float spread, float force, float damage, float b Particles.Create(impactEffect, endPos)?.SetForward(0, trace.Normal); } - if (!IsServer || !trace.Entity.IsValid()) + if (!Game.IsServer || !trace.Entity.IsValid()) { continue; } @@ -168,23 +169,22 @@ public virtual void ShootBullet(float spread, float force, float damage, float b public virtual IEnumerable TraceBullet(Vector3 start, Vector3 end, float radius = 2.0f) { - bool InWater = Sandbox.Internal.GlobalGameNamespace.Map.Physics.IsPointWater(start); + bool InWater = FindInSphere(start, 0.1f).Any(e => e is Water); //Game.PhysicsWorld //.Physics.IsPointWater(start); yield return Trace.Ray(start, end) .UseHitboxes() - .HitLayer(CollisionLayer.Water, !InWater) - .HitLayer(CollisionLayer.Debris) + .WorldAndEntities() .Ignore(Owner) .Ignore(this) .Size(radius) .Run(); } - public virtual void DealDamage(Entity target, Vector3 position, Vector3 force, float damage, DamageFlags damageType, TraceResult? traceResult = null) + public virtual void DealDamage(Entity target, Vector3 position, Vector3 force, float damage, string[] damageTags, TraceResult? traceResult = null) { DamageInfo damageInfo = new DamageInfo() .WithPosition(position) - .WithFlag(damageType) + .WithTags(damageTags) .WithForce(force) .WithAttacker(Owner) .WithWeapon(this); diff --git a/code/items/weapons/base/Weapon.Pickup.cs b/code/items/weapons/base/Weapon.Pickup.cs index 258b98506..549b6802b 100644 --- a/code/items/weapons/base/Weapon.Pickup.cs +++ b/code/items/weapons/base/Weapon.Pickup.cs @@ -60,7 +60,7 @@ public override void OnCarryDrop(Entity dropper) public void HintTick(Player player) { - if (!IsServer || player.LifeState != LifeState.Alive) + if (!Game.IsServer || player.LifeState != LifeState.Alive) { return; } diff --git a/code/items/weapons/base/Weapon.cs b/code/items/weapons/base/Weapon.cs index 19f2b5a27..91dc91a03 100644 --- a/code/items/weapons/base/Weapon.cs +++ b/code/items/weapons/base/Weapon.cs @@ -83,7 +83,7 @@ public override void Spawn() public static float GetRealRPM(int rpm) => 60f / rpm; - public override void Simulate(Client owner) + public override void Simulate(IClient owner) { if (TimeSinceDeployed < WeaponInfo.DeployTime) { @@ -100,14 +100,14 @@ public override void Simulate(Client owner) if (type != null) { - if (IsServer) + if (Game.IsServer) { Ammo ammoBox = Utils.GetObjectByType(type); ammoBox.LastDropOwner = Owner; ammoBox.TimeSinceLastDrop = 0f; - ammoBox.Position = Owner.EyePosition + Owner.EyeRotation.Forward * AMMO_DROP_POSITION_OFFSET; - ammoBox.Rotation = Owner.EyeRotation; - ammoBox.Velocity = Owner.EyeRotation.Forward * AMMO_DROP_VELOCITY; + ammoBox.Position = Owner.AimRay.Position + Owner.AimRay.Forward * AMMO_DROP_POSITION_OFFSET; + ammoBox.Rotation = Owner.Rotation; + ammoBox.Velocity = Owner.AimRay.Forward * AMMO_DROP_VELOCITY; ammoBox.SetCurrentAmmo(ClipAmmo); } @@ -165,22 +165,22 @@ public override void Simulate(Client owner) // TODO Zoom } - public static int GetHoldType(CarriableCategories category) => category switch + public static CitizenAnimationHelper.HoldTypes GetHoldType(CarriableCategories category) => category switch { - CarriableCategories.Melee => 0, - CarriableCategories.Pistol => 1, - CarriableCategories.SMG or CarriableCategories.Sniper => 2, - CarriableCategories.Shotgun => 3, - CarriableCategories.OffensiveEquipment => 0, - CarriableCategories.UtilityEquipment => 0, - CarriableCategories.Grenade => 0, + CarriableCategories.Melee => CitizenAnimationHelper.HoldTypes.None, + CarriableCategories.Pistol => CitizenAnimationHelper.HoldTypes.Pistol, + CarriableCategories.SMG or CarriableCategories.Sniper => CitizenAnimationHelper.HoldTypes.Rifle, + CarriableCategories.Shotgun => CitizenAnimationHelper.HoldTypes.Shotgun, + CarriableCategories.OffensiveEquipment => CitizenAnimationHelper.HoldTypes.None, + CarriableCategories.UtilityEquipment => CitizenAnimationHelper.HoldTypes.None, + CarriableCategories.Grenade => CitizenAnimationHelper.HoldTypes.None, _ => 0, }; - public override void SimulateAnimator(PawnAnimator anim) + public override void SimulateAnimator(CitizenAnimationHelper anim) { - anim.SetAnimParameter("holdtype", GetHoldType(CarriableInfo.Category)); - anim.SetAnimParameter("aim_body_weight", 1.0f); + anim.HoldType = GetHoldType(CarriableInfo.Category); + anim.AimBodyWeight = 1.0f; } public int AvailableAmmo(ClipInfo clipInfo) @@ -234,7 +234,7 @@ public bool GiveAmmo(ClipInfo clipInfo, int amount) public override void CreateViewModel() { - Host.AssertClient(); + Game.AssertClient(); if (string.IsNullOrEmpty(ViewModelPath)) { @@ -268,28 +268,28 @@ public virtual int GetClipInfoIndex(ClipInfo clipInfo) public virtual T GetClipInfoMax(string propertyName) where T : IComparable { - if (ClipInfos.Length < 1) - { + //if (ClipInfos.Length < 1) + //{ return default; - } + //} - PropertyInfo propertyInfo = ClipInfos[0].GetType().GetProperty(propertyName); - T highest = (T) propertyInfo.GetValue(ClipInfos[0], null); + //PropertyInfo propertyInfo = ClipInfos[0].GetType().GetProperty(propertyName); + //T highest = (T) propertyInfo.GetValue(ClipInfos[0], null); - if (ClipInfos.Length > 1) - { - for (int i = 1; i < ClipInfos.Length; i++) - { - T tmp = (T) propertyInfo.GetValue(ClipInfos[i], null); + //if (ClipInfos.Length > 1) + //{ + // for (int i = 1; i < ClipInfos.Length; i++) + // { + // T tmp = (T) propertyInfo.GetValue(ClipInfos[i], null); - if (tmp.CompareTo(highest) > 0) - { - highest = tmp; - } - } - } + // if (tmp.CompareTo(highest) > 0) + // { + // highest = tmp; + // } + // } + //} - return highest; + //return highest; } } } diff --git a/code/lang/TTTLanguage.cs b/code/lang/TTTLanguage.cs index 8f7738ca2..8170933b9 100644 --- a/code/lang/TTTLanguage.cs +++ b/code/lang/TTTLanguage.cs @@ -2,6 +2,8 @@ using System.IO; using System.Text.Json.Serialization; +using System.Linq; + using Sandbox; using TTTReborn.UI; @@ -17,7 +19,7 @@ public partial class Settings namespace Categories { - using Globalization; + using TTTReborn.Globalization; public partial class General { @@ -71,39 +73,46 @@ public static void Load() { Languages.Clear(); - foreach (string file in FileSystem.Mounted.FindFile("/lang/packs/", "*.json", false)) + foreach (string file in FileSystem.Mounted.FindFile("/lang", "*.json", false)) { string name = Path.GetFileNameWithoutExtension(file); - string json = FileSystem.Mounted.ReadAllText($"/lang/packs/{file}"); + string json = FileSystem.Mounted.ReadAllText($"/lang/{file}"); Language language = new(name, json); + string key = language.Data.Code ?? name; - Languages.Add(language.Data.Code ?? name, language); - - Log.Info($"Added language pack: '{name}'."); + if (!Languages.ContainsKey(key)) + { + Languages.Add(key, language); + Log.Info($"Added language pack: '{name}'."); + } else + { + Log.Warning($"Tried adding language pack for '{key}' again!"); + } } ActiveLanguage = GetLanguageByCode(FALLBACK_LANGUAGE); - FileSystem.Mounted.Watch().OnChangedFile += (fileName) => - { - foreach (string file in FileSystem.Mounted.FindFile("/lang/packs/", "*.json", false)) - { - if (fileName.Equals(file)) - { - Load(); - - // TODO reload HUD - - break; - } - } - }; + // FIXME FileSystem.Mounted.Watch() is not avilable anymore + //FileSystem.Mounted.Watch().OnChangedFile += (fileName) => + //{ + // foreach (string file in FileSystem.Mounted.FindFile("/lang/packs/", "*.json", false)) + // { + // if (fileName.Equals(file)) + // { + // Load(); + + // // TODO reload HUD + + // break; + // } + // } + //}; } public static Language GetLanguageByCode(string name) { - Language lang = null; + Language lang = default; if (Languages != null && !string.IsNullOrEmpty(name)) { @@ -140,7 +149,7 @@ public static void OnChangeLanguageSettings() namespace TTTReborn { - using Globalization; + using TTTReborn.Globalization; public partial class Player { diff --git a/code/map/ForceWin.cs b/code/map/ForceWin.cs index 105601784..b31fb4f58 100644 --- a/code/map/ForceWin.cs +++ b/code/map/ForceWin.cs @@ -56,11 +56,11 @@ public void Force(Entity activator) private static void ForceEndRound(Team team) { - if (Gamemode.Game.Instance.Round is InProgressRound) + if (Gamemode.TTTGame.Instance.Round is InProgressRound) { //Logic taken from InProgressRound.LoadPostRound. Should reference the function instead? NetworkableGameEvent.RegisterNetworked(new Events.Game.FinishEvent(team)); - Gamemode.Game.Instance.ForceRoundChange(new PostRound()); + Gamemode.TTTGame.Instance.ForceRoundChange(new PostRound()); } } } diff --git a/code/map/LogicAssigned.cs b/code/map/LogicAssigned.cs index cdbe36114..ab9f6ea60 100644 --- a/code/map/LogicAssigned.cs +++ b/code/map/LogicAssigned.cs @@ -32,7 +32,7 @@ public string CheckValue [Input] public void Activate(Entity activator) { - if (activator is Player player && Gamemode.Game.Instance.Round is InProgressRound) + if (activator is Player player && Gamemode.TTTGame.Instance.Round is InProgressRound) { if (player.Role.Name.Equals(CheckValue) || player.Team.Name.Equals(CheckValue)) { diff --git a/code/map/LogicDoorEntity.cs b/code/map/LogicDoorEntity.cs index 8a754571a..29b3653ff 100644 --- a/code/map/LogicDoorEntity.cs +++ b/code/map/LogicDoorEntity.cs @@ -34,7 +34,7 @@ public string CheckValue [Input] public void Activate(Entity activator) { - if (Gamemode.Game.Instance.Round is InProgressRound && IsUsable(activator)) + if (Gamemode.TTTGame.Instance.Round is InProgressRound && IsUsable(activator)) { Toggle(activator); diff --git a/code/map/MapHandler.cs b/code/map/MapHandler.cs index 3dc62ad0f..9b58724cd 100644 --- a/code/map/MapHandler.cs +++ b/code/map/MapHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Sandbox; @@ -37,8 +38,8 @@ public void Reset() player.Inventory.DropAll(); } - Sandbox.Internal.GlobalGameNamespace.Map.Reset(Game.DefaultCleanupFilter); - Sandbox.Internal.Decals.RemoveFromWorld(); + Game.ResetMap(Array.Empty()); ;//Gamemode.TTTGame.DefaultCleanupFilter); + // Sandbox.Internal.Decals.RemoveFromWorld(); Ammos.Clear(); Weapons.Clear(); diff --git a/code/map/MapSelectionHandler.cs b/code/map/MapSelectionHandler.cs index 063ae4eed..11879478d 100644 --- a/code/map/MapSelectionHandler.cs +++ b/code/map/MapSelectionHandler.cs @@ -31,7 +31,7 @@ public async Task Load() private static async Task> GetTTTMapNames() { - Package result = await Package.Fetch(Global.GameIdent, true); + Package result = await Package.Fetch(Game.Server.GameIdent, true); return result.GetMeta>("MapList"); } diff --git a/code/map/logicbutton/LogicButton.cs b/code/map/logicbutton/LogicButton.cs index 37f78f5cf..47135e529 100644 --- a/code/map/logicbutton/LogicButton.cs +++ b/code/map/logicbutton/LogicButton.cs @@ -56,7 +56,7 @@ public LogicButton() { Transmit = TransmitType.Always; // Make sure our clients receive the button entity. - if (IsServer) + if (Game.IsServer) { Reset(); } @@ -65,7 +65,7 @@ public LogicButton() // (Re)initialize our variables to default. Runs at preround as well as during construction public void Reset() { - Host.AssertServer(); + Game.AssertServer(); IsLocked = Locked; IsDelayed = false; @@ -75,7 +75,7 @@ public void Reset() public void OnSecond() // Hijack the round timer to tick on every second. No reason to tick any faster. { - Host.AssertServer(); + Game.AssertServer(); if (HasDelay && IsDelayed && !IsRemoved && NextUse <= 0) // Check timer if button has delayed, no reason to check if button is removed. { @@ -86,7 +86,7 @@ public void OnSecond() // Hijack the round timer to tick on every second. No rea [Input] public void Press(Player activator) { - Host.AssertServer(); + Game.AssertServer(); if (!IsDisabled) // Make sure button is not delayed, locked or removed. { @@ -113,7 +113,7 @@ public void Press(Player activator) [Input] public void Lock() { - Host.AssertServer(); + Game.AssertServer(); IsLocked = true; } @@ -121,7 +121,7 @@ public void Lock() [Input] public void Unlock() { - Host.AssertServer(); + Game.AssertServer(); IsLocked = false; } @@ -129,7 +129,7 @@ public void Unlock() [Input] public void Toggle() { - Host.AssertServer(); + Game.AssertServer(); IsLocked = !IsLocked; } diff --git a/code/map/logicbutton/LogicButtonPoint.cs b/code/map/logicbutton/LogicButtonPoint.cs index b390d3d18..0d27ead03 100644 --- a/code/map/logicbutton/LogicButtonPoint.cs +++ b/code/map/logicbutton/LogicButtonPoint.cs @@ -53,7 +53,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/player/Player.AFK.cs b/code/player/Player.AFK.cs index e50f68307..75a3b6b01 100644 --- a/code/player/Player.AFK.cs +++ b/code/player/Player.AFK.cs @@ -29,7 +29,7 @@ private void TickAFKSystem() } bool isAnyKeyPressed = Buttons.Any(button => Input.Down(button)); - bool isMouseMoving = Input.MouseDelta != Vector3.Zero; + bool isMouseMoving = Input.MouseDelta != Vector2.Zero; if (isAnyKeyPressed || isMouseMoving) { @@ -44,13 +44,13 @@ private void TickAFKSystem() if (shouldKick) { - Log.Warning($"Player ID: {Client.PlayerId}, Name: {Client.Name} was kicked from the server for being AFK."); + Log.Warning($"Player ID: {Client.SteamId}, Name: {Client.Name} was kicked from the server for being AFK."); Client.Kick(); } else { - Log.Warning($"Player ID: {Client.PlayerId}, Name: {Client.Name} was moved to spectating for being AFK."); + Log.Warning($"Player ID: {Client.SteamId}, Name: {Client.Name} was moved to spectating for being AFK."); ToggleForcedSpectator(); } diff --git a/code/player/Player.Commands.Client.cs b/code/player/Player.Commands.Client.cs index 5e49ef569..fe8157fac 100644 --- a/code/player/Player.Commands.Client.cs +++ b/code/player/Player.Commands.Client.cs @@ -10,7 +10,7 @@ public partial class Player [ConCmd.Client(Name = "ttt_playerids", Help = "Returns a list of all players (clients) and their associated IDs")] public static void PlayerID() { - List playerList = Client.All.ToList(); + List playerList = Game.Clients.ToList(); for (int i = 0; i < playerList.Count; i++) { diff --git a/code/player/Player.Commands.Server.cs b/code/player/Player.Commands.Server.cs index 0348da296..3faadbd25 100644 --- a/code/player/Player.Commands.Server.cs +++ b/code/player/Player.Commands.Server.cs @@ -14,7 +14,7 @@ public partial class Player { private static Player GetPlayerById(int id) { - List playerList = Client.All.ToList(); + List playerList = Game.Clients.ToList(); if (playerList.Count <= id) { @@ -32,10 +32,10 @@ private static Player GetPlayerById(int id) [ConCmd.Server(Name = "ttt_respawn", Help = "Respawns the current player or the player with the given id")] public static void RespawnPlayer(string id = null) { - if (!ConsoleSystem.Caller.HasPermission("respawn")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("respawn")) + //{ + // return; + //} Player player; @@ -109,12 +109,12 @@ public static void RequestItem(string itemName) [ConCmd.Server(Name = "ttt_setrole")] public static void SetRole(string roleName, string id = null) { - if (!ConsoleSystem.Caller.HasPermission("role")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("role")) + //{ + // return; + //} - if (Gamemode.Game.Instance.Round is not Rounds.InProgressRound) + if (Gamemode.TTTGame.Instance.Round is not Rounds.InProgressRound) { if (id == null) { @@ -187,12 +187,12 @@ public static void ToggleForceSpectator() [ConCmd.Server(Name = "ttt_force_restart")] public static void ForceRestart() { - if (!ConsoleSystem.Caller.HasPermission("restart")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("restart")) + //{ + // return; + //} - Gamemode.Game.Instance.ChangeRound(new PreRound()); + Gamemode.TTTGame.Instance.ChangeRound(new PreRound()); Log.Info($"{ConsoleSystem.Caller.Name} forced a restart."); } diff --git a/code/player/Player.Damage.cs b/code/player/Player.Damage.cs index eefc70396..0539f2b37 100644 --- a/code/player/Player.Damage.cs +++ b/code/player/Player.Damage.cs @@ -62,7 +62,7 @@ public void SetHealth(float health) public override void TakeDamage(DamageInfo info) { - LastDamageWasHeadshot = GetHitboxGroup(info.HitboxIndex) == (int) HitboxGroup.Head; + LastDamageWasHeadshot = info.BoneIndex == (int) HitboxGroup.Head; if (LastDamageWasHeadshot) { @@ -71,7 +71,7 @@ public override void TakeDamage(DamageInfo info) // TODO this should be handled by hooks and in the item itself // If player has bodyarmor, was not shot in the head, and was shot by a bullet, reduce damage by 30%. - if (Inventory.Perks.Has(Utils.GetLibraryName(typeof(BodyArmor))) && !LastDamageWasHeadshot && (info.Flags & DamageFlags.Bullet) == DamageFlags.Bullet) + if (Inventory.Perks.Has(Utils.GetLibraryName(typeof(BodyArmor))) && !LastDamageWasHeadshot && info.HasTag("bullet")) { info.Damage *= ArmorReductionPercentage; } @@ -84,7 +84,7 @@ public override void TakeDamage(DamageInfo info) { LastDistanceToAttacker = Utils.SourceUnitsToMeters(Position.Distance(attacker.Position)); - if (Gamemode.Game.Instance.Round is not (Rounds.InProgressRound or Rounds.PostRound)) + if (Gamemode.TTTGame.Instance.Round is not (Rounds.InProgressRound or Rounds.PostRound)) { return; } @@ -99,17 +99,17 @@ public override void TakeDamage(DamageInfo info) NetworkableGameEvent.RegisterNetworked(client, new Events.Player.TakeDamageEvent(this, info.Damage, info.Attacker)); // Play pain sounds - if ((info.Flags & DamageFlags.Fall) == DamageFlags.Fall) + if (info.HasTag("fall")) { PlaySound("fall").SetVolume(0.5f).SetPosition(info.Position); } - else if ((info.Flags & DamageFlags.Bullet) == DamageFlags.Bullet) + else if (info.HasTag("bullet")) { - PlaySound("grunt" + Rand.Int(1, 4)).SetVolume(0.4f).SetPosition(info.Position); + PlaySound("grunt" + Game.Random.Int(1, 4)).SetVolume(0.4f).SetPosition(info.Position); } // Register player damage with the Karma system - Gamemode.Game.Instance?.Karma?.RegisterPlayerDamage(info.Attacker as Player, this, info.Damage); + Gamemode.TTTGame.Instance?.Karma?.RegisterPlayerDamage(info.Attacker as Player, this, info.Damage); _lastDamageInfo = info; diff --git a/code/player/Player.Flashlight.cs b/code/player/Player.Flashlight.cs index cea2da0d2..3cde6fa14 100644 --- a/code/player/Player.Flashlight.cs +++ b/code/player/Player.Flashlight.cs @@ -52,7 +52,7 @@ public void ShowFlashlight(bool shouldShow, bool playSounds = true) if (IsFlashlightOn) { - if (IsServer) + if (Game.IsServer) { _worldFlashlight.TurnOff(); } @@ -62,7 +62,7 @@ public void ShowFlashlight(bool shouldShow, bool playSounds = true) } } - if (IsServer) + if (Game.IsServer) { using (Prediction.Off()) { @@ -74,7 +74,7 @@ public void ShowFlashlight(bool shouldShow, bool playSounds = true) { if (!HasFlashlightEntity) { - if (IsServer) + if (Game.IsServer) { _worldFlashlight = new() { @@ -97,7 +97,7 @@ public void ShowFlashlight(bool shouldShow, bool playSounds = true) } else { - if (IsServer) + if (Game.IsServer) { _worldFlashlight.SetParent(null); _worldFlashlight.Rotation = EyeRotation; @@ -111,12 +111,12 @@ public void ShowFlashlight(bool shouldShow, bool playSounds = true) } } - if (IsServer && playSounds) + if (Game.IsServer && playSounds) { PlaySound("flashlight-on"); } } - else if (IsServer && playSounds) + else if (Game.IsServer && playSounds) { PlaySound("flashlight-off"); } @@ -134,23 +134,23 @@ private void TickPlayerFlashlight() if (IsFlashlightOn) { - _worldFlashlight.Rotation = Rotation.Slerp(_worldFlashlight.Rotation, Input.Rotation, SMOOTH_SPEED); - _worldFlashlight.Position = Vector3.Lerp(_worldFlashlight.Position, EyePosition + Input.Rotation.Forward * FLASHLIGHT_DISTANCE, SMOOTH_SPEED); + _worldFlashlight.Rotation = Rotation.Slerp(_worldFlashlight.Rotation, Input.AnalogLook.ToRotation(), SMOOTH_SPEED); ; + _worldFlashlight.Position = Vector3.Lerp(_worldFlashlight.Position, EyePosition + Input.AnalogLook.Forward * FLASHLIGHT_DISTANCE, SMOOTH_SPEED); } } - public override void PostCameraSetup(ref CameraSetup camSetup) - { - camSetup.ZNear = 0.1f; + //public override void PostCameraSetup(ref CameraSetup camSetup) + //{ + // camSetup.ZNear = 0.1f; - base.PostCameraSetup(ref camSetup); + // base.PostCameraSetup(ref camSetup); - if (IsFlashlightOn) - { - _viewFlashlight.Rotation = Input.Rotation; - _viewFlashlight.Position = EyePosition + Input.Rotation.Forward * FLASHLIGHT_DISTANCE; - } - } + // if (IsFlashlightOn) + // { + // _viewFlashlight.Rotation = Input.AnalogLook.ToRotation(); + // _viewFlashlight.Position = EyePosition + Input.AnalogLook.Forward * FLASHLIGHT_DISTANCE; + // } + //} } [HideInEditor] diff --git a/code/player/Player.Hints.cs b/code/player/Player.Hints.cs index 552e6b4d9..c6447be0c 100644 --- a/code/player/Player.Hints.cs +++ b/code/player/Player.Hints.cs @@ -19,12 +19,12 @@ public partial class Player private void TickEntityHints() { - if (CameraMode is ThirdPersonSpectateCamera) - { - DeleteHint(); + //if (CameraMode is ThirdPersonSpectateCamera) + //{ + // DeleteHint(); - return; - } + // return; + //} IEntityHint hint = IsLookingAtHintableEntity(MAX_HINT_DISTANCE); Entity target = hint as Entity; @@ -55,14 +55,14 @@ private void TickEntityHints() { hint.HintTick(this); - if (IsClient) + if (Game.IsClient) { _currentHintPanel.UpdateHintPanel(hint.TextOnTick); } } else if (target is DoorEntity doorEntity) { - if (IsClient) + if (Game.IsClient) { TranslationData translationData; @@ -98,13 +98,13 @@ private void TickEntityHints() DeleteHint(); - if (IsClient) + if (Game.IsClient) { if ((hint == null || hint.ShowGlow) && target is ModelEntity model && model.IsValid()) { Glow glow = model.Components.GetOrCreate(); glow.Color = Color.White; // TODO: Let's let people change this in their settings. - glow.Active = true; + glow.Enabled = true; } if (hint != null) @@ -145,7 +145,7 @@ private void TickEntityHints() private void DeleteHint() { - if (IsClient) + if (Game.IsClient) { if (_currentTarget != null && _currentTarget is ModelEntity model && model.IsValid()) { @@ -153,7 +153,7 @@ private void DeleteHint() if (glow != null) { - glow.Active = false; + glow.Enabled = false; } } diff --git a/code/player/Player.Lookup.cs b/code/player/Player.Lookup.cs index 20544d37b..7b6127695 100644 --- a/code/player/Player.Lookup.cs +++ b/code/player/Player.Lookup.cs @@ -22,16 +22,16 @@ public Trace GetLookingTrace(float distance) { Trace trace; - if (IsClient) + if (Game.IsClient) { - trace = Trace.Ray(CameraMode.Position, CameraMode.Position + CameraMode.Rotation.Forward * distance); + trace = Trace.Ray(Client.AimRay.Position, Client.AimRay.Position + Client.AimRay.Forward * distance); } else { trace = Trace.Ray(EyePosition, EyePosition + EyeRotation.Forward * distance); } - trace = trace.HitLayer(CollisionLayer.Debris).Ignore(this); + trace = trace.WithAnyTags("world", "debries", "solid", "player").Ignore(this); if (IsSpectatingPlayer) { diff --git a/code/player/Player.RoleButtons.cs b/code/player/Player.RoleButtons.cs index 3bcdb8d75..6ab53eaea 100644 --- a/code/player/Player.RoleButtons.cs +++ b/code/player/Player.RoleButtons.cs @@ -20,7 +20,7 @@ public partial class Player public void SendLogicButtonsToClient() { - if (IsClient) + if (Game.IsClient) { return; } @@ -42,7 +42,7 @@ public void SendLogicButtonsToClient() [Event.Hotload] public static void OnHotload() { - if (Host.IsClient) + if (Game.IsClient) { return; } @@ -142,7 +142,7 @@ public static void ActivateLogicButton(int networkIdent) // Client keybinding for activating button within focus. public static void TickLogicButtonActivate() { - if (Local.Pawn is not Player player || FocusedButton == null || !Input.Pressed(InputButton.Use)) + if (Game.LocalPawn is not Player player || FocusedButton == null || !Input.Pressed(InputButton.Use)) { return; } diff --git a/code/player/Player.Roles.cs b/code/player/Player.Roles.cs index f591c1780..81d60e72b 100644 --- a/code/player/Player.Roles.cs +++ b/code/player/Player.Roles.cs @@ -82,16 +82,16 @@ public void SendClientRole(To? to = null) public void SyncMIA(Player player = null) { - if (Gamemode.Game.Instance.Round is not InProgressRound) + if (Gamemode.TTTGame.Instance.Round is not InProgressRound) { return; } if (player == null) { - List traitors = new(); + List traitors = new(); - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if ((client.Pawn as Player).Team.GetType() == typeof(TraitorTeam)) { diff --git a/code/player/Player.Shop.cs b/code/player/Player.Shop.cs index b98313fea..2ea80dda6 100644 --- a/code/player/Player.Shop.cs +++ b/code/player/Player.Shop.cs @@ -119,7 +119,7 @@ private static void OnRoundChanged(BaseRound _, BaseRound newRound) [ClientRpc] public static void ClientBoughtItem(string itemName) { - (Local.Pawn as Player).BoughtItemsSet.Add(itemName); + (Game.LocalPawn as Player).BoughtItemsSet.Add(itemName); UpdateQuickShop(); } @@ -146,7 +146,7 @@ public void ServerUpdateShop() [ClientRpc] public static void ClientUpdateShop(string shopJson) { - (Local.Pawn as Player).Shop = Shop.InitializeFromJSON(shopJson); + (Game.LocalPawn as Player).Shop = Shop.InitializeFromJSON(shopJson); } } } diff --git a/code/player/Player.Spectating.cs b/code/player/Player.Spectating.cs index 33d41fde9..645ba9b2c 100644 --- a/code/player/Player.Spectating.cs +++ b/code/player/Player.Spectating.cs @@ -27,7 +27,9 @@ public bool IsSpectatingPlayer public bool IsSpectator { - get => CameraMode is IObservationCamera; +#pragma warning disable CS0184 // 'Der angegebene Ausdruck für den 'is'-Ausdruck darf niemals der angegebene Typ sein + get => Sandbox.Camera.Current is IObservationCamera; +#pragma warning restore CS0184 // 'Der angegebene Ausdruck für den 'is'-Ausdruck darf niemals der angegebene Typ sein } private int _targetIdx = 0; @@ -35,7 +37,7 @@ public bool IsSpectator [Event("player_died")] protected static void OnPlayerDied(Player deadPlayer) { - if (!Host.IsClient || Local.Pawn is not Player player) + if (!Game.IsClient || Game.LocalPawn is not Player player) { return; } @@ -64,10 +66,10 @@ public void UpdateObservatedPlayer() CurrentPlayer = players[_targetIdx]; } - if (CameraMode is IObservationCamera camera) - { - camera.OnUpdateObservatedPlayer(oldObservatedPlayer, CurrentPlayer); - } + //if (Sandbox.Camera.Current is IObservationCamera camera) + //{ + // camera.OnUpdateObservatedPlayer(oldObservatedPlayer, CurrentPlayer); + //} } public void MakeSpectator(bool useRagdollCamera = true) @@ -75,7 +77,7 @@ public void MakeSpectator(bool useRagdollCamera = true) EnableAllCollisions = false; EnableDrawing = false; Controller = null; - CameraMode = useRagdollCamera ? new RagdollSpectateCamera() : new FreeSpectateCamera(); + // CameraMode = useRagdollCamera ? new RagdollSpectateCamera() : new FreeSpectateCamera(); LifeState = LifeState.Dead; Health = 0f; ShowFlashlight(false, false); @@ -95,7 +97,7 @@ public void ToggleForcedSpectator() Client.SetValue("forcedspectator", true); } } - else if (Gamemode.Game.Instance.Round is not Rounds.InProgressRound && Gamemode.Game.Instance.Round is not Rounds.PostRound) + else if (Gamemode.TTTGame.Instance.Round is not Rounds.InProgressRound && Gamemode.TTTGame.Instance.Round is not Rounds.PostRound) { Respawn(); } diff --git a/code/player/Player.VoiceChat.cs b/code/player/Player.VoiceChat.cs index d6f14f547..76b9ff9e5 100644 --- a/code/player/Player.VoiceChat.cs +++ b/code/player/Player.VoiceChat.cs @@ -13,7 +13,7 @@ public partial class Player // clientside-only public bool IsSpeaking { get; internal set; } = false; - private static readonly Dictionary> OldReceiveClients = new(); + private static readonly Dictionary> OldReceiveClients = new(); private void TickPlayerVoiceChat() { @@ -23,7 +23,7 @@ private void TickPlayerVoiceChat() if (Input.Pressed(InputButton.Walk)) { - if (Local.Pawn is Player player && CanUseTeamVoiceChat(player)) + if (Game.LocalPawn is Player player && CanUseTeamVoiceChat(player)) { RequestTeamChat(true); } @@ -59,11 +59,11 @@ private static void ToggleTeamChat(Player player, bool toggle) { player.IsTeamVoiceChatEnabled = toggle; - List clients = new(); + List clients = new(); if (toggle) { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player pawnPlayer && player.Team == pawnPlayer.Team) { @@ -82,7 +82,7 @@ private static void ToggleTeamChat(Player player, bool toggle) } // cleanup disconnected clients - foreach (Client client in OldReceiveClients[player]) + foreach (IClient client in OldReceiveClients[player]) { if (client.IsValid()) { @@ -111,7 +111,7 @@ public static void ClientToggleTeamVoiceChat(Player player, bool toggle) player.IsTeamVoiceChatEnabled = toggle; - if (Local.Pawn is Player localPlayer && localPlayer != player) + if (Game.LocalPawn is Player localPlayer && localPlayer != player) { return; } @@ -123,7 +123,7 @@ public static void ClientToggleTeamVoiceChat(Player player, bool toggle) [Event("player_role_select")] protected static void OnSelectRole(Player player) { - if (!Host.IsServer) + if (!Game.IsServer) { return; } @@ -134,10 +134,10 @@ protected static void OnSelectRole(Player player) ToggleTeamChat(player, false); } - Client playerClient = player.Client; + IClient playerClient = player.Client; // sync already talking other players with the current player - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player pawnPlayer && player != pawnPlayer && pawnPlayer.IsTeamVoiceChatEnabled) { diff --git a/code/player/Player.cs b/code/player/Player.cs index ad1467e77..937cafc76 100644 --- a/code/player/Player.cs +++ b/code/player/Player.cs @@ -43,10 +43,10 @@ public Player() // Important: Server-side only public void InitialSpawn() { - bool isPostRound = Gamemode.Game.Instance.Round is Rounds.PostRound; + bool isPostRound = Gamemode.TTTGame.Instance.Round is Rounds.PostRound; IsInitialSpawning = true; - IsForcedSpectator = isPostRound || Gamemode.Game.Instance.Round is Rounds.InProgressRound; + IsForcedSpectator = isPostRound || Gamemode.TTTGame.Instance.Round is Rounds.InProgressRound; NetworkableGameEvent.RegisterNetworked(new Events.Player.InitialSpawnEvent(Client)); @@ -79,7 +79,7 @@ public override void Respawn() { Model = WorldModel; - Animator = new StandardPlayerAnimator(); + //Animator = new StandardPlayerAnimator(); EnableHideInFirstPerson = true; EnableShadowInFirstPerson = false; @@ -102,7 +102,7 @@ public override void Respawn() if (!IsForcedSpectator) { Controller = new DefaultWalkController(); - CameraMode = new FirstPersonCamera(); + //CameraMode = new FirstPersonCamera(); EnableAllCollisions = true; EnableDrawing = true; @@ -114,9 +114,9 @@ public override void Respawn() RemovePlayerCorpse(); Inventory.DeleteContents(); - Gamemode.Game.Instance.Round.OnPlayerSpawn(this); + Gamemode.TTTGame.Instance.Round.OnPlayerSpawn(this); - switch (Gamemode.Game.Instance.Round) + switch (Gamemode.TTTGame.Instance.Round) { case Rounds.PreRound: case Rounds.WaitingRound: @@ -148,7 +148,7 @@ public override void OnKilled() NetworkableGameEvent.RegisterNetworked(new Events.Player.DiedEvent(this)); } - BecomePlayerCorpseOnServer(_lastDamageInfo.Force, GetHitboxBone(_lastDamageInfo.HitboxIndex)); + BecomePlayerCorpseOnServer(_lastDamageInfo.Force, _lastDamageInfo.BoneIndex); ShowFlashlight(false, false); @@ -156,11 +156,11 @@ public override void OnKilled() using (Prediction.Off()) { - if (Gamemode.Game.Instance.Round is Rounds.InProgressRound) + if (Gamemode.TTTGame.Instance.Round is Rounds.InProgressRound) { SyncMIA(); } - else if (Gamemode.Game.Instance.Round is Rounds.PostRound && PlayerCorpse != null && !PlayerCorpse.Data.IsIdentified) + else if (Gamemode.TTTGame.Instance.Round is Rounds.PostRound && PlayerCorpse != null && !PlayerCorpse.Data.IsIdentified) { PlayerCorpse.Data.IsIdentified = true; @@ -174,9 +174,9 @@ public override void OnKilled() Inventory.DeleteContents(); } - public override void Simulate(Client client) + public override void Simulate(IClient client) { - if (IsClient) + if (Game.IsClient) { TickPlayerVoiceChat(); } @@ -195,16 +195,16 @@ public override void Simulate(Client client) } // Input requested a carriable entity switch - if (Input.ActiveChild != null) - { - ActiveChild = Input.ActiveChild; - } + //if (Input.ActiveChild != null) + //{ + // ActiveChild = Input.ActiveChild; + //} SimulateActiveChild(client, ActiveChild); TickItemSimulate(); - if (Host.IsServer) + if (Game.IsServer) { TickPlayerUse(); TickPlayerDropCarriable(); @@ -217,7 +217,7 @@ public override void Simulate(Client client) } PawnController controller = GetActiveController(); - controller?.Simulate(client, this, GetActiveAnimator()); + // controller?.Simulate(client, this, GetActiveAnimator()); } protected override void UseFail() @@ -227,7 +227,7 @@ protected override void UseFail() public override void StartTouch(Entity other) { - if (IsClient) + if (Game.IsClient) { return; } @@ -240,7 +240,7 @@ public override void StartTouch(Entity other) public override void EndTouch(Entity other) { - if (IsClient) + if (Game.IsClient) { return; } @@ -272,22 +272,22 @@ private void TickPlayerDropCarriable() private void TickPlayerChangeSpectateCamera() { - if (!Input.Pressed(InputButton.Jump) || !IsServer) + if (!Input.Pressed(InputButton.Jump) || !Game.IsServer) { return; } - using (Prediction.Off()) - { - CameraMode = CameraMode switch - { - RagdollSpectateCamera => new FreeSpectateCamera(), - FreeSpectateCamera => new ThirdPersonSpectateCamera(), - ThirdPersonSpectateCamera => new FirstPersonSpectatorCamera(), - FirstPersonSpectatorCamera => new FreeSpectateCamera(), - _ => CameraMode - }; - } + //using (Prediction.Off()) + //{ + // CameraMode = CameraMode switch + // { + // RagdollSpectateCamera => new FreeSpectateCamera(), + // FreeSpectateCamera => new ThirdPersonSpectateCamera(), + // ThirdPersonSpectateCamera => new FirstPersonSpectatorCamera(), + // FirstPersonSpectatorCamera => new FreeSpectateCamera(), + // _ => CameraMode + // }; + //} } private void TickItemSimulate() diff --git a/code/player/PlayerCorpse.cs b/code/player/PlayerCorpse.cs index 2f6738b75..b609339ad 100644 --- a/code/player/PlayerCorpse.cs +++ b/code/player/PlayerCorpse.cs @@ -3,6 +3,7 @@ using System.Text.Json.Serialization; using Sandbox; +using Sandbox.Physics; using TTTReborn.Entities; using TTTReborn.Globalization; @@ -45,12 +46,13 @@ public partial class PlayerCorpse : ModelEntity, IEntityHint public PlayerCorpse() { - MoveType = MoveType.Physics; UsePhysicsCollision = true; - SetInteractsAs(CollisionLayer.Debris); - SetInteractsWith(CollisionLayer.WORLD_GEOMETRY); - SetInteractsExclude(CollisionLayer.Player); + Tags.Add("corpse"); + Tags.Add("debris"); + + //SetInteractsWith(CollisionLayer.WORLD_GEOMETRY); + //SetInteractsExclude(CollisionLayer.Player); Data.KilledTime = Time.Now; } @@ -59,7 +61,7 @@ public void CopyFrom(Player player) { DeadPlayer = player; - Data.PlayerId = player.Client.PlayerId; + Data.PlayerId = player.Client.SteamId; Data.Name = player.Client.Name; Data.RoleName = player.Role.Name; Data.TeamName = player.Team.Name; @@ -169,7 +171,7 @@ public void HintTick(Player confirmingPlayer) { using (Prediction.Off()) { - if (IsClient && !Input.Down(InputButton.Use)) + if (Game.IsClient && !Input.Down(InputButton.Use)) { if (InspectMenu.Instance != null) { @@ -183,7 +185,7 @@ public void HintTick(Player confirmingPlayer) { bool covert = Input.Down(InputButton.Duck); - if (IsServer) + if (Game.IsServer) { if (!covert) { diff --git a/code/player/camera/FirstPersonSpectatorCamera.cs b/code/player/camera/FirstPersonSpectatorCamera.cs index c5bfddd50..ddfc8eeec 100644 --- a/code/player/camera/FirstPersonSpectatorCamera.cs +++ b/code/player/camera/FirstPersonSpectatorCamera.cs @@ -10,7 +10,7 @@ public override void Deactivated() { base.Deactivated(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } @@ -21,7 +21,7 @@ public override void Deactivated() public override void Update() { - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/player/camera/FreeSpectateCamera.cs b/code/player/camera/FreeSpectateCamera.cs index 91d711159..51499f0b8 100644 --- a/code/player/camera/FreeSpectateCamera.cs +++ b/code/player/camera/FreeSpectateCamera.cs @@ -18,8 +18,8 @@ public override void Activated() { base.Activated(); - _targetPos = CurrentView.Position; - _targetRot = CurrentView.Rotation; + //_targetPos = CurrentView.Position; + //_targetRot = CurrentView.Rotation; Position = _targetPos; Rotation = _targetRot; @@ -28,7 +28,7 @@ public override void Activated() public override void Update() { - if (Local.Client == null) + if (Game.LocalClient == null) { return; } @@ -42,26 +42,26 @@ public override void Update() Rotation = Rotation.Slerp(Rotation, _targetRot, 10 * RealTime.Delta * (1 - LERP_MODE)); } - public override void BuildInput(InputBuilder input) - { - _moveInput = input.AnalogMove; + //public override void BuildInput(InputBuilder input) + //{ + // _moveInput = input.AnalogMove; - _moveSpeed = 1; + // _moveSpeed = 1; - if (input.Down(InputButton.Run)) - { - _moveSpeed = 5; - } + // if (input.Down(InputButton.Run)) + // { + // _moveSpeed = 5; + // } - if (input.Down(InputButton.Duck)) - { - _moveSpeed = 0.2f; - } + // if (input.Down(InputButton.Duck)) + // { + // _moveSpeed = 0.2f; + // } - _lookAngles += input.AnalogLook; - _lookAngles.roll = 0; + // _lookAngles += input.AnalogLook; + // _lookAngles.roll = 0; - base.BuildInput(input); - } + // base.BuildInput(input); + //} } } diff --git a/code/player/camera/RagdollSpectateCamera.cs b/code/player/camera/RagdollSpectateCamera.cs index 5587dd0c6..0a9faab14 100644 --- a/code/player/camera/RagdollSpectateCamera.cs +++ b/code/player/camera/RagdollSpectateCamera.cs @@ -10,7 +10,7 @@ public override void Activated() { base.Activated(); - FocusPoint = CurrentView.Position - GetViewOffset(); + FocusPoint = Game.LocalPawn.Position - GetViewOffset(); } public override void Update() @@ -18,21 +18,21 @@ public override void Update() FocusPoint = Vector3.Lerp(FocusPoint, GetSpectatePoint(), Time.Delta * 5.0f); Position = FocusPoint + GetViewOffset(); - Rotation = Input.Rotation; + Rotation = Input.AnalogLook.ToRotation(); Viewer = null; } public virtual Vector3 GetSpectatePoint() { - if (Local.Pawn is Player player && player.Corpse.IsValid()) + if (Game.LocalPawn is Player player && player.Corpse.IsValid()) { return player.Corpse.PhysicsGroup.MassCenter; } - return Local.Pawn.Position; + return Game.LocalPawn.Position; } - public virtual Vector3 GetViewOffset() => Input.Rotation.Forward * -130 + Vector3.Up * 20; + public virtual Vector3 GetViewOffset() => Input.AnalogLook.Forward * -130 + Vector3.Up * 20; } } diff --git a/code/player/camera/ThirdPersonSpectateCamera.cs b/code/player/camera/ThirdPersonSpectateCamera.cs index 85139040b..13d1a98fe 100644 --- a/code/player/camera/ThirdPersonSpectateCamera.cs +++ b/code/player/camera/ThirdPersonSpectateCamera.cs @@ -17,12 +17,12 @@ public override void Activated() { base.Activated(); - Rotation = CurrentView.Rotation; + Rotation = Sandbox.Camera.Rotation; } public override void Update() { - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } @@ -41,7 +41,7 @@ public override void Update() private Vector3 GetSpectatePoint() { - if (Local.Pawn is not Player player || !player.IsSpectatingPlayer) + if (Game.LocalPawn is not Player player || !player.IsSpectatingPlayer) { return DefaultPosition; } @@ -49,17 +49,17 @@ private Vector3 GetSpectatePoint() return player.CurrentPlayer.EyePosition; } - public override void BuildInput(InputBuilder input) - { - _lookAngles += input.AnalogLook; - _lookAngles.roll = 0; + //public override void BuildInput(InputBuilder input) + //{ + // _lookAngles += input.AnalogLook; + // _lookAngles.roll = 0; - base.BuildInput(input); - } + // base.BuildInput(input); + //} public override void Deactivated() { - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/player/controller/DefaultWalkController.cs b/code/player/controller/DefaultWalkController.cs index a61774e3d..3fdf0b0ab 100644 --- a/code/player/controller/DefaultWalkController.cs +++ b/code/player/controller/DefaultWalkController.cs @@ -89,7 +89,7 @@ public override void Simulate() #endregion #region Drowning - IsUnderwater = Pawn.WaterLevel == 1f; + IsUnderwater = Pawn.GetWaterLevel() == 1f; if (IsUnderwater) { @@ -100,15 +100,14 @@ public override void Simulate() Breath = MathF.Min(Breath + BREATH_GAIN_PER_SECOND * Time.Delta, MAX_BREATH); } - if (Host.IsServer && Breath == 0f) + if (Game.IsServer && Breath == 0f) { using (Prediction.Off()) { DamageInfo damageInfo = new() { Attacker = Pawn, - Flags = DamageFlags.Drown, - HitboxIndex = (int) HitboxIndex.Head, + Tags = new System.Collections.Generic.HashSet { "drown" }, Position = Position, Damage = MathF.Max(DROWN_DAMAGE_PER_SECOND * Time.Delta, 0f) }; @@ -146,15 +145,15 @@ public override void CategorizePosition(bool stayOnGround) public virtual void OnPostCategorizePosition(bool stayOnGround, TraceResult trace) { - if (Host.IsServer && trace.Hit && _fallVelocity < -FALL_DAMAGE_VELOCITY) + if (Game.IsServer && trace.Hit && _fallVelocity < -FALL_DAMAGE_VELOCITY) { using (Prediction.Off()) { DamageInfo damageInfo = new() { Attacker = Pawn, - Flags = DamageFlags.Fall, - HitboxIndex = (int) HitboxIndex.LeftFoot, + Tags = new System.Collections.Generic.HashSet {"fall"}, + //HitboxIndex = (int) HitboxIndex.LeftFoot, Position = Position, Damage = (MathF.Abs(_fallVelocity) - FALL_DAMAGE_VELOCITY) * FALL_DAMAGE_SCALE }; @@ -165,9 +164,9 @@ public virtual void OnPostCategorizePosition(bool stayOnGround, TraceResult trac } [Event("player_initialspawn")] - protected static void OnInitialSpawn(Client client) + protected static void OnInitialSpawn(IClient client) { - if (Host.IsClient) + if (Game.IsClient) { return; } @@ -178,7 +177,7 @@ protected static void OnInitialSpawn(Client client) [Event("settings_change")] public static void OnSettingsChange() { - if (Host.IsClient) + if (Game.IsClient) { return; } @@ -186,9 +185,9 @@ public static void OnSettingsChange() Update(); } - public static void Update(Client client = null) + public static void Update(IClient client = null) { - if (Host.IsClient) + if (Game.IsClient) { return; } @@ -206,10 +205,10 @@ public partial class Player [ConCmd.Server(Name = "ttt_toggle_sprint", Help = "Toggles sprinting")] public static void ToggleSprinting() { - if (!ConsoleSystem.Caller.HasPermission("ttt_toggle_sprint")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("ttt_toggle_sprint")) + //{ + // return; + //} DefaultWalkController.IsSprintEnabled = !DefaultWalkController.IsSprintEnabled; diff --git a/code/player/inventory/Inventory.Ammo.cs b/code/player/inventory/Inventory.Ammo.cs index 08bd96da7..933f2a973 100644 --- a/code/player/inventory/Inventory.Ammo.cs +++ b/code/player/inventory/Inventory.Ammo.cs @@ -49,7 +49,7 @@ public bool Set(string ammoType, int amount) AmmoList[ammo] = amount; - if (Host.IsServer) + if (Game.IsServer) { _owner.ClientSetAmmo(To.Single(_owner), ammo, amount); } @@ -90,7 +90,7 @@ public void Clear() { AmmoList.Clear(); - if (Host.IsServer) + if (Game.IsServer) { _owner.ClientClearAmmo(To.Single(_owner)); } diff --git a/code/player/inventory/Inventory.Perks.cs b/code/player/inventory/Inventory.Perks.cs index 136794728..e12160ded 100644 --- a/code/player/inventory/Inventory.Perks.cs +++ b/code/player/inventory/Inventory.Perks.cs @@ -25,7 +25,7 @@ public bool Give(Perk perk) PerkList.Add(perk); - if (Host.IsServer) + if (Game.IsServer) { _owner.ClientAddPerk(To.Single(_owner), perk.Info.LibraryName); } @@ -47,7 +47,7 @@ public bool Take(Perk perk) perk.Remove(); perk.Delete(); - if (Host.IsServer) + if (Game.IsServer) { _owner.ClientRemovePerk(To.Single(_owner), perk.Info.LibraryName); } @@ -94,7 +94,7 @@ public void Clear() PerkList.Clear(); - if (Host.IsServer) + if (Game.IsServer) { _owner.ClientClearPerks(To.Single(_owner)); } diff --git a/code/player/inventory/Inventory.cs b/code/player/inventory/Inventory.cs index a3420cfb3..743caa10b 100644 --- a/code/player/inventory/Inventory.cs +++ b/code/player/inventory/Inventory.cs @@ -180,7 +180,7 @@ public IList GetAmmoNames() public override bool Drop(Entity entity) { - if (!Host.IsServer || !Contains(entity) || entity is ICarriableItem item && !item.CanDrop) + if (!Game.IsServer || !Contains(entity) || entity is ICarriableItem item && !item.CanDrop) { return false; } @@ -221,9 +221,9 @@ public override Entity DropActive() public Entity DropEntity(Equipment equipment) { Type type = equipment.ObjectType; - Vector3 position = Owner.EyePosition + Owner.EyeRotation.Forward * DROPPOSITIONOFFSET; - Rotation rotation = Owner.EyeRotation; - Vector3 velocity = Owner.EyeRotation.Forward * DROPVELOCITY; + Vector3 position = Owner.AimRay.Position + Owner.AimRay.Forward * DROPPOSITIONOFFSET; + Rotation rotation = Owner.Rotation; + Vector3 velocity = Owner.AimRay.Forward * DROPVELOCITY; if (Remove(equipment)) { diff --git a/code/player/shop/Shop.cs b/code/player/shop/Shop.cs index f9c8985be..e5686008a 100644 --- a/code/player/shop/Shop.cs +++ b/code/player/shop/Shop.cs @@ -25,7 +25,7 @@ public class Shop public List Items { set; get; } = new(); public bool Enabled { get; set; } = true; - public bool Accessable() => Items.Count > 0 && Enabled && Gamemode.Game.Instance.Round is InProgressRound; + public bool Accessable() => Items.Count > 0 && Enabled && Gamemode.TTTGame.Instance.Round is InProgressRound; public static Shop InitializeFromJSON(string json) { diff --git a/code/roles/DetectiveRole.cs b/code/roles/DetectiveRole.cs index be73707f3..26315f1e8 100644 --- a/code/roles/DetectiveRole.cs +++ b/code/roles/DetectiveRole.cs @@ -18,7 +18,7 @@ public class DetectiveRole : Role public override void OnSelect(Player player) { - if (Host.IsServer && player.Team == DefaultTeam) + if (Game.IsServer && player.Team == DefaultTeam) { foreach (Player otherPlayer in Utils.GetPlayers((pl) => pl != player)) { diff --git a/code/roles/Role.cs b/code/roles/Role.cs index 49e9ac133..f7444f3dd 100644 --- a/code/roles/Role.cs +++ b/code/roles/Role.cs @@ -50,7 +50,7 @@ public virtual void OnSelect(Player player) { player.Credits = Math.Max(DefaultCredits, player.Credits); - if (Host.IsServer) + if (Game.IsServer) { player.Shop = Shop; player.ServerUpdateShop(); diff --git a/code/roles/TraitorRole.cs b/code/roles/TraitorRole.cs index 1187f3bcd..d77a60279 100644 --- a/code/roles/TraitorRole.cs +++ b/code/roles/TraitorRole.cs @@ -18,7 +18,7 @@ public class TraitorRole : Role public override void OnSelect(Player player) { - if (Host.IsServer && player.Team == DefaultTeam) + if (Game.IsServer && player.Team == DefaultTeam) { foreach (Player otherPlayer in player.Team.Members) { diff --git a/code/rounds/BaseRound.cs b/code/rounds/BaseRound.cs index c727ee35f..703ef6d7d 100644 --- a/code/rounds/BaseRound.cs +++ b/code/rounds/BaseRound.cs @@ -17,7 +17,17 @@ public abstract partial class BaseRound : BaseNetworkable public float RoundEndTime { get; set; } [Net] - public float TimeLeft => RoundEndTime - Time.Now; + public float TimeLeft { get; set; } + //{ + // get + // { + // return RoundEndTime - Time.Now; + // } + // set + // { + // //nop; + // } + //} [Net] public float StartedAt { get; set; } @@ -27,7 +37,7 @@ public abstract partial class BaseRound : BaseNetworkable public void Start() { - if (Host.IsServer) + if (Game.IsServer) { StartedAt = Time.Now; @@ -43,7 +53,7 @@ public void Start() public void Finish() { - if (Host.IsServer) + if (Game.IsServer) { RoundEndTime = 0f; } @@ -68,7 +78,7 @@ public virtual void OnTick() { } public virtual void OnSecond() { - if (Host.IsServer) + if (Game.IsServer) { if (RoundEndTime > 0 && Time.Now >= RoundEndTime) { @@ -87,7 +97,7 @@ protected virtual void OnStart() { } protected virtual void OnFinish() { - if (!Host.IsServer) + if (!Game.IsServer) { return; } diff --git a/code/rounds/InProgressRound.cs b/code/rounds/InProgressRound.cs index 7193b872b..5daff646b 100644 --- a/code/rounds/InProgressRound.cs +++ b/code/rounds/InProgressRound.cs @@ -15,10 +15,10 @@ public partial class InProgressRound : BaseRound public override string RoundName { get; set; } = "In Progress"; [Net] - public List Players { get; set; } + public IList Players { get; set; } [Net] - public List Spectators { get; set; } + public IList Spectators { get; set; } private List _logicButtons; @@ -57,11 +57,11 @@ public override void OnPlayerLeave(Player player) protected override void OnStart() { - if (Host.IsServer) + if (Game.IsServer) { // For now, if the Weapons.Count of the map is zero, let's just give the players // a fixed weapon loadout. - if (Gamemode.Game.Instance.MapHandler.Weapons.Count < Players.Count) + if (Gamemode.TTTGame.Instance.MapHandler.Weapons.Count < Players.Count) { foreach (Player player in Players) { @@ -138,13 +138,13 @@ private static void LoadPostRound(Team winningTeam) { NetworkableGameEvent.RegisterNetworked(new Events.Game.FinishEvent(winningTeam)); - Gamemode.Game.Instance.MapSelection.TotalRoundsPlayed++; - Gamemode.Game.Instance.ForceRoundChange(new PostRound()); + Gamemode.TTTGame.Instance.MapSelection.TotalRoundsPlayed++; + Gamemode.TTTGame.Instance.ForceRoundChange(new PostRound()); } public override void OnSecond() { - if (Host.IsServer) + if (Game.IsServer) { if (!ServerSettings.Instance.Debug.PreventWin) { @@ -159,7 +159,7 @@ public override void OnSecond() if (!Utils.HasMinimumPlayers() && IsRoundOver() == null) { - Gamemode.Game.Instance.ForceRoundChange(new WaitingRound()); + Gamemode.TTTGame.Instance.ForceRoundChange(new WaitingRound()); } } } @@ -182,7 +182,7 @@ protected override void OnFinish() { base.OnFinish(); - if (!Host.IsServer) + if (!Game.IsServer) { return; } @@ -205,12 +205,12 @@ protected override void OnFinish() [Event("player_role_select")] protected static void OnPlayerRoleChange(Player _) { - if (Host.IsClient) + if (Game.IsClient) { return; } - if (Gamemode.Game.Instance.Round is InProgressRound inProgressRound) + if (Gamemode.TTTGame.Instance.Round is InProgressRound inProgressRound) { inProgressRound.ChangeRoundIfOver(); } @@ -219,7 +219,7 @@ protected static void OnPlayerRoleChange(Player _) [Event("settings_change")] protected static void OnChangeSettings() { - if (Host.IsClient || Gamemode.Game.Instance.Round is not InProgressRound inProgressRound) + if (Game.IsClient || Gamemode.TTTGame.Instance.Round is not InProgressRound inProgressRound) { return; } diff --git a/code/rounds/MapSelectionRound.cs b/code/rounds/MapSelectionRound.cs index 711bbb33d..f8497b9d0 100644 --- a/code/rounds/MapSelectionRound.cs +++ b/code/rounds/MapSelectionRound.cs @@ -19,29 +19,29 @@ protected override void OnTimeUp() { base.OnTimeUp(); - IDictionary maps = Gamemode.Game.Instance.MapSelection.MapImages; + IDictionary maps = Gamemode.TTTGame.Instance.MapSelection.MapImages; // We failed to fetch TTT maps, fall back to default map. if (maps.Count == 0) { - Global.ChangeLevel(ServerSettings.Instance.Map.DefaultMap); + Sandbox.Game.ChangeLevel(ServerSettings.Instance.Map.DefaultMap); return; } - IDictionary playerIdMapVote = Gamemode.Game.Instance.MapSelection.PlayerIdMapVote; + IDictionary playerIdMapVote = Gamemode.TTTGame.Instance.MapSelection.PlayerIdMapVote; IDictionary mapToVoteCount = MapSelectionHandler.GetTotalVotesPerMap(playerIdMapVote); // Nobody voted, so let's change to a random map. if (mapToVoteCount.Count == 0) { - Global.ChangeLevel(maps.ElementAt(Utils.RNG.Next(maps.Count)).Key); + Sandbox.Game.ChangeLevel(maps.ElementAt(Utils.RNG.Next(maps.Count)).Key); return; } // Change to the map which received the most votes first. - Global.ChangeLevel(mapToVoteCount.OrderByDescending(x => x.Value).First().Key); + Sandbox.Game.ChangeLevel(mapToVoteCount.OrderByDescending(x => x.Value).First().Key); } public override void OnPlayerKilled(Player player) diff --git a/code/rounds/PostRound.cs b/code/rounds/PostRound.cs index 6e5e87d3f..16eb477e6 100644 --- a/code/rounds/PostRound.cs +++ b/code/rounds/PostRound.cs @@ -19,8 +19,8 @@ protected override void OnTimeUp() // TODO: Allow users to close the menu themselves using mouse cursor. RPCs.ClientClosePostRoundMenu(); - bool shouldChangeMap = Gamemode.Game.Instance.MapSelection.TotalRoundsPlayed >= ServerSettings.Instance.Round.TotalRounds; - Gamemode.Game.Instance.ChangeRound(shouldChangeMap ? new MapSelectionRound() : new PreRound()); + bool shouldChangeMap = Gamemode.TTTGame.Instance.MapSelection.TotalRoundsPlayed >= ServerSettings.Instance.Round.TotalRounds; + Gamemode.TTTGame.Instance.ChangeRound(shouldChangeMap ? new MapSelectionRound() : new PreRound()); } public override void OnPlayerKilled(Player player) @@ -32,7 +32,7 @@ public override void OnPlayerKilled(Player player) protected override void OnStart() { - if (Host.IsServer) + if (Game.IsServer) { using (Prediction.Off()) { diff --git a/code/rounds/PreRound.cs b/code/rounds/PreRound.cs index 70a54be58..81c1d8e85 100644 --- a/code/rounds/PreRound.cs +++ b/code/rounds/PreRound.cs @@ -27,11 +27,11 @@ public override void OnPlayerKilled(Player player) protected override void OnStart() { - if (Host.IsServer) + if (Game.IsServer) { - Gamemode.Game.Instance.MapHandler.Reset(); + Gamemode.TTTGame.Instance.MapHandler.Reset(); - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player) { @@ -68,7 +68,7 @@ protected override void OnTimeUp() AssignRolesAndRespawn(players); - Gamemode.Game.Instance.ChangeRound(new InProgressRound + Gamemode.TTTGame.Instance.ChangeRound(new InProgressRound { Players = players, Spectators = spectators @@ -108,7 +108,7 @@ private static async void StartRespawnTimer(Player player) { await GameTask.DelaySeconds(1); - if (player.IsValid() && Gamemode.Game.Instance.Round is PreRound) + if (player.IsValid() && Gamemode.TTTGame.Instance.Round is PreRound) { player.Respawn(); } diff --git a/code/rounds/WaitingRound.cs b/code/rounds/WaitingRound.cs index fc82d1137..529750d90 100644 --- a/code/rounds/WaitingRound.cs +++ b/code/rounds/WaitingRound.cs @@ -10,9 +10,9 @@ public class WaitingRound : BaseRound public override void OnSecond() { - if (Host.IsServer && Utils.HasMinimumPlayers()) + if (Game.IsServer && Utils.HasMinimumPlayers()) { - Gamemode.Game.Instance.ForceRoundChange(new PreRound()); + Gamemode.TTTGame.Instance.ForceRoundChange(new PreRound()); } base.OnSecond(); @@ -29,9 +29,9 @@ public override void OnPlayerKilled(Player player) protected override void OnStart() { - if (Host.IsServer) + if (Game.IsServer) { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player) { @@ -49,7 +49,7 @@ private static async void StartRespawnTimer(Player player) { await GameTask.DelaySeconds(1); - if (player.IsValid() && Gamemode.Game.Instance.Round is WaitingRound) + if (player.IsValid() && Gamemode.TTTGame.Instance.Round is WaitingRound) { player.Respawn(); } diff --git a/code/settings/Settings.cs b/code/settings/Settings.cs index 35e297ca1..6429f1c86 100644 --- a/code/settings/Settings.cs +++ b/code/settings/Settings.cs @@ -61,7 +61,7 @@ public static Settings Instance public static void Load() { - if (Host.IsClient) + if (Game.IsClient) { Instance = SettingFunctions.LoadSettings(); } @@ -83,7 +83,7 @@ public static void Load() public static void Unload() { - if (Host.IsClient) + if (Game.IsClient) { SettingFunctions.SaveSettings(ClientSettings.Instance); } @@ -215,10 +215,10 @@ public static void SendSettingsToServer(ServerSettings settings) [ConCmd.Server] private static void ServerSendPartialSettings(int packetHash, int packetNum, int maxPackets, string partialSettings) { - if (!ConsoleSystem.Caller?.HasPermission("serversettings") ?? true) - { - return; - } + //if (!ConsoleSystem.Caller?.HasPermission("serversettings") ?? true) + //{ + // return; + //} ProceedPartialSettings(packetHash, packetNum, maxPackets, partialSettings); } @@ -261,10 +261,10 @@ private static void ProceedPartialSettings(int packetHash, int packetNum, int ma [ConCmd.Server] public static void RequestServerSettings() { - if (!ConsoleSystem.Caller.HasPermission("serversettings")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("serversettings")) + //{ + // return; + //} ClientSendServerSettings(To.Single(ConsoleSystem.Caller), GetJSON(ServerSettings.Instance, true)); } diff --git a/code/teams/Team.cs b/code/teams/Team.cs index 43ee43978..b868b4ac6 100644 --- a/code/teams/Team.cs +++ b/code/teams/Team.cs @@ -36,7 +36,7 @@ public Team() } } - public IEnumerable GetClients() => Members.Select(x => x.Client); + public IEnumerable GetClients() => Members.Select(x => x.Client); public virtual bool CheckWin(Player player) => true; diff --git a/code/ui/Hud.cs b/code/ui/Hud.cs index 62c0d633d..9badf0938 100644 --- a/code/ui/Hud.cs +++ b/code/ui/Hud.cs @@ -14,7 +14,7 @@ public partial class Hud : HudEntity public Hud() { - if (Host.IsServer) + if (Game.IsServer) { return; } @@ -30,7 +30,7 @@ public Hud() [Event.Hotload] public static void OnHotReloaded() { - if (Host.IsServer) + if (Game.IsServer) { return; } @@ -39,7 +39,7 @@ public static void OnHotReloaded() _ = new Hud(); - if (Local.Client.Pawn is Player player) + if (Game.LocalClient.Pawn is Player player) { Current.AliveHudInstance.Enabled = player.LifeState == LifeState.Alive && !player.IsForcedSpectator; } @@ -50,7 +50,7 @@ public static void OnHotReloaded() [Event("player_spawn")] protected void OnPlayerSpawned(Player player) { - if (IsServer || player != Local.Client.Pawn) + if (Game.IsServer || player != Game.LocalClient.Pawn) { return; } @@ -61,7 +61,7 @@ protected void OnPlayerSpawned(Player player) [Event("player_died")] protected void OnPlayerDied(Player deadPlayer) { - if (IsServer || deadPlayer != Local.Client.Pawn) + if (Game.IsServer || deadPlayer != Game.LocalClient.Pawn) { return; } @@ -70,9 +70,9 @@ protected void OnPlayerDied(Player deadPlayer) } [Event("player_initialspawn")] - public static void Initialize(Client client) + public static void Initialize(IClient client) { - if (Host.IsServer || client != Local.Client) + if (Game.IsServer || client != Game.LocalClient) { return; } diff --git a/code/ui/alivehud/breathindicator/BreathIndicator.cs b/code/ui/alivehud/breathindicator/BreathIndicator.cs index a0edd9190..355048139 100644 --- a/code/ui/alivehud/breathindicator/BreathIndicator.cs +++ b/code/ui/alivehud/breathindicator/BreathIndicator.cs @@ -22,7 +22,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player || player.Controller is not DefaultWalkController playerController) + if (Game.LocalPawn is not Player player || player.Controller is not DefaultWalkController playerController) { return; } diff --git a/code/ui/alivehud/c4/C4Arm.cs b/code/ui/alivehud/c4/C4Arm.cs index 8575a3353..a44d9ac20 100644 --- a/code/ui/alivehud/c4/C4Arm.cs +++ b/code/ui/alivehud/c4/C4Arm.cs @@ -43,7 +43,7 @@ public C4Arm() ActionButtonPanel.Add.TranslationButton(new TranslationData("EQUIPMENT.C4.UI.PICKUP"), null, "button action-button", () => { - C4Entity.PickUp(Entity.NetworkIdent, Local.Pawn.NetworkIdent); + C4Entity.PickUp(Entity.NetworkIdent, Game.LocalPawn.NetworkIdent); }); ActionButtonPanel.Add.TranslationButton(new TranslationData("EQUIPMENT.C4.UI.DESTROY"), null, "button action-button", () => @@ -77,7 +77,7 @@ private void SetTimer(int presetIndex) public override void Tick() { - if (this.IsEnabled() && Entity?.Transform.Position.Distance(Local.Pawn.Owner.Position) > 100f) + if (this.IsEnabled() && Entity?.Transform.Position.Distance(Game.LocalPawn.Owner.Position) > 100f) { this.Enabled(false); } diff --git a/code/ui/alivehud/damageindicator/DamageIndicator.cs b/code/ui/alivehud/damageindicator/DamageIndicator.cs index eacab6a3a..06ab4c234 100644 --- a/code/ui/alivehud/damageindicator/DamageIndicator.cs +++ b/code/ui/alivehud/damageindicator/DamageIndicator.cs @@ -28,7 +28,7 @@ public DamageIndicator() : base() [Event("player_takedamage")] protected void OnTakeDamage(Player player, float damage) { - if (Host.IsServer || player.Client != Local.Client) + if (Game.IsServer || player.Client != Game.LocalClient) { return; } @@ -40,7 +40,7 @@ protected void OnTakeDamage(Player player, float damage) [Event("player_spawn")] protected void OnPlayerSpawned(Player player) { - if (Host.IsServer || player != Local.Client.Pawn) + if (Game.IsServer || player != Game.LocalClient.Pawn) { return; } @@ -53,7 +53,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { Style.Opacity = 0; diff --git a/code/ui/alivehud/quickshop/QuickShop.cs b/code/ui/alivehud/quickshop/QuickShop.cs index 456f3d5ef..2d446c957 100644 --- a/code/ui/alivehud/quickshop/QuickShop.cs +++ b/code/ui/alivehud/quickshop/QuickShop.cs @@ -50,7 +50,7 @@ public void Reload() SelectedItemData = null; - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } @@ -94,7 +94,7 @@ private void AddItem(ShopItemData itemData) return; } - if (SelectedItemData?.IsBuyable(Local.Pawn as Player) ?? false) + if (SelectedItemData?.IsBuyable(Game.LocalPawn as Player) ?? false) { Player.RequestItem(item.ItemData?.Name); @@ -159,7 +159,7 @@ public override void Tick() return; } - int newCredits = (Local.Pawn as Player).Credits; + int newCredits = (Game.LocalPawn as Player).Credits; if (_credits != newCredits) { @@ -173,7 +173,7 @@ public override void Tick() namespace TTTReborn { - using UI; + using TTTReborn.UI; public partial class Player { @@ -189,7 +189,7 @@ public static void TickPlayerShop() QuickShop.Instance.Enabled = false; QuickShop.Instance.Update(); } - else if (Input.Pressed(InputButton.View) && Local.Pawn is Player player) + else if (Input.Pressed(InputButton.View) && Game.LocalPawn is Player player) { if (!(player.Shop?.Accessable() ?? false)) { diff --git a/code/ui/alivehud/quickshop/QuickShopItem.cs b/code/ui/alivehud/quickshop/QuickShopItem.cs index b7a97171e..6eac30110 100644 --- a/code/ui/alivehud/quickshop/QuickShopItem.cs +++ b/code/ui/alivehud/quickshop/QuickShopItem.cs @@ -30,7 +30,7 @@ public void SetItem(ShopItemData shopItemData) public void Update() { - IsDisabled = (Local.Pawn as Player).CanBuy(ItemData) != BuyError.None; + IsDisabled = (Game.LocalPawn as Player).CanBuy(ItemData) != BuyError.None; this.Enabled(!IsDisabled); } diff --git a/code/ui/alivehud/staminaindicator/StaminaIndicator.cs b/code/ui/alivehud/staminaindicator/StaminaIndicator.cs index 447a2f64b..521804620 100644 --- a/code/ui/alivehud/staminaindicator/StaminaIndicator.cs +++ b/code/ui/alivehud/staminaindicator/StaminaIndicator.cs @@ -22,7 +22,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player || player.Controller is not DefaultWalkController playerController) + if (Game.LocalPawn is not Player player || player.Controller is not DefaultWalkController playerController) { return; } diff --git a/code/ui/components/BindingKeyImage.cs b/code/ui/components/BindingKeyImage.cs index 15cc4a8bc..e0cc7082b 100644 --- a/code/ui/components/BindingKeyImage.cs +++ b/code/ui/components/BindingKeyImage.cs @@ -29,7 +29,7 @@ public override void Tick() if (Parent is BindingPanel bindingPanel) { - bindingPanel.FinalLayout(); + bindingPanel.FinalLayout(0); } } } diff --git a/code/ui/components/dragdrop/Drag.cs b/code/ui/components/dragdrop/Drag.cs index b1e51a6a3..281dab7fb 100644 --- a/code/ui/components/dragdrop/Drag.cs +++ b/code/ui/components/dragdrop/Drag.cs @@ -138,8 +138,8 @@ protected override void OnMouseMove(MousePanelEvent e) float screenWidth = Screen.Width; float screenHeight = Screen.Height; - float parentWidth = DragBasePanel.Box.Rect.width; - float parentHeight = DragBasePanel.Box.Rect.height; + float parentWidth = DragBasePanel.Box.Rect.Width; + float parentHeight = DragBasePanel.Box.Rect.Height; float left = position.x; float top = position.y; diff --git a/code/ui/components/tooltip/Tooltip.cs b/code/ui/components/tooltip/Tooltip.cs index a21b2e9e2..de8b5f12f 100644 --- a/code/ui/components/tooltip/Tooltip.cs +++ b/code/ui/components/tooltip/Tooltip.cs @@ -32,10 +32,10 @@ public Tooltip(Panel relatedPanel, Action onCreate = null, Action pl.LifeState == LifeState.Dead)), ConsoleSystem.Caller.Name, message, Channel.Spectator, $"avatar:{ConsoleSystem.Caller.PlayerId}"); + AddChatEntry(To.Multiple(Utils.GetClients((pl) => pl.LifeState == LifeState.Dead)), ConsoleSystem.Caller.Name, message, Channel.Spectator, $"avatar:{ConsoleSystem.Caller.SteamId}"); } else { - AddChatEntry(To.Everyone, ConsoleSystem.Caller.Name, message, Channel.Player, $"avatar:{ConsoleSystem.Caller.PlayerId}"); + AddChatEntry(To.Everyone, ConsoleSystem.Caller.Name, message, Channel.Player, $"avatar:{ConsoleSystem.Caller.SteamId}"); } } @@ -258,11 +259,11 @@ public static void SayTeam(string message) Log.Info($"{ConsoleSystem.Caller}: {message}"); - List clients = new(); + List clients = new(); player.Team.Members.ForEach(member => clients.Add(member.Client)); - AddChatEntry(To.Multiple(clients), ConsoleSystem.Caller.Name, message, Channel.Team, $"avatar:{ConsoleSystem.Caller.PlayerId}", player.Team.Name); + AddChatEntry(To.Multiple(clients), ConsoleSystem.Caller.Name, message, Channel.Team, $"avatar:{ConsoleSystem.Caller.SteamId}", player.Team.Name); } } } diff --git a/code/ui/generalhud/gametimer/GameTimerDisplay.cs b/code/ui/generalhud/gametimer/GameTimerDisplay.cs index 8c4510df4..dce25466d 100644 --- a/code/ui/generalhud/gametimer/GameTimerDisplay.cs +++ b/code/ui/generalhud/gametimer/GameTimerDisplay.cs @@ -19,15 +19,15 @@ public override void Tick() { base.Tick(); - if (Game.Instance.Round == null) + if (TTTGame.Instance.Round == null) { return; } - RoundLabel.UpdateTranslation(new TranslationData($"ROUND.STATE.{Game.Instance.Round.RoundName.ToUpper().Replace(' ', '_')}")); + RoundLabel.UpdateTranslation(new TranslationData($"ROUND.STATE.{TTTGame.Instance.Round.RoundName.ToUpper().Replace(' ', '_')}")); - TimerPanel.SetClass("disabled", Game.Instance.Round is Rounds.WaitingRound); - TimerLabel.Text = Game.Instance.Round.TimeLeftFormatted; + TimerPanel.SetClass("disabled", TTTGame.Instance.Round is Rounds.WaitingRound); + TimerLabel.Text = TTTGame.Instance.Round.TimeLeftFormatted; } } } diff --git a/code/ui/generalhud/infofeed/InfoFeed.cs b/code/ui/generalhud/infofeed/InfoFeed.cs index c4aa79e07..7bc3f068d 100644 --- a/code/ui/generalhud/infofeed/InfoFeed.cs +++ b/code/ui/generalhud/infofeed/InfoFeed.cs @@ -18,11 +18,11 @@ public InfoFeed() : base() StyleSheet.Load("/ui/generalhud/infofeed/InfoFeed.scss"); } - public virtual Panel AddEntry(Client leftClient, string method) + public virtual Panel AddEntry(IClient leftClient, string method) { InfoFeedEntry e = Current.AddChild(); - bool isLeftLocal = leftClient == Local.Client; + bool isLeftLocal = leftClient == Game.LocalClient; Player leftPlayer = leftClient.Pawn as Player; @@ -44,12 +44,12 @@ public virtual Panel AddEntry(string method, Color? color = null) return e; } - public virtual Panel AddEntry(Client leftClient, Client rightClient, string method, string postfix = "") + public virtual Panel AddEntry(IClient leftClient, IClient rightClient, string method, string postfix = "") { InfoFeedEntry e = Current.AddChild(); - bool isLeftLocal = leftClient == Local.Client; - bool isRightLocal = rightClient == Local.Client; + bool isLeftLocal = leftClient == Game.LocalClient; + bool isRightLocal = rightClient == Game.LocalClient; Player leftPlayer = leftClient.Pawn as Player; diff --git a/code/ui/generalhud/inspectmenu/InspectMenu.cs b/code/ui/generalhud/inspectmenu/InspectMenu.cs index a7d0750a5..a42938839 100644 --- a/code/ui/generalhud/inspectmenu/InspectMenu.cs +++ b/code/ui/generalhud/inspectmenu/InspectMenu.cs @@ -97,7 +97,7 @@ public void InspectCorpse(PlayerCorpse playerCorpse) _playerCorpse = playerCorpse; - AvatarImage.SetTexture($"avatar:{_playerCorpse.DeadPlayer?.Client.PlayerId}"); + AvatarImage.SetTexture($"avatar:{_playerCorpse.DeadPlayer?.Client.SteamId}"); PlayerLabel.Text = _playerCorpse.DeadPlayer?.Client.Name; @@ -179,7 +179,7 @@ private void UpdateCurrentInspectDescription() public override void Tick() { - if (!Enabled || !_playerCorpse.IsValid() || _playerCorpse.Transform.Position.Distance(Local.Pawn.Owner.Position) > 100f) + if (!Enabled || !_playerCorpse.IsValid() || _playerCorpse.Transform.Position.Distance(Game.LocalPawn.Owner.Position) > 100f) { Enabled = false; diff --git a/code/ui/generalhud/inventorywrapper/InventoryWrapper.cs b/code/ui/generalhud/inventorywrapper/InventoryWrapper.cs index baa5e412e..2980596c9 100644 --- a/code/ui/generalhud/inventorywrapper/InventoryWrapper.cs +++ b/code/ui/generalhud/inventorywrapper/InventoryWrapper.cs @@ -16,7 +16,7 @@ public InventoryWrapper() StyleSheet.Load("/ui/generalhud/inventorywrapper/InventoryWrapper.scss"); Effects = AddChild(); - InventorySelection = AddChild(); + //InventorySelection = AddChild(); } } } diff --git a/code/ui/generalhud/inventorywrapper/effects/Effects.cs b/code/ui/generalhud/inventorywrapper/effects/Effects.cs index da99c93d0..c50056ca9 100644 --- a/code/ui/generalhud/inventorywrapper/effects/Effects.cs +++ b/code/ui/generalhud/inventorywrapper/effects/Effects.cs @@ -17,7 +17,7 @@ public Effects() AddClass("effects"); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySelection.cs b/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySelection.cs index 90c9e2df1..d2883d8a9 100644 --- a/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySelection.cs +++ b/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySelection.cs @@ -33,7 +33,7 @@ public InventorySelection() : base() AddClass("text-shadow"); AddClass("inventory-selection"); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } @@ -51,7 +51,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } @@ -218,10 +218,10 @@ protected void OnSpectatingChange(Player player) /// IClientInput implementation, calls during the client input build. /// You can both read and write to input, to affect what happens down the line. /// - [Event.BuildInput] - protected void ProcessClientInventorySelectionInput(InputBuilder input) + [Event.Client.BuildInput] + protected void ProcessClientInventorySelectionInput() { - if (Local.Pawn is not Player player || player.IsSpectatingPlayer) + if (Game.LocalPawn is not Player player || player.IsSpectatingPlayer) { return; } @@ -233,7 +233,7 @@ protected void ProcessClientInventorySelectionInput(InputBuilder input) List childrenList = Children.ToList(); ICarriableItem activeCarriable = player.ActiveChild as ICarriableItem; - int keyboardIndexPressed = GetKeyboardNumberPressed(input); + int keyboardIndexPressed = GetKeyboardNumberPressed(); if (keyboardIndexPressed != -1) { @@ -261,28 +261,28 @@ protected void ProcessClientInventorySelectionInput(InputBuilder input) } } - if (activeCarriable == null || activeCarriableOfSlotTypeIndex == -1) - { - // The user isn't holding an active carriable, or is holding a weapon that has a different - // hold type than the one selected using the keyboard. We can just select the first weapon. - input.ActiveChild = weaponsOfSlotTypeSelected.FirstOrDefault() as Entity; - } - else - { - // The user is holding a weapon that has the same hold type as the keyboard index the user pressed. - // Find the next possible weapon within the hold types. - input.ActiveChild = weaponsOfSlotTypeSelected[GetNextWeaponIndex(activeCarriableOfSlotTypeIndex, weaponsOfSlotTypeSelected.Count)] as Entity; - } + //if (activeCarriable == null || activeCarriableOfSlotTypeIndex == -1) + //{ + // // The user isn't holding an active carriable, or is holding a weapon that has a different + // // hold type than the one selected using the keyboard. We can just select the first weapon. + // Input.ActiveChild = weaponsOfSlotTypeSelected.FirstOrDefault() as Entity; + //} + //else + //{ + // // The user is holding a weapon that has the same hold type as the keyboard index the user pressed. + // // Find the next possible weapon within the hold types. + // input.ActiveChild = weaponsOfSlotTypeSelected[GetNextWeaponIndex(activeCarriableOfSlotTypeIndex, weaponsOfSlotTypeSelected.Count)] as Entity; + //} } - int mouseWheelIndex = input.MouseWheel; + int mouseWheelIndex = Input.MouseWheel; if (mouseWheelIndex != 0) { int activeCarriableIndex = childrenList.FindIndex((p) => p is InventorySlot slot && slot.Carriable.Info.LibraryName == activeCarriable?.Info.LibraryName); int newSelectedIndex = NormalizeSlotIndex(-mouseWheelIndex + activeCarriableIndex, childrenList.Count - 1); - input.ActiveChild = (childrenList[newSelectedIndex] as InventorySlot)?.Carriable as Entity; + //input.ActiveChild = (childrenList[newSelectedIndex] as InventorySlot)?.Carriable as Entity; } } @@ -291,11 +291,11 @@ protected void ProcessClientInventorySelectionInput(InputBuilder input) private static int NormalizeSlotIndex(int index, int maxIndex) => index > maxIndex ? 0 : index < 0 ? maxIndex : index; - private int GetKeyboardNumberPressed(InputBuilder input) + private int GetKeyboardNumberPressed() { for (int i = 0; i < _slotInputButtons.Length; i++) { - if (input.Pressed(_slotInputButtons[i])) + if (Input.Pressed(_slotInputButtons[i])) { return i; } diff --git a/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySlot.cs b/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySlot.cs index ba2b6e091..3477922ca 100644 --- a/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySlot.cs +++ b/code/ui/generalhud/inventorywrapper/inventoryselection/InventorySlot.cs @@ -23,7 +23,7 @@ public InventorySlot(ICarriableItem carriable) NameLabel.UpdateTranslation(new TranslationData(Utils.GetTranslationKey(carriable.Info.LibraryName, "NAME"))); - if (Local.Pawn is Player player) + if (Game.LocalPawn is Player player) { if (carriable is Weapon weapon && carriable.CarriableInfo.Category != CarriableCategories.Melee) { @@ -36,7 +36,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is Player player) + if (Game.LocalPawn is Player player) { SlotLabel.Style.BackgroundColor = player.Team.Color; } diff --git a/code/ui/generalhud/mapselectionmenu/MapSelectionMenu.cs b/code/ui/generalhud/mapselectionmenu/MapSelectionMenu.cs index a1eb46e88..130b04e15 100644 --- a/code/ui/generalhud/mapselectionmenu/MapSelectionMenu.cs +++ b/code/ui/generalhud/mapselectionmenu/MapSelectionMenu.cs @@ -49,7 +49,7 @@ private List GetMapPanels() private void InitMapPanels() { - IDictionary mapImages = Gamemode.Game.Instance.MapSelection.MapImages; + IDictionary mapImages = Gamemode.TTTGame.Instance.MapSelection.MapImages; List mapPanels = GetMapPanels(); @@ -76,24 +76,24 @@ public override void Tick() return; } - IDictionary playerIdMapVote = Gamemode.Game.Instance.MapSelection.PlayerIdMapVote; + IDictionary playerIdMapVote = Gamemode.TTTGame.Instance.MapSelection.PlayerIdMapVote; IDictionary mapToVoteCount = Map.MapSelectionHandler.GetTotalVotesPerMap(playerIdMapVote); - bool hasLocalClientVoted = playerIdMapVote.ContainsKey(Local.Client.PlayerId); + bool hasLocalClientVoted = playerIdMapVote.ContainsKey(Game.LocalClient.SteamId); GetMapPanels().ForEach((mapPanel) => { mapPanel.TotalVotes.Text = mapToVoteCount.ContainsKey(mapPanel.MapName) ? $"{mapToVoteCount[mapPanel.MapName]}" : string.Empty; - mapPanel.SetClass("voted", hasLocalClientVoted && playerIdMapVote[Local.Client.PlayerId] == mapPanel.MapName); + mapPanel.SetClass("voted", hasLocalClientVoted && playerIdMapVote[Game.LocalClient.SteamId] == mapPanel.MapName); }); } [ConCmd.Server(Name = "ttt_vote_next_map")] public static void VoteNextMap(string name) { - long callerPlayerId = ConsoleSystem.Caller.PlayerId; - IDictionary nextMapVotes = Gamemode.Game.Instance.MapSelection.PlayerIdMapVote; + long callerPlayerId = ConsoleSystem.Caller.SteamId; + IDictionary nextMapVotes = Gamemode.TTTGame.Instance.MapSelection.PlayerIdMapVote; nextMapVotes[callerPlayerId] = name; diff --git a/code/ui/generalhud/playerinfo/PlayerInfoDisplay.cs b/code/ui/generalhud/playerinfo/PlayerInfoDisplay.cs index 0e875fa5c..46222258d 100644 --- a/code/ui/generalhud/playerinfo/PlayerInfoDisplay.cs +++ b/code/ui/generalhud/playerinfo/PlayerInfoDisplay.cs @@ -15,7 +15,7 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } diff --git a/code/ui/generalhud/playerinfo/PlayerRoleDisplay.cs b/code/ui/generalhud/playerinfo/PlayerRoleDisplay.cs index 5a2e9b585..687677f4b 100644 --- a/code/ui/generalhud/playerinfo/PlayerRoleDisplay.cs +++ b/code/ui/generalhud/playerinfo/PlayerRoleDisplay.cs @@ -15,12 +15,12 @@ public override void Tick() { base.Tick(); - if (Local.Pawn is not Player player) + if (Game.LocalPawn is not Player player) { return; } - this.Enabled(!player.IsSpectator && !player.IsSpectatingPlayer && Gamemode.Game.Instance.Round is Rounds.InProgressRound); + this.Enabled(!player.IsSpectator && !player.IsSpectatingPlayer && Gamemode.TTTGame.Instance.Round is Rounds.InProgressRound); if (this.IsEnabled()) { diff --git a/code/ui/generalhud/tabmenu/TabMenu.cs b/code/ui/generalhud/tabmenu/TabMenu.cs index dd1b4e990..4d10d4f2d 100644 --- a/code/ui/generalhud/tabmenu/TabMenu.cs +++ b/code/ui/generalhud/tabmenu/TabMenu.cs @@ -63,7 +63,7 @@ public void Init() // ForceSpectator button ForceSpectatorButton = SidebarPanel.Add.ButtonWithIcon(null, GetForcedSpectatorIcon(), "force-spectator", () => { - if (Local.Pawn is Player player) + if (Game.LocalPawn is Player player) { bool isForcedSpectator = player.IsForcedSpectator; @@ -76,7 +76,7 @@ public void Init() private static string GetForcedSpectatorIcon() { - if (Local.Pawn is Player player && player.IsForcedSpectator) + if (Game.LocalPawn is Player player && player.IsForcedSpectator) { return "visibility_off"; } diff --git a/code/ui/generalhud/tabmenu/gameresultsmenu/GameResultsMenu.cs b/code/ui/generalhud/tabmenu/gameresultsmenu/GameResultsMenu.cs index 84bedadc3..8cb9651cc 100644 --- a/code/ui/generalhud/tabmenu/gameresultsmenu/GameResultsMenu.cs +++ b/code/ui/generalhud/tabmenu/gameresultsmenu/GameResultsMenu.cs @@ -69,9 +69,9 @@ private void FilterEvents(bool isAll) { foreach (ILoggedGameEvent gameEvent in LoggedGameEvents) { - if (gameEvent.Contains(Sandbox.Local.Client)) + if (gameEvent.Contains(Sandbox.Game.LocalClient)) { - EventWrapper.AddChild(gameEvent.GetEventPanel(Sandbox.Local.Client)); + EventWrapper.AddChild(gameEvent.GetEventPanel(Sandbox.Game.LocalClient)); } } } diff --git a/code/ui/generalhud/tabmenu/scoreboard/Scoreboard.cs b/code/ui/generalhud/tabmenu/scoreboard/Scoreboard.cs index f0a2101ab..b9fb2b05d 100644 --- a/code/ui/generalhud/tabmenu/scoreboard/Scoreboard.cs +++ b/code/ui/generalhud/tabmenu/scoreboard/Scoreboard.cs @@ -38,7 +38,7 @@ public Scoreboard() private void Initialize() { - if (Host.IsServer) + if (Game.IsServer) { return; } @@ -48,7 +48,7 @@ private void Initialize() AddScoreboardGroup(defaultScoreboardGroup.ToString()); } - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { AddClient(client); } @@ -68,7 +68,7 @@ protected void OnPlayerSpawned(Player player) } [Event("player_connected")] - public void OnPlayerConnected(Client client) + public void OnPlayerConnected(IClient client) { AddClient(client); UpdateScoreboardGroups(); @@ -81,7 +81,7 @@ protected void OnPlayerDisconnected(long playerId, NetworkDisconnectionReason re UpdateScoreboardGroups(); } - public void AddClient(Client client) + public void AddClient(IClient client) { if (client == null) { @@ -90,7 +90,7 @@ public void AddClient(Client client) return; } - if (_entries.TryGetValue(client.PlayerId, out ScoreboardEntry _)) + if (_entries.TryGetValue(client.SteamId, out ScoreboardEntry _)) { return; } @@ -100,15 +100,15 @@ public void AddClient(Client client) scoreboardGroup.GroupMembers++; - _entries.Add(client.PlayerId, scoreboardEntry); + _entries.Add(client.SteamId, scoreboardEntry); scoreboardGroup.UpdateLabel(); ScoreboardHeader.UpdateServerInfo(); } - public void UpdateClient(Client client) + public void UpdateClient(IClient client) { - if (!_entries.TryGetValue(client.PlayerId, out ScoreboardEntry panel)) + if (!_entries.TryGetValue(client.SteamId, out ScoreboardEntry panel)) { return; } @@ -118,7 +118,7 @@ public void UpdateClient(Client client) if (scoreboardGroup.GroupTitle != panel.ScoreboardGroupName) { // instead of remove and add, move the panel into the right parent - RemoveClient(client.PlayerId); + RemoveClient(client.SteamId); AddClient(client); } else @@ -131,7 +131,7 @@ public void UpdateClient(Client client) public void Update() { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { UpdateClient(client); } @@ -161,13 +161,13 @@ public override void Tick() { base.Tick(); - bool invalidList = _entries.Count != Client.All.Count; + bool invalidList = _entries.Count != Game.Clients.Count; if (!invalidList) { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { - if (!_entries.ContainsKey(client.PlayerId)) + if (!_entries.ContainsKey(client.SteamId)) { invalidList = true; @@ -179,17 +179,17 @@ public override void Tick() if (!invalidList) { // Due to not having a `client.GetValue` change callback, we have to handle it differently - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { bool newIsForcedSpectator = client.GetValue("forcedspectator"); - if (!_forcedSpecList.TryGetValue(client.PlayerId, out bool isForcedSpectator)) + if (!_forcedSpecList.TryGetValue(client.SteamId, out bool isForcedSpectator)) { - _forcedSpecList.Add(client.PlayerId, newIsForcedSpectator); + _forcedSpecList.Add(client.SteamId, newIsForcedSpectator); } else if (isForcedSpectator != newIsForcedSpectator) { - _forcedSpecList[client.PlayerId] = newIsForcedSpectator; + _forcedSpecList[client.SteamId] = newIsForcedSpectator; UpdateClient(client); } @@ -204,7 +204,7 @@ public override void Tick() _entries.Clear(); - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { AddClient(client); } @@ -228,7 +228,7 @@ private ScoreboardGroup AddScoreboardGroup(string groupName) return scoreboardGroup; } - private ScoreboardGroup GetScoreboardGroup(Client client) + private ScoreboardGroup GetScoreboardGroup(IClient client) { string group = DefaultScoreboardGroup.Alive.ToString(); @@ -236,7 +236,7 @@ private ScoreboardGroup GetScoreboardGroup(Client client) { group = DefaultScoreboardGroup.Spectator.ToString(); } - else if (client.PlayerId != 0 && client.Pawn is Player player) + else if (client.SteamId != 0 && client.Pawn is Player player) { if (player.IsConfirmed) { diff --git a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardEntry.cs b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardEntry.cs index ab38cd1bb..b89599269 100644 --- a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardEntry.cs +++ b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardEntry.cs @@ -11,7 +11,7 @@ namespace TTTReborn.UI public class ScoreboardEntry : Panel { public string ScoreboardGroupName; - public Client Client; + public IClient Client; private Image PlayerAvatar { get; set; } private string PlayerName { get; set; } @@ -33,9 +33,9 @@ public virtual void Update() Score = Client.GetInt("score").ToString(); Karma = Client.GetInt("karma").ToString(); - SetClass("me", Client == Local.Client); + SetClass("me", Client == Game.LocalClient); - PlayerAvatar.SetTexture($"avatar:{Client.PlayerId}"); + PlayerAvatar.SetTexture($"avatar:{Client.SteamId}"); if (Client.Pawn is Player player && player.Role is not NoneRole && player.Role is not InnocentRole) { diff --git a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardGroup.cs b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardGroup.cs index 0eed7f503..125dfe030 100644 --- a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardGroup.cs +++ b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardGroup.cs @@ -28,7 +28,7 @@ public ScoreboardGroup(Panel parent, string groupName) : base(parent) GroupPingLabel.UpdateTranslation(new TranslationData("SCOREBOARD.COLUMNS.PING")); } - public ScoreboardEntry AddEntry(Client client) + public ScoreboardEntry AddEntry(IClient client) { ScoreboardEntry scoreboardEntry = GroupContent.AddChild(); scoreboardEntry.ScoreboardGroupName = GroupTitle; diff --git a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardHeader.cs b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardHeader.cs index b3f32033b..6fad9d79b 100644 --- a/code/ui/generalhud/tabmenu/scoreboard/ScoreboardHeader.cs +++ b/code/ui/generalhud/tabmenu/scoreboard/ScoreboardHeader.cs @@ -25,8 +25,8 @@ public ScoreboardHeader() public void UpdateServerInfo() { - ServerMapName = Global.MapName; - ServerPlayersLabel.UpdateTranslation(new TranslationData("SCOREBOARD.HEADER.PLAYERAMOUNT", Client.All.Count, ConsoleSystem.GetValue("maxplayers").ToInt(0))); + ServerMapName = Game.Server.MapIdent ; + ServerPlayersLabel.UpdateTranslation(new TranslationData("SCOREBOARD.HEADER.PLAYERAMOUNT", Game.Clients.Count, ConsoleSystem.GetValue("maxplayers").ToInt(0))); } } } diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/homepage/HomePage.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/homepage/HomePage.cs index f7c04312a..afb69bea1 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/homepage/HomePage.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/homepage/HomePage.cs @@ -31,15 +31,15 @@ public void GoToShopEditor() public HomePage() { - if (Local.Client.HasPermission("visualprogramming")) - { - RoleSelectionEditorButton.RemoveClass("inactive"); - } - - if (Local.Client.HasPermission("shopeditor")) - { - ShopEditorButton.RemoveClass("inactive"); - } + //if (Game.LocalClient.HasPermission("visualprogramming")) + //{ + // RoleSelectionEditorButton.RemoveClass("inactive"); + //} + + //if (Game.LocalClient.HasPermission("shopeditor")) + //{ + // ShopEditorButton.RemoveClass("inactive"); + //} } public void GoToComponentTesting() diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.FileSelection.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.FileSelection.cs index 03f6ede1a..80c2b2a4b 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.FileSelection.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.FileSelection.cs @@ -158,10 +158,10 @@ public partial class Player [ConCmd.Server(Name = "ttt_serversettings_saveas_request")] public static void RequestSaveServerSettingsAs(string filePath, string fileName, bool overwrite = false) { - if (!ConsoleSystem.Caller.HasPermission("serversettings")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("serversettings")) + //{ + // return; + //} if (overwrite || !FileSystem.Data.FileExists(filePath + fileName + SettingFunctions.SETTINGS_FILE_EXTENSION)) { @@ -185,10 +185,10 @@ public static void ClientAskOverwriteSelectedSettings(string filePath, string fi [ConCmd.Server(Name = "ttt_serversettings_loadfrom_request")] public static void RequestLoadFrom(string filePath, string fileName) { - if (!ConsoleSystem.Caller.HasPermission("serversettings")) - { - return; - } + //if (!ConsoleSystem.Caller.HasPermission("serversettings")) + //{ + // return; + //} SettingsManager.Instance = SettingFunctions.LoadSettings(filePath, fileName); diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.cs index ee1a321ee..46a39fa4f 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/SettingsPage.cs @@ -20,10 +20,10 @@ public partial class SettingsPage : Panel public SettingsPage() { - if (Local.Client.HasPermission("serversettings")) - { - ServerSettingsButton.RemoveClass("inactive"); - } + //if (Game.LocalClient.HasPermission("serversettings")) + //{ + // ServerSettingsButton.RemoveClass("inactive"); + //} } public void GoToClientSettings() @@ -37,154 +37,154 @@ public void GoToServerSettings() SettingFunctions.RequestServerSettings(); } - public static void CreateSettings(TranslationTabContainer tabContainer, Settings.Settings settings, Type settingsType = null) - { - settingsType ??= settings.GetType(); - - Type baseSettingsType = typeof(Settings.Settings); - - if (settingsType != baseSettingsType) - { - CreateSettings(tabContainer, settings, settingsType.BaseType); - } - - PropertyInfo[] properties = settingsType.GetProperties(); - string nsp = typeof(Settings.Categories.Round).Namespace; - - foreach (PropertyInfo propertyInfo in properties) - { - if (propertyInfo.DeclaringType.BaseType != baseSettingsType && settingsType != baseSettingsType || !propertyInfo.PropertyType.Namespace.Equals(nsp)) - { - continue; - } - - string categoryName = propertyInfo.Name; - object propertyObject = propertyInfo.GetValue(settings); - - if (propertyObject == null) - { - continue; - } - - Panel tab = new(); - tab.AddClass("root"); - - foreach (PropertyInfo subPropertyInfo in propertyInfo.PropertyType.GetProperties()) - { - foreach (object attribute in subPropertyInfo.GetCustomAttributes()) - { - if (attribute is not SettingAttribute settingAttribute) - { - continue; - } - - string propertyName = subPropertyInfo.Name; - - switch (settingAttribute) - { - case SwitchSettingAttribute: - CreateSwitchSetting(tab, settings, categoryName, propertyName, propertyObject); - - break; - - case InputSettingAttribute: - CreateInputSetting(tab, settings, categoryName, propertyName, propertyObject); - - break; - - case DropdownSettingAttribute: - CreateDropdownSetting(tab, settings, categoryName, propertyName, propertyObject, propertyInfo, subPropertyInfo); - - break; - } - - break; - } - - tab.Add.LineBreak(); - } - - tabContainer.AddTab(tab, new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.TITLE")); - } - } - - private static void CreateSwitchSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject) - { - TranslationCheckbox checkbox = parent.Add.TranslationCheckbox(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE")); - checkbox.AddTooltip(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION")); - checkbox.Checked = Utils.GetPropertyValue(propertyObject, propertyName); - checkbox.AddEventListener("onchange", (panelEvent) => - { - UpdateSettingsProperty(settings, propertyObject, propertyName, checkbox.Checked); - }); - } - - private static void CreateInputSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject) - { - CreateSettingsEntry(parent, $"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE", Utils.GetPropertyValue(propertyObject, propertyName).ToString(), $"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION", (value) => - { - UpdateSettingsProperty(settings, propertyObject, propertyName, value); - }); - } - - private static void CreateDropdownSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject, PropertyInfo propertyInfo, PropertyInfo subPropertyInfo) - { - parent.Add.Panel(categoryName.ToLower()); - parent.Add.TranslationLabel(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE"), "h3").AddTooltip(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION")); - - TranslationDropdown dropdownSelection = parent.Add.TranslationDropdown(); - - foreach (PropertyInfo possibleDropdownPropertyInfo in propertyInfo.PropertyType.GetProperties()) - { - foreach (object possibleDropdownAttribute in possibleDropdownPropertyInfo.GetCustomAttributes()) - { - if (possibleDropdownAttribute is DropdownOptionsAttribute dropdownOptionsAttribute && dropdownOptionsAttribute.DropdownSetting.Equals(subPropertyInfo.Name)) - { - dropdownSelection.AddEventListener("onchange", (e) => - { - UpdateSettingsProperty(settings, propertyObject, propertyName, dropdownSelection.Selected.Value); - }); - - foreach (KeyValuePair keyValuePair in Utils.GetPropertyValue>(propertyObject, possibleDropdownPropertyInfo.Name)) - { - Option option; - - if (dropdownOptionsAttribute.AvoidTranslation) - { - option = new Option(keyValuePair.Key, keyValuePair.Value); - } - else - { - option = new TranslationOption(new TranslationData(keyValuePair.Key), keyValuePair.Value); - } - - dropdownSelection.Options.Add(option); - } - } - } - } - - dropdownSelection.Select(Utils.GetPropertyValue(propertyObject, propertyName)); - } - - private static void UpdateSettingsProperty(Settings.Settings settings, object propertyObject, string propertyName, T value) - { - Utils.SetPropertyValue(propertyObject, propertyName, value); - - if (Gamemode.Game.Instance.Debug) - { - Log.Debug($"Set {propertyName} to {value}"); - } - - if (settings is ServerSettings serverSettings) - { - SettingFunctions.SendSettingsToServer(serverSettings); - } - else - { - GameEvent.Register(new Events.Settings.ChangeEvent()); - } - } + //public static void CreateSettings(TranslationTabContainer tabContainer, Settings.Settings settings, Type settingsType = null) + //{ + // settingsType ??= settings.GetType(); + + // Type baseSettingsType = typeof(Settings.Settings); + + // if (settingsType != baseSettingsType) + // { + // CreateSettings(tabContainer, settings, settingsType.BaseType); + // } + + // PropertyInfo[] properties = settingsType.GetProperties(); + // string nsp = typeof(Settings.Categories.Round).Namespace; + + // foreach (PropertyInfo propertyInfo in properties) + // { + // if (propertyInfo.DeclaringType.BaseType != baseSettingsType && settingsType != baseSettingsType || !propertyInfo.PropertyType.Namespace.Equals(nsp)) + // { + // continue; + // } + + // string categoryName = propertyInfo.Name; + // object propertyObject = propertyInfo.GetValue(settings); + + // if (propertyObject == null) + // { + // continue; + // } + + // Panel tab = new(); + // tab.AddClass("root"); + + // foreach (PropertyInfo subPropertyInfo in propertyInfo.PropertyType.GetProperties()) + // { + // foreach (object attribute in subPropertyInfo.GetCustomAttributes()) + // { + // if (attribute is not SettingAttribute settingAttribute) + // { + // continue; + // } + + // string propertyName = subPropertyInfo.Name; + + // switch (settingAttribute) + // { + // case SwitchSettingAttribute: + // CreateSwitchSetting(tab, settings, categoryName, propertyName, propertyObject); + + // break; + + // case InputSettingAttribute: + // CreateInputSetting(tab, settings, categoryName, propertyName, propertyObject); + + // break; + + // case DropdownSettingAttribute: + // CreateDropdownSetting(tab, settings, categoryName, propertyName, propertyObject, propertyInfo, subPropertyInfo); + + // break; + // } + + // break; + // } + + // tab.Add.LineBreak(); + // } + + // tabContainer.AddTab(tab, new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.TITLE")); + // } + //} + + //private static void CreateSwitchSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject) + //{ + // TranslationCheckbox checkbox = parent.Add.TranslationCheckbox(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE")); + // checkbox.AddTooltip(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION")); + // checkbox.Checked = Utils.GetPropertyValue(propertyObject, propertyName); + // checkbox.AddEventListener("onchange", (panelEvent) => + // { + // UpdateSettingsProperty(settings, propertyObject, propertyName, checkbox.Checked); + // }); + //} + + //private static void CreateInputSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject) + //{ + // CreateSettingsEntry(parent, $"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE", Utils.GetPropertyValue(propertyObject, propertyName).ToString(), $"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION", (value) => + // { + // UpdateSettingsProperty(settings, propertyObject, propertyName, value); + // }); + //} + + //private static void CreateDropdownSetting(Panel parent, Settings.Settings settings, string categoryName, string propertyName, object propertyObject, PropertyInfo propertyInfo, PropertyInfo subPropertyInfo) + //{ + // parent.Add.Panel(categoryName.ToLower()); + // parent.Add.TranslationLabel(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.TITLE"), "h3").AddTooltip(new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.{propertyName.ToUpper()}.DESCRIPTION")); + + // TranslationDropdown dropdownSelection = parent.Add.TranslationDropdown(); + + // foreach (PropertyInfo possibleDropdownPropertyInfo in propertyInfo.PropertyType.GetProperties()) + // { + // foreach (object possibleDropdownAttribute in possibleDropdownPropertyInfo.GetCustomAttributes()) + // { + // if (possibleDropdownAttribute is DropdownOptionsAttribute dropdownOptionsAttribute && dropdownOptionsAttribute.DropdownSetting.Equals(subPropertyInfo.Name)) + // { + // dropdownSelection.AddEventListener("onchange", (e) => + // { + // UpdateSettingsProperty(settings, propertyObject, propertyName, dropdownSelection.Selected.Value); + // }); + + // foreach (KeyValuePair keyValuePair in Utils.GetPropertyValue>(propertyObject, possibleDropdownPropertyInfo.Name)) + // { + // Option option; + + // if (dropdownOptionsAttribute.AvoidTranslation) + // { + // option = new Option(keyValuePair.Key, keyValuePair.Value); + // } + // else + // { + // option = new TranslationOption(new TranslationData(keyValuePair.Key), keyValuePair.Value); + // } + + // dropdownSelection.Options.Add(option); + // } + // } + // } + // } + + // dropdownSelection.Select(Utils.GetPropertyValue(propertyObject, propertyName)); + //} + + //private static void UpdateSettingsProperty(Settings.Settings settings, object propertyObject, string propertyName, T value) + //{ + // Utils.SetPropertyValue(propertyObject, propertyName, value); + + // if (Gamemode.TTTGame.Instance.Debug) + // { + // Log.Debug($"Set {propertyName} to {value}"); + // } + + // if (settings is ServerSettings serverSettings) + // { + // SettingFunctions.SendSettingsToServer(serverSettings); + // } + // else + // { + // GameEvent.Register(new Events.Settings.ChangeEvent()); + // } + //} public static TextEntry CreateSettingsEntry(Panel parent, string title, T defaultValue, string description, Action OnSubmit = null, Action OnChange = null) { diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/clientsettingspage/ClientSettingsPage.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/clientsettingspage/ClientSettingsPage.cs index 778d68c37..d76ddb366 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/clientsettingspage/ClientSettingsPage.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/clientsettingspage/ClientSettingsPage.cs @@ -12,7 +12,7 @@ public partial class ClientSettingsPage : Panel public ClientSettingsPage() { - SettingsPage.CreateSettings(TabContainer, ClientSettings.Instance); + //SettingsPage.CreateSettings(TabContainer, ClientSettings.Instance); SettingsPage.CreateFileSelectionButtons(Buttons, false); } } diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/serversettingspage/ServerSettingsPage.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/serversettingspage/ServerSettingsPage.cs index 97689d97f..e7234f3fb 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/serversettingspage/ServerSettingsPage.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/settingspage/serversettingspage/ServerSettingsPage.cs @@ -12,7 +12,7 @@ public partial class ServerSettingsPage : Panel public ServerSettingsPage(ServerSettings serverSettings) { - SettingsPage.CreateSettings(TabContainer, serverSettings); + //SettingsPage.CreateSettings(TabContainer, serverSettings); SettingsPage.CreateFileSelectionButtons(Buttons, true); } } diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Commands.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Commands.cs index 2a9e1a217..71c20dd76 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Commands.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Commands.cs @@ -20,12 +20,12 @@ public static void ServerRequestShopEditorAccess() To to = To.Single(ConsoleSystem.Caller); - if (!ConsoleSystem.Caller.HasPermission("shopeditor")) - { - ClientReceiveShopEditorAccess(to, false); + //if (!ConsoleSystem.Caller.HasPermission("shopeditor")) + //{ + // ClientReceiveShopEditorAccess(to, false); - return; - } + // return; + //} foreach (Type roleType in Utils.GetTypes()) { @@ -66,10 +66,10 @@ public static void ClientReceiveShopEditorAccess(bool _) [ConCmd.Server] public static void ServerToggleShop(string roleName, bool toggle) { - if (!(ConsoleSystem.Caller?.HasPermission("shopeditor") ?? false)) - { - return; - } + //if (!(ConsoleSystem.Caller?.HasPermission("shopeditor") ?? false)) + //{ + // return; + //} if (ProcessShopToggle(roleName, toggle)) { @@ -103,9 +103,9 @@ private static bool ProcessShopToggle(string roleName, bool toggle) role.Shop.Enabled = toggle; - if (Host.IsServer) + if (Game.IsServer) { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player && player.Role.Equals(roleName)) { @@ -113,7 +113,7 @@ private static bool ProcessShopToggle(string roleName, bool toggle) } } } - else if (Local.Client?.Pawn is Player player && player.Role.Name.Equals(roleName)) + else if (Game.LocalClient?.Pawn is Player player && player.Role.Name.Equals(roleName)) { player.Shop.Enabled = toggle; } diff --git a/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Item.Commands.cs b/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Item.Commands.cs index 34c8b5656..a6d8846e8 100644 --- a/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Item.Commands.cs +++ b/code/ui/generalhud/tabmenu/tttmenu/pages/shopeditorpage/ShopEditorPage.Item.Commands.cs @@ -23,10 +23,10 @@ private static void ToggleItem(QuickShopItem item, Role role) [ConCmd.Server] public static void ServerUpdateItem(string itemName, bool toggle, string shopItemDataJson, string roleName) { - if (!(ConsoleSystem.Caller?.HasPermission("shopeditor") ?? false)) - { - return; - } + //if (!(ConsoleSystem.Caller?.HasPermission("shopeditor") ?? false)) + //{ + // return; + //} if (ProcessItemUpdate(itemName, toggle, shopItemDataJson, roleName, out _)) { @@ -82,9 +82,9 @@ private static bool ProcessItemUpdate(string itemName, bool toggle, string shopI UpdateShop(role.Shop, toggle, itemName, shopItemData); - if (Host.IsServer) + if (Game.IsServer) { - foreach (Client client in Client.All) + foreach (IClient client in Game.Clients) { if (client.Pawn is Player player && player.Role.Equals(roleName)) { @@ -92,7 +92,7 @@ private static bool ProcessItemUpdate(string itemName, bool toggle, string shopI } } } - else if (Local.Client?.Pawn is Player player && player.Role.Name.Equals(roleName)) + else if (Game.LocalClient?.Pawn is Player player && player.Role.Name.Equals(roleName)) { UpdateShop(player.Shop, toggle, itemName, shopItemData); diff --git a/code/ui/generalhud/voicechat/VoiceChatDisplay.cs b/code/ui/generalhud/voicechat/VoiceChatDisplay.cs index 22c02b5bb..1c60a19ac 100644 --- a/code/ui/generalhud/voicechat/VoiceChatDisplay.cs +++ b/code/ui/generalhud/voicechat/VoiceChatDisplay.cs @@ -18,9 +18,9 @@ public VoiceChatDisplay() : base() AddClass("voicechat-display"); } - public void OnVoicePlayed(Client client, float level) + public void OnVoicePlayed(IClient client, float level) { - VoiceChatEntry entry = ChildrenOfType().FirstOrDefault(x => x.Friend.Id == client.PlayerId); + VoiceChatEntry entry = ChildrenOfType().FirstOrDefault(x => x.Friend.Id == client.SteamId); if (entry == null) { diff --git a/code/ui/generalhud/voicechat/VoiceChatEntry.cs b/code/ui/generalhud/voicechat/VoiceChatEntry.cs index 305a94707..abb2378ca 100644 --- a/code/ui/generalhud/voicechat/VoiceChatEntry.cs +++ b/code/ui/generalhud/voicechat/VoiceChatEntry.cs @@ -18,7 +18,7 @@ public string Name get => Friend.Name; } public Image Avatar { get; set; } - public Client Client { get; } + public IClient Client { get; } private float _voiceLevel = 0.5f; private float _targetVoiceLevel = 0; @@ -26,12 +26,12 @@ public string Name private RealTimeSince _timeSincePlayed; - public VoiceChatEntry(Client client) + public VoiceChatEntry(IClient client) { Client = client; - Friend = new(client.PlayerId); + Friend = new(client.SteamId); - Avatar.SetTexture($"avatar:{client.PlayerId}"); + Avatar.SetTexture($"avatar:{client.SteamId}"); } public void Update(float level) diff --git a/code/ui/richpanel/RichPanel.Resizeable.cs b/code/ui/richpanel/RichPanel.Resizeable.cs index ac8d9f174..fd921a7e5 100644 --- a/code/ui/richpanel/RichPanel.Resizeable.cs +++ b/code/ui/richpanel/RichPanel.Resizeable.cs @@ -137,12 +137,12 @@ protected override void OnMouseDown(MousePanelEvent e) _draggingMouseStartPosition = Mouse.Position; _boxDataBeforeDraggingStarted = new BoxData { - Width = (float) Math.Ceiling(Box.Rect.width), - Height = (float) Math.Ceiling(Box.Rect.height), - Top = (float) Math.Ceiling(Box.Rect.top), - Right = (float) Math.Ceiling(Box.Rect.right), - Bottom = (float) Math.Ceiling(Box.Rect.bottom), - Left = (float) Math.Ceiling(Box.Rect.left) + Width = (float) Math.Ceiling(Box.Rect.Width), + Height = (float) Math.Ceiling(Box.Rect.Height), + Top = (float) Math.Ceiling(Box.Rect.Top), + Right = (float) Math.Ceiling(Box.Rect.Right), + Bottom = (float) Math.Ceiling(Box.Rect.Bottom), + Left = (float) Math.Ceiling(Box.Rect.Left) }; Matrix? matrix = GlobalMatrix; @@ -186,10 +186,10 @@ protected override void OnMouseMove(MousePanelEvent e) float screenWidth = Screen.Width; float screenHeight = Screen.Height; - float width = Box.Rect.width; - float height = Box.Rect.height; - float left = Box.Rect.left; - float top = Box.Rect.top; + float width = Box.Rect.Width; + float height = Box.Rect.Height; + float left = Box.Rect.Left; + float top = Box.Rect.Top; float minWidth = ComputedStyle.MinWidth != null ? ComputedStyle.MinWidth.Value.GetPixels(screenWidth) : width; float maxWidth = ComputedStyle.MaxWidth != null ? ComputedStyle.MaxWidth.Value.GetPixels(screenWidth) : width; @@ -296,7 +296,7 @@ public override void Tick() { CurrentHorizontalDragAnchor = DragAnchor.LEFT; } - else if (MousePosition.x < Box.Rect.width && MousePosition.x > Box.Rect.width - DRAG_OBLIGINGNESS) + else if (MousePosition.x < Box.Rect.Width && MousePosition.x > Box.Rect.Width - DRAG_OBLIGINGNESS) { CurrentHorizontalDragAnchor = DragAnchor.RIGHT; } @@ -309,7 +309,7 @@ public override void Tick() { CurrentVerticalDragAnchor = DragAnchor.TOP; } - else if (MousePosition.y < Box.Rect.height && MousePosition.y > Box.Rect.height - DRAG_OBLIGINGNESS) + else if (MousePosition.y < Box.Rect.Height && MousePosition.y > Box.Rect.Height - DRAG_OBLIGINGNESS) { CurrentVerticalDragAnchor = DragAnchor.BOTTOM; } diff --git a/code/ui/visual-programming/nodes/node/Node.cs b/code/ui/visual-programming/nodes/node/Node.cs index 4d06a8256..22f499d06 100644 --- a/code/ui/visual-programming/nodes/node/Node.cs +++ b/code/ui/visual-programming/nodes/node/Node.cs @@ -279,7 +279,7 @@ public virtual void Prepare() InputData = new object[inputConnectionCount]; - StackNode.SetPos(Box.Rect.left, Box.Rect.top); + StackNode.SetPos(Box.Rect.Left, Box.Rect.Top); } } @@ -501,7 +501,7 @@ public void ConnectWithNode(Node node) ["LibraryName"] = LibraryName, ["ConnectionInputIds"] = ConnectionInputIds, ["ConnectionOutputIds"] = ConnectionOutputIds, - ["Pos"] = new Vector2(Box.Rect.left, Box.Rect.top), + ["Pos"] = new Vector2(Box.Rect.Left, Box.Rect.Top), }; public virtual void LoadFromJsonData(Dictionary jsonData) diff --git a/code/ui/visual-programming/nodes/node/NodeConnectionPoint.cs b/code/ui/visual-programming/nodes/node/NodeConnectionPoint.cs index 0aa892462..aea7e6f22 100644 --- a/code/ui/visual-programming/nodes/node/NodeConnectionPoint.cs +++ b/code/ui/visual-programming/nodes/node/NodeConnectionPoint.cs @@ -24,7 +24,7 @@ public Vector2 Position { Rect rect = Box.Rect; - return new Vector2(rect.left + rect.width * 0.5f, rect.top + rect.height * 0.5f); + return new Vector2(rect.Left + rect.Width * 0.5f, rect.Top + rect.Height * 0.5f); } } diff --git a/code/ui/visual-programming/nodes/node/NodeConnectionWire.cs b/code/ui/visual-programming/nodes/node/NodeConnectionWire.cs index 52636c72d..4d26bac25 100644 --- a/code/ui/visual-programming/nodes/node/NodeConnectionWire.cs +++ b/code/ui/visual-programming/nodes/node/NodeConnectionWire.cs @@ -82,8 +82,8 @@ public void UpdateMousePosition(Vector2 vector2) Vector2 pos = StartPoint.Position; Vector2 delta = vector2 - pos; - Vector2 finalPos = new(pos); - Vector2 finalSize = new(delta); + Vector2 finalPos = new(pos.x, pos.y); + Vector2 finalSize = new(delta.x, delta.y); float halfLineThickness = LINE_THICKNESS * 0.5f; diff --git a/code/visual-programming/NodeStack.Networking.cs b/code/visual-programming/NodeStack.Networking.cs index 7039fd351..7e9a4010c 100644 --- a/code/visual-programming/NodeStack.Networking.cs +++ b/code/visual-programming/NodeStack.Networking.cs @@ -24,12 +24,12 @@ public static void ServerRequestStack() To to = To.Single(ConsoleSystem.Caller); - if (!ConsoleSystem.Caller.HasPermission("visualprogramming")) - { - ClientInitializeNodesFromStack(to, false); + //if (!ConsoleSystem.Caller.HasPermission("visualprogramming")) + //{ + // ClientInitializeNodesFromStack(to, false); - return; - } + // return; + //} ClientInitializeNodesFromStack(to, true, JsonSerializer.Serialize(Instance.GetJsonData())); } @@ -72,10 +72,10 @@ public static void ClientSendStackBuildResult() [ConCmd.Server] private static void ServerUploadPartialStack(int packetHash, int packetNum, int maxPackets, string partialStack) { - if (!ConsoleSystem.Caller?.HasPermission("visualprogramming") ?? true) - { - return; - } + //if (!ConsoleSystem.Caller?.HasPermission("visualprogramming") ?? true) + //{ + // return; + //} ProceedPartialUpload(packetHash, packetNum, maxPackets, partialStack); @@ -177,10 +177,10 @@ private static void ProceedPartialUpload(int packetHash, int packetNum, int maxP [ConCmd.Server] public static void ServerResetStack() { - if (!ConsoleSystem.Caller?.HasPermission("visualprogramming") ?? true) - { - return; - } + //if (!ConsoleSystem.Caller?.HasPermission("visualprogramming") ?? true) + //{ + // return; + //} Instance.Init(); diff --git a/code/visual-programming/nodes/PercentageSelectionStackNode.cs b/code/visual-programming/nodes/PercentageSelectionStackNode.cs index 7a2189e20..8b5d9eb59 100644 --- a/code/visual-programming/nodes/PercentageSelectionStackNode.cs +++ b/code/visual-programming/nodes/PercentageSelectionStackNode.cs @@ -32,7 +32,7 @@ public override object[] Test(object[] input) return buildArray; } - int allPlayerAmount = Client.All.Count; // TODO just use available players, not specs + int allPlayerAmount = Game.Clients.Count; // TODO just use available players, not specs int[] playerAmounts = new int[percentListCount]; int count = 0; diff --git a/code/visual-programming/nodes/PlayerAmountSelectionStackNode.cs b/code/visual-programming/nodes/PlayerAmountSelectionStackNode.cs index 896f5b396..e1821b7c3 100644 --- a/code/visual-programming/nodes/PlayerAmountSelectionStackNode.cs +++ b/code/visual-programming/nodes/PlayerAmountSelectionStackNode.cs @@ -24,7 +24,7 @@ public override object[] Test(object[] input) return null; } - int allPlayerAmount = Client.All.Count; // TODO just use available players, not specs + int allPlayerAmount = Game.Clients.Count; // TODO just use available players, not specs object[] buildArray = new object[playerAmountListCount]; diff --git a/code/world-ui/RoleWorldIcon.cs b/code/world-ui/RoleWorldIcon.cs index 1835f2613..b75e71cc4 100644 --- a/code/world-ui/RoleWorldIcon.cs +++ b/code/world-ui/RoleWorldIcon.cs @@ -31,7 +31,7 @@ public override void Tick() { base.Tick(); - if (!Player.IsValid || Player.LifeState != LifeState.Alive || Local.Pawn is Player localPlayer && !Player.IsTeamMember(localPlayer)) + if (!Player.IsValid || Player.LifeState != LifeState.Alive || Game.LocalPawn is Player localPlayer && !Player.IsTeamMember(localPlayer)) { this.Enabled(false); } @@ -55,9 +55,9 @@ public override void Tick() private Transform GetTransform() { - Transform transform = Player.GetBoneTransform(Player.GetHitboxBone((int) HitboxIndex.Head)).WithScale(0.125f); + Transform transform = Player.GetBoneTransform((int) HitboxIndex.Head).WithScale(0.125f); transform.Position += Vector3.Up * 22.5f; - transform.Rotation = Rotation.LookAt(-CurrentView.Rotation.Forward); + transform.Rotation = Sandbox.Camera.Rotation; return transform; } diff --git a/lang/de-DE.json b/lang/de-DE.json new file mode 100644 index 000000000..3d9c5dc1a --- /dev/null +++ b/lang/de-DE.json @@ -0,0 +1,410 @@ +{ + "__LANGUAGE__": { + "NAME": "Deutsch", + "CODE": "de-DE" + }, + "ROLE": { + "NONE": { + "NAME": "Unbekannt" + }, + "INNOCENT": { + "NAME": "Unschuldiger" + }, + "TRAITOR": { + "NAME": "Verräter" + }, + "DETECTIVE": { + "NAME": "Detektiv" + } + }, + "TEAM": { + "INNOCENTS": { + "NAME": "Unschuldige", + "WIN": "DIE UNSCHULDIGEN GEWINNEN!" + }, + "TRAITORS": { + "NAME": "Verräter", + "WIN": "DIE VERRÄTER GEWINNEN!" + }, + "NONES": { + "NAME": "Niemand", + "WIN": "UNENTSCHIEDEN!" + } + }, + "WIN": { + "DESCRIPTION": "Danke, dass Du TTT Reborn spielst, weitere Updates und Statistiken werden folgen!" + }, + "ROUND": { + "STATE": { + "WAITING": "Warten", + "PREPARING": "Vorbereitung", + "IN_PROGRESS": "Im Gange", + "POST": "Runde vorbei", + "MAP_SELECTION": "Wähle eine Map" + } + }, + "PLAYER": { + "STATUS": { + "HEALTH": { + "HEALTHY": "Gesund", + "HURT": "Verletzt", + "WOUNDED": "Verwundet", + "BADLY_WOUNDED": "Schwer verwundet", + "NEAR_DEATH": "Dem Tode nahe", + "DEAD": "Tot" + } + } + }, + "CORPSE": { + "INSPECT": { + "QUICKINFO": { + "HEADSHOT": "Kopfschuss", + "SUICIDE": "Selbstmord", + "DISTANCE": "{0}m", + "TIME": "{0}" + }, + "IDENTIFIER": { + "TIMESINCEDEATH": "Er/Sie starb vor ungefähr {0}.", + "HEADSHOT": "Die tötliche Wunde war ein Kopfschuss. Keine Zeit zum Schreien.", + "SUICIDE": "Du kannst keinen spezifischen Grund für den Tod dieses Terry's finden.", + "KILLED": "Er/Sie wurde von etwa {0}m entfernt getötet.", + "WEAPON": "Es scheint, als wäre '{0}' genutzt worden, um Ihn/Sie zu töten.", + "PERK": "Er/Sie trug '{0}'." + } + }, + "USE": { + "IDENTIFY": "Halten, um die Leiche zu identifizieren", + "INSPECT": "Halten, um die Leiche zu inspizieren", + "COVERTINSPECT": "Halten, um die Leiche verdeckt zu inspizieren" + } + }, + "SCOREBOARD": { + "HEADER": { + "GAMEMODE": "{0} Server", + "CREATEDBY": "Erstellt von {0}", + "PLAYERAMOUNT": "{0} / {1} Spieler", + "SERVERINFO": "{0} Spieler. Map: {1}", + "PLAYERSLEFT": "{0} Spieler verbleibend" + }, + "GROUP": { + "ALIVE": "Lebendig", + "DEAD": "Bestätigte Tode", + "MISSING": "Vermisst", + "SPECTATOR": "Zuschauer" + }, + "COLUMNS": { + "KARMA": "Karma", + "DEATHS": "Tode", + "SCORE": "Punkte", + "PING": "Ping" + } + }, + "QUICKSHOP": { + "CREDITS": { + "DESCRIPTION": "Du hast ${0}" + }, + "ITEM": { + "DESCRIPTION": "Die Beschreibung für das Item '{0}' wird sich später an dieser Stelle befinden." + } + }, + "REALM": { + "CLIENT": "Client", + "SERVER": "Server" + }, + "MENU": { + "SETTINGS": { + "TITLE": "Einstellungen", + "CLIENT": "Client Einstellungen", + "SERVER": "Server Einstellungen", + "LOADING": "Lade...", + "TABS": { + "GENERAL": { + "TITLE": "Allgemein", + "LANGUAGE": { + "TITLE" : "Sprache", + "DESCRIPTION": "Die Anzeige-Sprache für den Nutzer" + }, + "RETURNMISSINGKEYS": { + "TITLE": "Debuggung: Gebe fehlende Language-Keys zurück", + "DESCRIPTION": "Falls es einen fehlenden Language-Key gibt, gebe diesen statt des Fallbacks zurück." + } + }, + "DEBUG": { + "TITLE": "Debug", + "PREVENTWIN": { + "TITLE": "Sieg unterbinden", + "DESCRIPTION": "Soll das Rundenende aufgrund eines Sieges basierend auf Zeitablauf oder erfüllte Siegbedingung unterbunden werden? (Map-Trigger ausgenommen)" + } + }, + "AFK": { + "TITLE": "AFK", + "SECONDSTILLKICK": { + "TITLE": "AFK Zeit", + "DESCRIPTION": "Die Zeit bevor der Spieler als AFK markiert wird." + }, + "SHOULDKICKPLAYERS": { + "TITLE": "Sollen AFK-Spieler gekickt werden?", + "DESCRIPTION": "Ob ein Spieler gekickt oder (falls deaktiviert) als Zuschauer gesetzt werden soll." + } + }, + "MOVEMENT": { + "TITLE": "Sprinten", + "ISSPRINTENABLED": { + "TITLE" : "Sprinten aktivieren?", + "DESCRIPTION": "Ob Sprinten auf dem Server aktiviert sein soll." + } + }, + "ROUND": { + "TITLE": "Runden", + "MINPLAYERS": { + "TITLE": "Minimum Spieler", + "DESCRIPTION": "Die minimale Anzahl an Spielern, die für den Start des Spiels benötigt werden. Falls die Spielerzahl unterhalb der gesetzten Zahl fällt, wird das Spiel abgebrochen, sofern es bereits gestartet ist." + }, + "PREROUNDTIME": { + "TITLE": "Vorbereitungszeit", + "DESCRIPTION": "Die Zeit, wie lange die Vorbereitungsrunde gehen soll." + }, + "ROUNDTIME": { + "TITLE": "Rundenzeit", + "DESCRIPTION": "Die Zeit, wie lange die Hauptrunde gehen soll." + }, + "POSTROUNDTIME": { + "TITLE": "Nachrundenzeit", + "DESCRIPTION": "Die Zeit, bevor die nächste Runde startet." + }, + "MAPSELECTIONROUNDTIME": { + "TITLE": "Mapauswahl: Rundenzeit", + "DESCRIPTION": "Die Zeit für die Mapauswahl" + }, + "TOTALROUNDS": { + "TITLE": "Maximale Rundenanzahl", + "DESCRIPTION": "Maximale Rundenanzahl, bis es zur Mapauswahl kommt" + }, + "KILLTIMEREWARD": { + "TITLE": "Belohnungszeit für Tötung", + "DESCRIPTION": "Die Extrazeit, die ein Verräter für das Töten von Unschuldigen bekommt." + } + }, + "MAP": { + "TITLE": "Map", + "DEFAULTMAP": { + "TITLE": "Standard-Map", + "DESCRIPTION": "Wähle eine Map aus, welche standardmäßig ausgewählt wird." + } + } + }, + "BUTTONS": { + "SAVE": "Speichern", + "LOAD": "Laden", + "OVERWRITE": { + "TITLE": "Überschreibe '{0}'", + "DESCRIPTION": "Möchtest du '{0}' mit den aktuellen Einstellungen überschreiben? (Falls du zustimmst, gehen die Einstellungen, die in der ausgewählten Datei gespeichert sind, verloren!)" + } + } + }, + "KEYBINDINGS": { + "TITLE": "Tastaturbelegung", + "RESTRICTION": "Wegen Restriktionen der S&Box Entwickler kannst Du deine Keybindings leider nur im S&Box Optionsmenü oder über die Konsole ändern.", + "MOVEMENT": { + "TITLE": "Bewegung", + "FORWARD": "Vorwärts", + "BACK": "Rückwärts", + "LEFT": "Links", + "RIGHT": "Rechts", + "JUMP": "Springen", + "CROUCH": "Ducken", + "SPRINT": "Sprinten" + }, + "WEAPONS": { + "TITLE": "Waffen", + "FIRE": "Feuern", + "RELOAD": "Nachladen", + "DROP_WEAPON": "Waffe fallenlassen", + "DROP_AMMO": "Munition fallenlassen" + }, + "ACTIONS": { + "TITLE": "Aktionen", + "USE": "Nutzen", + "FLASHLIGHT": "Taschenlampe" + }, + "COMMUNICATION": { + "TITLE": "Kommunikation", + "VOICECHAT": "Sprachchat", + "TEAMVOICECHAT": "Team-Sprachchat", + "TEAMTEXTCHAT": "Team-Textchat" + }, + "MENUS": { + "TITLE": "Menüs", + "MENU": "Scoreboard, Menü, Logs etc.", + "QUICKSHOP": "QuickShop" + } + }, + "TESTING": { + "TITLE": "Testen", + "FILESELECTION": "Explorer" + }, + "SHOPEDITOR": { + "TITLE": "Shop Editor", + "TOGGLEROLE": "Umschalten, um den Shop für die aktuell ausgewählte Rolle zu de-/aktivieren.", + "SELECTROLE": "Wähle eine Rolle aus, um den damit verbundenen Shop zu modifizieren.", + "ENABLEROLE": "Aktiviert", + "NOPERMISSION": "Du hast keine Berechtigungen, um auf den ShopEditor zuzugreifen.", + "EDIT": { + "TITLE": "Bearbeite das Item.", + "DESCRIPTION": "Bearbeite das Item '{0}'" + }, + "PRICE": { + "TITLE": "Preis", + "DESCRIPTION": "Der Preis von: '{0}'." + } + }, + "ROLEEDITOR": { + "TITLE": "Role Editor", + "RESET": { + "TITLE": "RoleSelection zurücksetzen", + "DESCRIPTION": "Bist du dir sicher, dass du die RoleSelection zurücksetzen willst?" + } + } + }, + "GAMERESULTSMENU": { + "EMPTY": "Events werden erst zum Rundenende erstellt.", + "TITLE": "Events der letzten Runde:", + "ALLFILTER": "Global", + "PLAYERFILTER": "Du", + "EVENTS": { + "SCORING": { + "PLAYERNAME": "Spielername", + "SCORE": "Punkte", + "KARMA": "Karma" + } + } + }, + "MAPSELECTION": { + "VOTE": "Wähle die nächste Map!" + }, + "WEAPON": { + "PISTOL": { + "NAME": "Pistole" + }, + "SMG": { + "NAME": "SMG" + }, + "SHOTGUN": { + "NAME": "Schrot" + }, + "SNIPER": { + "NAME": "Scharfschützengewehr" + }, + "KNIFE": { + "NAME": "Messer" + }, + "NEWTONLAUNCHER": { + "NAME": "Newtonlauncher" + }, + "OFFENSIVEEQUIPMENT": { + "NAME": "Offensives Equipment" + }, + "RPG7": { + "NAME": "RPG-7" + }, + "BAYONET": { + "NAME": "Bayonet" + }, + "DEAGLE": { + "NAME": "Desert Eagle" + }, + "FAL": { + "NAME": "FAL" + }, + "L96A1": { + "NAME": "L96A1" + }, + "SPAS12": { + "NAME": "SPAS12" + }, + "UMP45": { + "NAME": "UMP45" + }, + "AMMO": { + "NAME": "Munition", + "WEAPON": "{0} Munition" + }, + "USE": "Drücken, um '{0}' aufzuheben" + }, + "EQUIPMENT": { + "HANDS": { + "NAME": "Hände" + }, + "C4": { + "NAME": "C4", + "UI": { + "PICKUP": "Aufheben", + "DESTROY": "Zerstören", + "ARM": "Schärfen", + "DEFUSECHANCE": "{0}% Chance zu entschärfen" + }, + "USE": { + "ARM": "Halten, um das C4 scharf zu machen", + "DEFUSE": "Drücken, um das C4 zu entschärfen" + } + }, + "DECOY": { + "NAME": "Köder" + }, + "HEALTHSTATION": { + "NAME": "HealthStation", + "USE": "Halten, um HealthStation zu nutzen ({0})" + }, + "MAGNETOSTICK": { + "NAME": "MagnetoStick" + } + }, + "PERK": { + "BODYARMOR": { + "NAME": "Körperschild" + }, + "RADAR": { + "NAME": "Radar" + } + }, + "ENTITY": { + "USE": "Drücken, um mit '{0}' zu interagieren", + "ENT_BUTTON": "Knopf" + }, + "DOOR": { + "OPEN": "Drücken, um die Tür zu öffnen", + "CLOSE": "Drücken, um die Tür zu schließen", + "LOCKED": "Die Tür ist verschlossen" + }, + "GAMEEVENT": { + "PLAYER": { + "TAKEDAMAGE": { + "TITLE": "Ein Spieler hat Schaden erlitten", + "DESCRIPTION": "'{0}' hat {1} Schaden von '{2}' erhalten" + }, + "DIED": { + "TITLE": "Ein Spieler ist gestorben", + "NOREASON": "'{0}' starb", + "BYSUICIDE": "'{0}' hat sich selbst umgebracht", + "BYPLAYER": "'{0}' wurde vom Spieler '{1}' getötet", + "BYOBJECT": "'{0}' wurde vom Objekt '{1}' getötet" + }, + "SPAWN": { + "TITLE": "Ein Spieler ist respawnt", + "DESCRIPTION": "'{0}' ist respawnt" + }, + "ROLE": { + "SELECT": { + "TITLE": "Einem Spieler wurde eine neue Rolle zugewiesen", + "DESCRIPTION": "'{0}' wurde die Rolle '{1}' zugewiesen" + } + } + }, + "GAME": { + "FINISH": { + "TITLE": "Rundenende", + "DESCRIPTION": "'{0}' hat gewonnen" + } + } + } +} diff --git a/lang/en-US.json b/lang/en-US.json new file mode 100644 index 000000000..724de4934 --- /dev/null +++ b/lang/en-US.json @@ -0,0 +1,410 @@ +{ + "__LANGUAGE__": { + "NAME": "English", + "CODE": "en-US" + }, + "ROLE": { + "NONE": { + "NAME": "Unknown" + }, + "INNOCENT": { + "NAME": "Innocent" + }, + "TRAITOR": { + "NAME": "Traitor" + }, + "DETECTIVE": { + "NAME": "Detective" + } + }, + "TEAM": { + "INNOCENTS": { + "NAME": "Innocents", + "WIN": "THE INNOCENT WIN!" + }, + "TRAITORS": { + "NAME": "Traitors", + "WIN": "THE TRAITORS WIN!" + }, + "NONES": { + "NAME": "None", + "WIN": "IT'S A TIE!" + } + }, + "WIN": { + "DESCRIPTION": "Thanks for playing TTT Reborn, more updates and stats to come!" + }, + "ROUND": { + "STATE": { + "WAITING": "Waiting", + "PREPARING": "Preparing", + "IN_PROGRESS": "In progress", + "POST": "Round over", + "MAP_SELECTION": "Selecting next map" + } + }, + "PLAYER": { + "STATUS": { + "HEALTH": { + "HEALTHY": "Healthy", + "HURT": "Hurt", + "WOUNDED": "Wounded", + "BADLY_WOUNDED": "Badly Wounded", + "NEAR_DEATH": "Near Death", + "DEAD": "Dead" + } + } + }, + "CORPSE": { + "INSPECT": { + "QUICKINFO": { + "HEADSHOT": "Headshot", + "SUICIDE": "Suicide", + "DISTANCE": "{0}m", + "TIME": "{0}" + }, + "IDENTIFIER": { + "TIMESINCEDEATH": "They died roughly {0} ago.", + "HEADSHOT": "The fatal wound was a headshot. No time to scream.", + "SUICIDE": "You cannot find a specific cause of this Terry's death.", + "KILLED": "They were killed from approximately {0}m away.", + "WEAPON": "It appears a '{0}' was used to kill them.", + "PERK": "They were carrying a '{0}'." + } + }, + "USE": { + "IDENTIFY": "Hold to identify the corpse", + "INSPECT": "Hold to inspect the corpse", + "COVERTINSPECT": "Hold to inspect the corpse covert" + } + }, + "SCOREBOARD": { + "HEADER": { + "GAMEMODE": "{0} Server", + "CREATEDBY": "Created by {0}", + "PLAYERAMOUNT": "{0} / {1} Players", + "SERVERINFO": "{0} players. Map: {1}", + "PLAYERSLEFT": "{0} players left" + }, + "GROUP": { + "ALIVE": "Alive", + "DEAD": "Confirmed Dead", + "MISSING": "Missing In Action", + "SPECTATOR": "Spectators" + }, + "COLUMNS": { + "KARMA": "Karma", + "DEATHS": "Deaths", + "SCORE": "Score", + "PING": "Ping" + } + }, + "QUICKSHOP": { + "CREDITS": { + "DESCRIPTION": "You have ${0}" + }, + "ITEM": { + "DESCRIPTION": "The description for the item '{0}' will go here." + } + }, + "REALM": { + "CLIENT": "Client", + "SERVER": "Server" + }, + "MENU": { + "SETTINGS": { + "TITLE": "Settings", + "CLIENT": "Client Settings", + "SERVER": "Server Settings", + "LOADING": "Loading...", + "TABS": { + "GENERAL": { + "TITLE": "General", + "LANGUAGE": { + "TITLE" : "Language", + "DESCRIPTION": "The displayed language on the client" + }, + "RETURNMISSINGKEYS": { + "TITLE": "Debuggung: Return missing key", + "DESCRIPTION": "If the displayed language has a missing key, return it." + } + }, + "DEBUG": { + "TITLE": "Debug", + "PREVENTWIN": { + "TITLE": "Supress victory", + "DESCRIPTION": "Shall the round end caused by a victory based on elapsed time or fulfilled victory condition be supressed? (Map triggers excluded)" + } + }, + "AFK": { + "TITLE": "AFK", + "SECONDSTILLKICK": { + "TITLE": "AFK Time", + "DESCRIPTION": "The length of time in minutes before a player is marked AFK." + }, + "SHOULDKICKPLAYERS": { + "TITLE": "Should Kick Players?", + "DESCRIPTION": "Whether or not a player should be kicked or moved to Spectators." + } + }, + "MOVEMENT": { + "TITLE": "Sprint", + "ISSPRINTENABLED": { + "TITLE" : "Sprint enabled?", + "DESCRIPTION": "Whether or not sprint should be enabled on the server." + } + }, + "ROUND": { + "TITLE": "Rounds", + "MINPLAYERS": { + "TITLE": "Minimum Players", + "DESCRIPTION": "The minimum players required to start. If it's below the set amount, the game will stop if already started." + }, + "PREROUNDTIME": { + "TITLE": "Preparing Time", + "DESCRIPTION": "The amount of time allowed for preparation." + }, + "ROUNDTIME": { + "TITLE": "Round Time", + "DESCRIPTION": "The amount of time allowed for the main round." + }, + "POSTROUNDTIME": { + "TITLE": "Postround Time", + "DESCRIPTION": "The amount of time before the next round starts." + }, + "MAPSELECTIONROUNDTIME": { + "TITLE": "MapSelection: Round Time", + "DESCRIPTION": "Time for the Map selection" + }, + "TOTALROUNDS": { + "TITLE": "Total Rounds", + "DESCRIPTION": "Total rounds to play until MapSelection appears" + }, + "KILLTIMEREWARD": { + "TITLE": "Kill Time Reward", + "DESCRIPTION": "The amount of extra time given to traitors for killing an innocent." + } + }, + "MAP": { + "TITLE": "Map", + "DEFAULTMAP": { + "TITLE": "Default Map", + "DESCRIPTION": "Choose a map that is selected by default." + } + } + }, + "BUTTONS": { + "SAVE": "Save", + "LOAD": "Load", + "OVERWRITE": { + "TITLE": "Overwrite '{0}'", + "DESCRIPTION": "Do you want to overwrite '{0}' with the current settings? (If you agree, the settings defined in this file will be lost!)" + } + } + }, + "KEYBINDINGS": { + "TITLE": "Keybindings", + "RESTRICTION": "Because of restrictions by the S&Box developers you can change your bindings just in the s&box options menu or through console.", + "MOVEMENT": { + "TITLE": "Movement", + "FORWARD": "Forward", + "BACK": "Back", + "LEFT": "Left", + "RIGHT": "Right", + "JUMP": "Jump", + "CROUCH": "Crouch", + "SPRINT": "Sprint" + }, + "WEAPONS": { + "TITLE": "Weapons", + "FIRE": "Fire", + "RELOAD": "Reload", + "DROP_WEAPON": "Drop Weapon", + "DROP_AMMO": "Drop Ammo" + }, + "ACTIONS": { + "TITLE": "Actions", + "USE": "Use", + "FLASHLIGHT": "Flashlight" + }, + "COMMUNICATION": { + "TITLE": "Communication", + "VOICECHAT": "Voice Chat", + "TEAMVOICECHAT": "Team Voice Chat", + "TEAMTEXTCHAT": "Team Text Chat" + }, + "MENUS": { + "TITLE": "Menus", + "MENU": "Scoreboard, Menu, Logs etc.", + "QUICKSHOP": "QuickShop" + } + }, + "TESTING": { + "TITLE": "Testing", + "FILESELECTION": "Explorer" + }, + "SHOPEDITOR": { + "TITLE": "Shop Editor", + "TOGGLEROLE": "Umschalten, um den Shop für die aktuell ausgewählte Rolle zu de-/aktivieren.", + "SELECTROLE": "Select a role to modify the connected shop.", + "ENABLEROLE": "Activated", + "NOPERMISSION": "You have no permission to access the ShopEditor.", + "EDIT": { + "TITLE": "Edit this item.", + "DESCRIPTION": "Edit the item '{0}'" + }, + "PRICE": { + "TITLE": "Price", + "DESCRIPTION": "The price of the item '{0}'." + } + }, + "ROLEEDITOR": { + "TITLE": "Role Editor", + "RESET": { + "TITLE": "Reset RoleSelection", + "DESCRIPTION": "Are you sure that you want to reset the RoleSelection?" + } + } + }, + "GAMERESULTSMENU": { + "EMPTY": "Events are just created at the end of a round.", + "TITLE": "Events of the last round:", + "ALLFILTER": "Global", + "PLAYERFILTER": "You", + "EVENTS": { + "SCORING": { + "PLAYERNAME": "Playername", + "SCORE": "Score", + "KARMA": "Karma" + } + } + }, + "MAPSELECTION": { + "VOTE": "Vote for the next map!" + }, + "WEAPON": { + "PISTOL": { + "NAME": "Pistol" + }, + "SMG": { + "NAME": "SMG" + }, + "SHOTGUN": { + "NAME": "Shotgun" + }, + "SNIPER": { + "NAME": "Sniper" + }, + "KNIFE": { + "NAME": "Knife" + }, + "NEWTONLAUNCHER": { + "NAME": "Newtonlauncher" + }, + "OFFENSIVEEQUIPMENT": { + "NAME": "Offensive Equipment" + }, + "RPG7": { + "NAME": "RPG-7" + }, + "BAYONET": { + "NAME": "Bayonet" + }, + "DEAGLE": { + "NAME": "Desert Eagle" + }, + "FAL": { + "NAME": "FAL" + }, + "L96A1": { + "NAME": "L96A1" + }, + "SPAS12": { + "NAME": "SPAS12" + }, + "UMP45": { + "NAME": "UMP45" + }, + "AMMO": { + "NAME": "Ammo", + "WEAPON": "{0} Ammo" + }, + "USE": "Press to pickup '{0}'" + }, + "EQUIPMENT": { + "HANDS": { + "NAME": "Hands" + }, + "C4": { + "NAME": "C4", + "UI": { + "PICKUP": "Pick Up", + "DESTROY": "Destroy", + "ARM": "Arm", + "DEFUSECHANCE": "{0}% chance to defuse" + }, + "USE": { + "ARM": "Hold to arm the C4", + "DEFUSE": "Press to defuse the C4" + } + }, + "DECOY": { + "NAME": "Decoy" + }, + "HEALTHSTATION": { + "NAME": "HealthStation", + "USE": "Hold to use the HealthStation ({0})" + }, + "MAGNETOSTICK": { + "NAME": "MagnetoStick" + } + }, + "PERK": { + "BODYARMOR": { + "NAME": "Bodyarmor" + }, + "RADAR": { + "NAME": "Radar" + } + }, + "ENTITY": { + "USE": "Press to interact with '{0}'", + "ENT_BUTTON": "Button" + }, + "DOOR": { + "OPEN": "Press to open the door", + "CLOSE": "Press to close the door", + "LOCKED": "Door is locked" + }, + "GAMEEVENT": { + "PLAYER": { + "TAKEDAMAGE": { + "TITLE": "A player received damage", + "DESCRIPTION": "'{0}' took {1} damage from '{2}'" + }, + "DIED": { + "TITLE": "A player died", + "NOREASON": "'{0}' died", + "BYSUICIDE": "'{0}' has committed suicide", + "BYPLAYER": "'{0}' was killed by player '{1}'", + "BYOBJECT": "'{0}' was killed by object '{1}'" + }, + "SPAWN": { + "TITLE": "A player respawned", + "DESCRIPTION": "'{0}' respawned" + }, + "ROLE": { + "SELECT": { + "TITLE": "A player received a new role", + "DESCRIPTION": "'{0}' received the role '{1}'" + } + } + }, + "GAME": { + "FINISH": { + "TITLE": "End of round", + "DESCRIPTION": "'{0}' have won" + } + } + } +} diff --git a/sounds/c4-beep.sound_c b/sounds/c4-beep.sound_c index 21a9c2756..8ea41d757 100644 Binary files a/sounds/c4-beep.sound_c and b/sounds/c4-beep.sound_c differ