public virtual unsafe void OnContact(PhyContactPairHeader *pairHeader, PhyContactPair *pairs, UInt32 nbPairs) { unsafe { CPhyEntity entity1 = null, entity2 = null; var pair = (*pairHeader); var entity1Handle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.actors0); if (entity1Handle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(entity1Handle); entity1 = weakRef.Target as CPhyEntity; } var entity2Handle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.actors0); if (entity2Handle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(entity2Handle); entity2 = weakRef.Target as CPhyEntity; } if (entity1.EntityType == PhyEntityType.PET_Actor) { } if (entity1.EntityType == PhyEntityType.PET_Controller) { } if (entity2.EntityType == PhyEntityType.PET_Controller) { } } }
public virtual unsafe void OnTrigger(PhyTriggerPair *pairs, UInt32 count) { unsafe { CPhyEntity triggerEntity = null, otherEntity = null; for (int i = 0; i < count; ++i) { var pair = pairs[i]; var otherHandle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.otherActor); if (otherHandle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(otherHandle); otherEntity = weakRef.Target as CPhyEntity; } var triggerHandle = CPhyActor.SDK_PhyEntity_GetCSharpHandle(pair.triggerActor); if (triggerHandle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(triggerHandle); triggerEntity = weakRef.Target as CPhyEntity; } if (otherEntity != null) { //if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND) // triggerPhyActor.HostComponent?.OnTriggerIn(); } if (triggerEntity != null && otherEntity != null) { var triggerActor = triggerEntity as CPhyActor; if (triggerActor != null) { if (otherEntity.EntityType == PhyEntityType.PET_Actor) { var otherActor = otherEntity as CPhyActor; if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND) { triggerActor.HostComponent?.OnTriggerIn(otherActor); } if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_LOST) == PhyPairFlag.eNOTIFY_TOUCH_LOST) { triggerActor.HostComponent?.OnTriggerOut(otherActor); } } if (otherEntity.EntityType == PhyEntityType.PET_Controller) { var otherController = otherEntity as CPhyController; if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND) { triggerActor.HostComponent?.OnTriggerIn(otherController); } if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_LOST) == PhyPairFlag.eNOTIFY_TOUCH_LOST) { triggerActor.HostComponent?.OnTriggerOut(otherController); } } } } } } }