diff --git a/Assets/Scripts/Game/GameState.cs b/Assets/Scripts/Game/GameState.cs index 66457d2..e072f01 100644 --- a/Assets/Scripts/Game/GameState.cs +++ b/Assets/Scripts/Game/GameState.cs @@ -69,12 +69,10 @@ public class GameState } } - public void ClearEntityModel(int entityNum) + public Entity GetEntity(int entityNum) { - if (entities.TryGetValue(entityNum, out var entity)) - { - entity.ClearModel(); - } + entities.TryGetValue(entityNum, out var entity); + return entity; } public void SetEntityAliasModel(int entityNum, string modelName) @@ -99,22 +97,6 @@ public class GameState // TODO: obtain Mesh from brush submodel and assign it to MeshRenderer } - public void UpdateEntityAnimation(int entityNum, float frameNum) - { - if (entities.TryGetValue(entityNum, out var entity)) - { - entity.UpdateAnimation(frameNum); - } - } - - public void SetEntityTransform(int entityNum, Vector3 position, Quaternion rotation) - { - if (entities.TryGetValue(entityNum, out var entity)) - { - entity.SetTransform(position, rotation); - } - } - public void RemoveEntity(int entityNum) { if (entities.TryGetValue(entityNum, out var entity)) diff --git a/Assets/Scripts/Modules/GameModule.cs b/Assets/Scripts/Modules/GameModule.cs index 31501e4..e042f3e 100644 --- a/Assets/Scripts/Modules/GameModule.cs +++ b/Assets/Scripts/Modules/GameModule.cs @@ -16,7 +16,7 @@ public partial class GameModule { if (string.IsNullOrEmpty(modelName)) { - uq.GameState.ClearEntityModel(entityNum); + uq.GameState.GetEntity(entityNum)?.ClearModel(); return; } @@ -35,14 +35,14 @@ public partial class GameModule if (modelName.EndsWith(".bsp")) { // TODO: non-world brush model - uq.GameState.ClearEntityModel(entityNum); + uq.GameState.GetEntity(entityNum)?.ClearModel(); return; } if (modelName.EndsWith(".spr")) { // TODO: sprite - uq.GameState.ClearEntityModel(entityNum); + uq.GameState.GetEntity(entityNum)?.ClearModel(); return; } @@ -51,7 +51,7 @@ public partial class GameModule private void SetEntityTransform(int entityNum, QVec3 origin, QVec3 angles) { - uq.GameState.SetEntityTransform(entityNum, origin.ToUnityPosition(), angles.ToUnityRotation()); + uq.GameState.GetEntity(entityNum)?.SetTransform(origin.ToUnityPosition(), angles.ToUnityRotation()); } private void RemoveEntity(int entityNum) @@ -61,6 +61,6 @@ public partial class GameModule private void UpdateEntityAnimation(int entityNum, float frameNum) { - uq.GameState.UpdateEntityAnimation(entityNum, frameNum); + uq.GameState.GetEntity(entityNum)?.UpdateAnimation(frameNum); } }