public SceneBase(int id, State state) : base(IntPtr.Zero) { _parentState = state; _id = id; _entities = new List <Entity>(); _systems = new List <ISystem>(); SceneCreatedCallback callback = () => { // Console.WriteLine("Progress = {0}", value); }; SceneUpdateCallback updateCallback = (value) => { //not used !!!!!!!!!!!! Updated(value); // Console.WriteLine("Progress = {0}", value); }; EntityAddedCallback entityAddedCallback = (UInt64 entityID, IntPtr entityHolder) => { _entities.Add(new Entity(entityID, entityHolder)); // Console.WriteLine("Progress = {0}", value); }; EntityRemovedCallback entityRemovedCallback = (UInt64 entityID) => { // Console.WriteLine("Progress = {0}", value); }; CPointer = GetScene(_parentState.CPointer, id, callback, updateCallback, entityAddedCallback, entityRemovedCallback, true); //call sceneCreate in c++ }
public void AddRegion(RegionContextBase rcontext) { m_log.Log(LogLevel.DWORLD, "Simulator connected " + rcontext.Name); RegionContextBase foundRegion = null; lock (m_regionList) { foundRegion = GetRegion(rcontext.Name); if (foundRegion == null) { // we don't know about this region. Add it and connect to events m_regionList.Add(rcontext); IEntityCollection coll; if (rcontext.TryGet<IEntityCollection>(out coll)) { if (Region_OnNewEntityCallback == null) { Region_OnNewEntityCallback = new EntityNewCallback(Region_OnNewEntity); } coll.OnEntityNew += Region_OnNewEntityCallback; if (Region_OnUpdateEntityCallback == null) { Region_OnUpdateEntityCallback = new EntityUpdateCallback(Region_OnUpdateEntity); } coll.OnEntityUpdate += Region_OnUpdateEntityCallback; if (Region_OnRemovedEntityCallback == null) { Region_OnRemovedEntityCallback = new EntityRemovedCallback(Region_OnRemovedEntity); } coll.OnEntityRemoved += Region_OnRemovedEntityCallback; } if (Region_OnRegionUpdatedCallback == null) { Region_OnRegionUpdatedCallback = new RegionRegionUpdatedCallback(Region_OnRegionUpdated); } rcontext.OnRegionUpdated += Region_OnRegionUpdatedCallback; } } // tell the world there is a new region (do it outside the lock) if (foundRegion == null) { if (OnWorldRegionNew != null) OnWorldRegionNew(rcontext); } }
private static extern unsafe IntPtr GetScene(IntPtr parentStateNativePtr, int id , [MarshalAs(UnmanagedType.FunctionPtr)] SceneCreatedCallback callbackPointer , [MarshalAs(UnmanagedType.FunctionPtr)] SceneUpdateCallback sceneUpdateCB , [MarshalAs(UnmanagedType.FunctionPtr)] EntityAddedCallback EntityAddedCB , [MarshalAs(UnmanagedType.FunctionPtr)] EntityRemovedCallback EntityRemovedCB, bool createNew);