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