private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { MyEntity entity = bodyToOtherEntity(body); if (entity == null) { return; } if (!(entity is MyCubeGrid) && !(entity is MyCharacter)) { return; } int entityCounter; bool registered = m_entitiesInContact.TryGetValue(entity, out entityCounter); Debug.Assert(registered, "Unregistering not registered entity from ship tool"); if (!registered) { return; } m_entitiesInContact.Remove(entity); if (entityCounter > 1) { m_entitiesInContact.Add(entity, entityCounter - 1); } }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { var entities = body.GetAllEntities(); foreach (var ientity in entities) { if (CanInteractWith(ientity)) { continue; } var entity = ientity as MyEntity; int entityCounter; if (m_entitiesInContact.TryGetValue(entity, out entityCounter)) { m_entitiesInContact.Remove(entity); m_entitiesInContact.Add(entity, entityCounter + 1); } else { m_entitiesInContact.Add(entity, 1); } } }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { MyEntity entity = bodyToOtherEntity(body); if (entity == null) { return; } if (!(entity is MyCubeGrid) && !(entity is MyCharacter)) { return; } int entityCounter; if (m_entitiesInContact.TryGetValue(entity, out entityCounter)) { m_entitiesInContact.Remove(entity); m_entitiesInContact.Add(entity, entityCounter + 1); } else { m_entitiesInContact.Add(entity, 1); } }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { var entities = body.GetAllEntities(); foreach (var ientity in entities) { if (CanInteractWith(ientity)) { continue; } var entity = ientity as MyEntity; int entityCounter; bool registered = m_entitiesInContact.TryGetValue(entity, out entityCounter); Debug.Assert(registered, "Unregistering not registered entity from ship tool"); if (!registered) { continue; } m_entitiesInContact.Remove(entity); if (entityCounter > 1) { m_entitiesInContact.Add(entity, entityCounter - 1); } } entities.Clear(); }
private HkBvShape CreateFieldShape(Vector3 extents) { var phantom = new HkPhantomCallbackShape(phantom_Enter, phantom_Leave); var detectorShape = new HkBoxShape(extents); return(new HkBvShape(detectorShape, phantom, HkReferencePolicy.TakeOwnership)); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) { return; } VRage.ProfilerShort.Begin("CollectorEnter"); var entities = body.GetAllEntities(); foreach (var entity in entities) { if (entity is MyFloatingObject) { m_entitiesToTake.Add(entity as MyFloatingObject); NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; } } entities.Clear(); VRage.ProfilerShort.End(); //if (!Sync.IsServer) // return; //var entity = body.GetEntity(); //if (entity is MyFloatingObject) //{ // Inventory.TakeFloatingObject(entity as MyFloatingObject); //} }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("ShipToolEnter"); var entities = body.GetAllEntities(); foreach (var ientity in entities) { if (!CanInteractWith(ientity)) { continue; } var entity = ientity as MyEntity; int entityCounter; if (m_entitiesInContact.TryGetValue(entity, out entityCounter)) { m_entitiesInContact.Remove(entity); m_entitiesInContact.Add(entity, entityCounter + 1); } else { m_entitiesInContact.Add(entity, 1); } } entities.Clear(); ProfilerShort.End(); }
private void LoadDummies() { var finalModel = Engine.Models.MyModels.GetModelOnlyDummies(BlockDefinition.Model); foreach (var dummy in finalModel.Dummies) { if (dummy.Key.ToLower().Contains("detector_shiptool")) { var matrix = dummy.Value.Matrix; float radius = matrix.Scale.AbsMin(); Matrix blockMatrix = this.PositionComp.LocalMatrix; Vector3 gridDetectorPosition = Vector3.Transform(matrix.Translation, blockMatrix); m_detectorSphere = new BoundingSphere(gridDetectorPosition, radius); var phantom = new HkPhantomCallbackShape(phantom_Enter, phantom_Leave); var sphereShape = new HkSphereShape(radius); var detectorShape = new HkBvShape(sphereShape, phantom, HkReferencePolicy.TakeOwnership); Physics = new Engine.Physics.MyPhysicsBody(this, RigidBodyFlag.RBF_DEFAULT); Physics.IsPhantom = true; Physics.CreateFromCollisionObject(detectorShape, matrix.Translation, WorldMatrix, null, MyPhysics.ObjectDetectionCollisionLayer); detectorShape.Base.RemoveReference(); break; } } }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { var other = body.GetEntity() as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) { return; } m_gridList.Add(other); }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (Sync.IsServer && !this.m_isCollecting) { List <VRage.ModAPI.IMyEntity> allEntities = body.GetAllEntities(); foreach (VRage.ModAPI.IMyEntity entity in allEntities) { this.m_entitiesToTake.Remove(entity as MyFloatingObject); } allEntities.Clear(); } }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { VRage.ProfilerShort.Begin("MergeLeave"); var entities = MyPhysicsExtensions.GetAllEntities(body); foreach (var entity in entities) { m_gridList.Remove(entity as MyCubeGrid); } entities.Clear(); VRage.ProfilerShort.End(); }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) { return; } var entity = body.GetEntity(); if (m_entitiesToTake.Contains(entity)) { m_entitiesToTake.Remove(entity as MyFloatingObject); } }
void phantom_Leave(HkPhantomCallbackShape sender, HkRigidBody body) { var entity = body.GetEntity(); lock (m_locker) { if (entity != null) { m_containedEntities.Remove(entity); MyTrace.Send(TraceWindow.EntityId, string.Format("Entity left gravity field, entity: {0}", entity)); } } }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) { return; } var entities = body.GetAllEntities(); foreach (var entity in entities) { m_entitiesToTake.Remove(entity as MyFloatingObject); } entities.Clear(); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { var entities = body.GetAllEntities(); foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) { continue; } m_gridList.Add(other); } }
void phantom_Leave(HkPhantomCallbackShape sender, HkRigidBody body) { ProfilerShort.Begin("GravityLeave"); var entity = MyPhysicsExtensions.GetEntity(body, 0);// jn: TODO we should collect bodies not entities lock (m_locker) { if (entity != null) { m_containedEntities.Remove(entity); MyTrace.Send(TraceWindow.EntityId, string.Format("Entity left gravity field, entity: {0}", entity)); } } ProfilerShort.End(); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { if (Sync.IsServer) { List <VRage.ModAPI.IMyEntity> allEntities = body.GetAllEntities(); foreach (VRage.ModAPI.IMyEntity entity in allEntities) { if (entity is MyFloatingObject) { this.m_entitiesToTake.Add(entity as MyFloatingObject); MySandboxGame.Static.Invoke(() => base.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME, "MyCollector::NeedsUpdate"); } } allEntities.Clear(); } }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) { return; } VRage.ProfilerShort.Begin("CollectorLeave"); var entities = body.GetAllEntities(); foreach (var entity in entities) { m_entitiesToTake.Remove(entity as MyFloatingObject); } entities.Clear(); VRage.ProfilerShort.End(); }
void phantom_Enter(HkPhantomCallbackShape sender, HkRigidBody body) { var entity = body.GetEntity(); // HACK: disabled gravity for ships (there may be more changes so I won't add Entity.RespectsGravity now) lock (m_locker) { if (entity != null && !(entity is MyCubeGrid)) { MyTrace.Send(TraceWindow.EntityId, string.Format("Entity entered gravity field, entity: {0}", entity)); m_containedEntities.Add(entity); if (entity.Physics.HasRigidBody) { ((MyPhysicsBody)entity.Physics).RigidBody.Activate(); } } } }
void phantom_Enter(HkPhantomCallbackShape sender, HkRigidBody body) { ProfilerShort.Begin("GravityEnter"); var entity = MyPhysicsExtensions.GetEntity(body, 0);// jn: TODO we should collect bodies not entities // HACK: disabled gravity for ships (there may be more changes so I won't add Entity.RespectsGravity now) lock (m_locker) { if (entity != null && !(entity is MyCubeGrid)) { MyTrace.Send(TraceWindow.EntityId, string.Format("Entity entered gravity field, entity: {0}", entity)); m_containedEntities.Add(entity); if (entity.Physics.HasRigidBody) { ((MyPhysicsBody)entity.Physics).RigidBody.Activate(); } } } ProfilerShort.End(); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { VRage.ProfilerShort.Begin("MergeEnter"); var entities = MyPhysicsExtensions.GetAllEntities(body); foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) { continue; } if (other.Physics.RigidBody != body) { continue; } var added = m_gridList.Add(other); //Debug.Assert(added, "entity already in list"); } entities.Clear(); VRage.ProfilerShort.End(); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) { return; } var entity = body.GetEntity(); if (entity is MyFloatingObject) { m_entitiesToTake.Add(entity as MyFloatingObject); NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; } //if (!Sync.IsServer) // return; //var entity = body.GetEntity(); //if (entity is MyFloatingObject) //{ // m_inventory.TakeFloatingObject(entity as MyFloatingObject); //} }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { var entities = body.GetAllEntities(); foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) continue; m_gridList.Add(other); } }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) return; var entities = body.GetAllEntities(); foreach (var entity in entities) { if (entity is MyFloatingObject) { m_entitiesToTake.Add(entity as MyFloatingObject); NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; } } entities.Clear(); //if (!Sync.IsServer) // return; //var entity = body.GetEntity(); //if (entity is MyFloatingObject) //{ // m_inventory.TakeFloatingObject(entity as MyFloatingObject); //} }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) return; var entities = body.GetAllEntities(); foreach(var entity in entities) m_entitiesToTake.Remove(entity as MyFloatingObject); entities.Clear(); }
void phantom_Enter(HkPhantomCallbackShape sender, HkRigidBody body) { }
void phantom_Enter(HkPhantomCallbackShape sender, HkRigidBody body) { var entity = body.GetEntity(); // HACK: disabled gravity for ships (there may be more changes so I won't add Entity.RespectsGravity now) lock (m_locker) { if (entity != null && !(entity is MyCubeGrid)) { MyTrace.Send(TraceWindow.EntityId, string.Format("Entity entered gravity field, entity: {0}", entity)); m_containedEntities.Add(entity); if (entity.Physics.HasRigidBody) ((MyPhysicsBody)entity.Physics).RigidBody.Activate(); } } }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("MergeEnter"); var entities = MyPhysicsExtensions.GetAllEntities(body); foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) continue; if(other.Physics.RigidBody != body) continue; var added = m_gridList.Add(other); //Debug.Assert(added, "entity already in list"); } entities.Clear(); ProfilerShort.End(); }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) return; var entity = body.GetEntity(); if (m_entitiesToTake.Contains(entity)) { m_entitiesToTake.Remove(entity as MyFloatingObject); } }
void phantom_Leave(HkPhantomCallbackShape sender, HkRigidBody body) { }
private void phantom_LeaveConnector(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("ShipConnectorLeaveConnector"); var entities = body.GetAllEntities(); foreach (var entity in entities) { m_detectedGrids.Remove(entity as MyCubeGrid); } entities.Clear(); ProfilerShort.End(); }
private void phantom_LeaveEjector(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("ShipConnectorLeaveEjector"); var updateEmissivity = (m_detectedFloaters.Count == 2); var entities = body.GetAllEntities(); foreach (var entity in entities) m_detectedFloaters.Remove(entity); entities.Clear(); if (updateEmissivity) UpdateEmissivity(); ProfilerShort.End(); }
void phantom_Enter(HkPhantomCallbackShape sender, HkRigidBody body) { VRage.ProfilerShort.Begin("GravityEnter"); var entity = MyPhysicsExtensions.GetEntity(body, 0);// jn: TODO we should collect bodies not entities // HACK: disabled gravity for ships (there may be more changes so I won't add Entity.RespectsGravity now) lock (m_locker) { if (entity != null && !(entity is MyCubeGrid)) { MyTrace.Send(TraceWindow.EntityId, string.Format("Entity entered gravity field, entity: {0}", entity)); m_containedEntities.Add(entity); if (entity.Physics.HasRigidBody) ((MyPhysicsBody)entity.Physics).RigidBody.Activate(); } } VRage.ProfilerShort.End(); }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { if (!Sync.IsServer) return; VRage.ProfilerShort.Begin("CollectorLeave"); var entities = body.GetAllEntities(); foreach(var entity in entities) m_entitiesToTake.Remove(entity as MyFloatingObject); entities.Clear(); VRage.ProfilerShort.End(); }
private HkBvShape CreateFieldShape(Vector3 extents) { var phantom = new HkPhantomCallbackShape(phantom_Enter, phantom_Leave); var detectorShape = new HkBoxShape(extents); return new HkBvShape(detectorShape, phantom, HkReferencePolicy.TakeOwnership); }
private void phantom_EnterEjector(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("ShipConnectorEnterEjector"); bool updateEmissivity = false; var entities = body.GetAllEntities(); foreach (var entity in entities) { Debug.Assert(entity is MyFloatingObject); if (entity is MyFloatingObject) { updateEmissivity |= (m_detectedFloaters.Count == 1); m_detectedFloaters.Add(entity); } } entities.Clear(); if (updateEmissivity) UpdateEmissivity(); ProfilerShort.End(); }
void phantom_Leave(HkPhantomCallbackShape sender, HkRigidBody body) { VRage.ProfilerShort.Begin("GravityLeave"); var entity = MyPhysicsExtensions.GetEntity(body, 0);// jn: TODO we should collect bodies not entities lock (m_locker) { if (entity != null) { m_containedEntities.Remove(entity); MyTrace.Send(TraceWindow.EntityId, string.Format("Entity left gravity field, entity: {0}", entity)); } } VRage.ProfilerShort.End(); }
void phantom_Leave(HkPhantomCallbackShape sender, HkRigidBody body) { var entity = body.GetEntity(0);// jn: TODO we should collect bodies not entities lock (m_locker) { if (entity != null) { m_containedEntities.Remove(entity); MyTrace.Send(TraceWindow.EntityId, string.Format("Entity left gravity field, entity: {0}", entity)); } } }
private void phantom_EnterConnector(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("ShipConnectorEnterConnector"); var entities = body.GetAllEntities(); using (entities.GetClearToken()) { foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other == this.CubeGrid) continue; m_detectedGrids.Add(other); } } ProfilerShort.End(); }
private HkBvShape CreateFieldShape(Vector3 extents) { HkPhantomCallbackShape shape = new HkPhantomCallbackShape(new HkPhantomHandler(this.phantom_Enter), new HkPhantomHandler(this.phantom_Leave)); return(new HkBvShape((HkShape) new HkBoxShape(extents), (HkShape)shape, HkReferencePolicy.TakeOwnership)); }
private HkBvShape CreateDetectorShape(Vector3 extents, Mode mode) { if (mode == Mode.Ejector) { var phantom = new HkPhantomCallbackShape(phantom_EnterEjector, phantom_LeaveEjector); var detectorShape = new HkBoxShape(extents); return new HkBvShape(detectorShape, phantom, HkReferencePolicy.TakeOwnership); } else { var phantom = new HkPhantomCallbackShape(phantom_EnterConnector, phantom_LeaveConnector); var detectorShape = new HkSphereShape(extents.AbsMax()); return new HkBvShape(detectorShape, phantom, HkReferencePolicy.TakeOwnership); } }
private void phantom_Leave(HkPhantomCallbackShape shape, HkRigidBody body) { ProfilerShort.Begin("MergeLeave"); var entities = MyPhysicsExtensions.GetAllEntities(body); foreach (var entity in entities) { m_gridList.Remove(entity as MyCubeGrid); } entities.Clear(); ProfilerShort.End(); }
private void phantom_LeaveEjector(HkPhantomCallbackShape shape, HkRigidBody body) { var updateEmissivity = (m_detectedFloaters.Count == 2); m_detectedFloaters.Remove(body.GetEntity()); if (updateEmissivity) UpdateEmissivity(); }
private void phantom_LeaveConnector(HkPhantomCallbackShape shape, HkRigidBody body) { var entities = body.GetAllEntities(); foreach (var entity in entities) { var other = entity as MyCubeGrid; if (other == null || other == this.CubeGrid) continue; m_detectedGrids.Remove(other); } entities.Clear(); }
private void phantom_EnterEjector(HkPhantomCallbackShape shape, HkRigidBody body) { var entity = body.GetEntity(); Debug.Assert(entity is MyFloatingObject); if (entity is MyFloatingObject) { var updateEmissivity = (m_detectedFloaters.Count == 1); m_detectedFloaters.Add(entity); if (updateEmissivity) UpdateEmissivity(); } }
private void phantom_EnterConnector(HkPhantomCallbackShape shape, HkRigidBody body) { var other = body.GetEntity() as MyCubeGrid; if (other == null || other == this.CubeGrid) return; m_detectedGrids.Add(other); }
private void phantom_Enter(HkPhantomCallbackShape shape, HkRigidBody body) { var other = body.GetEntity() as MyCubeGrid; if (other == null || other.GridSizeEnum != CubeGrid.GridSizeEnum || other == this.CubeGrid) return; m_gridList.Add(other); }