Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/Mocha.Common/Entities/IActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IActor

void Delete();
void Update();
void FrameUpdate();
}

public static class IActorExtensions
Expand Down
6 changes: 6 additions & 0 deletions Source/Mocha.Engine/BaseGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
56 changes: 56 additions & 0 deletions Source/Mocha.Tests/EntityTickTests.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}