From df95c4d1cc0b92a22224b5dcdd33877a3e5177e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 6 Sep 2025 14:36:56 +0000 Subject: [PATCH 1/3] Initial plan From 313ad0dc85c24d8a2a93f51ca71aed178d42d38b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 6 Sep 2025 14:42:21 +0000 Subject: [PATCH 2/3] Re-add entity tick logic to BaseGame.Update() and update IActor interface Co-authored-by: xezno <12881812+xezno@users.noreply.github.com> --- Source/Mocha.Common/Entities/IActor.cs | 1 + Source/Mocha.Engine/BaseGame.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Source/Mocha.Common/Entities/IActor.cs b/Source/Mocha.Common/Entities/IActor.cs index 33490069..fcee3912 100644 --- a/Source/Mocha.Common/Entities/IActor.cs +++ b/Source/Mocha.Common/Entities/IActor.cs @@ -7,6 +7,7 @@ public interface IActor void Delete(); void Update(); + void FrameUpdate(); } public static class IActorExtensions diff --git a/Source/Mocha.Engine/BaseGame.cs b/Source/Mocha.Engine/BaseGame.cs index c472bb99..0b0c254c 100644 --- a/Source/Mocha.Engine/BaseGame.cs +++ b/Source/Mocha.Engine/BaseGame.cs @@ -66,6 +66,12 @@ public void Update() } DebugOverlay.ScreenText( $"BaseGame.Update assembly {GetType().Assembly.GetHashCode()}" ); + + // Call tick logic on all entities + TryCallMethodOnEntity( "Update" ); + + // Fire tick event + Event.Run( Event.TickAttribute.Name ); } public void Shutdown() From 4dfcdbe9ece81f591da8d4efeb8f69ae106df70d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 6 Sep 2025 14:44:07 +0000 Subject: [PATCH 3/3] Add test to verify entity tick logic implementation Co-authored-by: xezno <12881812+xezno@users.noreply.github.com> --- Source/Mocha.Tests/EntityTickTests.cs | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Source/Mocha.Tests/EntityTickTests.cs diff --git a/Source/Mocha.Tests/EntityTickTests.cs b/Source/Mocha.Tests/EntityTickTests.cs new file mode 100644 index 00000000..836d8f14 --- /dev/null +++ b/Source/Mocha.Tests/EntityTickTests.cs @@ -0,0 +1,56 @@ +using Mocha; +using Mocha.Common; + +namespace Mocha.Tests; + +[TestClass] +public class EntityTickTests +{ + [TestMethod] + public void TestEntityImplementsTickInterface() + { + // Create a test actor instance + var actor = new TestActor(); + + // Verify it implements IActor correctly + Assert.IsInstanceOfType(actor, typeof(IActor)); + + // Verify it has both Update and FrameUpdate methods + var updateMethod = actor.GetType().GetMethod("Update"); + var frameUpdateMethod = actor.GetType().GetMethod("FrameUpdate"); + + Assert.IsNotNull(updateMethod); + Assert.IsNotNull(frameUpdateMethod); + } + + [TestMethod] + public void TestIActorInterfaceHasBothMethods() + { + // Verify IActor interface has both required methods + var iactorType = typeof(IActor); + var updateMethod = iactorType.GetMethod("Update"); + var frameUpdateMethod = iactorType.GetMethod("FrameUpdate"); + + Assert.IsNotNull(updateMethod, "IActor interface should have Update method"); + Assert.IsNotNull(frameUpdateMethod, "IActor interface should have FrameUpdate method"); + } +} + +// Test actor for validating interface compliance +public class TestActor : Actor +{ + public bool UpdateCalled { get; private set; } = false; + public bool FrameUpdateCalled { get; private set; } = false; + + public override void Update() + { + UpdateCalled = true; + base.Update(); + } + + public override void FrameUpdate() + { + FrameUpdateCalled = true; + base.FrameUpdate(); + } +} \ No newline at end of file