Found a problem and may be a solution: every call to the GameEntity events must check if the event has been assigned before calling it and must be commented the throw exception in the destructor.
namespace Leadwerks.Game
{
public class GameEntity : Leadwerks.Entity, IDisposable
{
......
~GameEntity()
{
//throw new System.NotImplementedException();
}
......
protected virtual void OnFreeEntity(IntPtr entity)
{
if (FreeEntity != null)
FreeEntity(this, entity);
}
}
}
With those changes to GameEntity I have no exception running the following VB code:
Sub Main()
Graphics.Initialize(800, 600)
Framework.Initialize(False)
Debug.Physics = True
Collisions.Set(1, 1, True)
Dim cube As Body = Body.CreateBox(1, 1, 1)
cube.Mass = 1
cube.CollisionType = 1
Dim plane As Body = Body.CreateBox(10, 0.2, 10)
plane.CollisionType = 1
plane.Position = cube.Position
plane.Move(New Vector3(0, -1, 0))
Dim AmmoBody As Body = Body.CreateBox(1, 1, 1)
AmmoBody.CollisionType = 1
AmmoBody.Mass = 1
AmmoBody.Position = cube.Position
AmmoBody.Move(New Vector3(1.5, 0, 0))
Dim GameEntityObject As New GameEntity(AmmoBody.Pointer)
AddHandler GameEntityObject.Collision, New CollisionEventHandler(AddressOf DeclareCollisionToScreen)
While (Not Keyboard.KeyHit(Key.Escape) And Not Window.HasRequestedClose())
Framework.Update()
Framework.Render()
Graphics.Flip()
End While
Framework.Terminate()
End Sub
Sub DeclareCollisionToScreen(ByVal Sender As Object, ByVal e As CollisionEventArgs)
Drawing.Text(e.Entity0.ToString, 50, 50)
End Sub