本文整理汇总了C#中VRage.Game.Entity.MyEntity类的典型用法代码示例。如果您正苦于以下问题:C# MyEntity类的具体用法?C# MyEntity怎么用?C# MyEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyEntity类属于VRage.Game.Entity命名空间,在下文中一共展示了MyEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeActive
protected void SerializeActive(BitStream stream, MyEntity entity)
{
if (stream.Writing)
{
if (entity.Physics.RigidBody != null && entity.Physics.RigidBody.IsActive)
stream.WriteBool(true);
else
stream.WriteBool(false);
}
else
{
// reading
bool isActive = stream.ReadBool();
if (entity != null && entity.Physics != null)
{
HkRigidBody rb = entity.Physics.RigidBody;
if (rb != null)
{
if (isActive)
rb.Activate();
else
rb.Deactivate();
}
}
}
}
示例2: Spawn
public static MyEntity Spawn(this MyPhysicalInventoryItem thisItem, MyFixedPoint amount, BoundingBoxD box, MyEntity owner = null)
{
if(amount < 0)
{
return null;
}
MatrixD spawnMatrix = MatrixD.Identity;
spawnMatrix.Translation = box.Center;
var entity = Spawn(thisItem, amount, spawnMatrix, owner);
if (entity == null)
return null;
var size = entity.PositionComp.LocalVolume.Radius;
var halfSize = box.Size / 2 - new Vector3(size);
halfSize = Vector3.Max(halfSize, Vector3.Zero);
box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
var pos = MyUtils.GetRandomPosition(ref box);
Vector3 forward = MyUtils.GetRandomVector3Normalized();
Vector3 up = MyUtils.GetRandomVector3Normalized();
while (forward == up)
up = MyUtils.GetRandomVector3Normalized();
Vector3 right = Vector3.Cross(forward, up);
up = Vector3.Cross(right, forward);
entity.WorldMatrix = MatrixD.CreateWorld(pos, forward, up);
return entity;
}
示例3: RemoveTrigger
public void RemoveTrigger(MyEntity entity, MyTriggerComponent trigger)
{
if (m_updateLock)
m_removeCacheTrigger.Add(new MyTuple<MyEntity, MyTriggerComponent>(entity, trigger));
else
RemoveTriggerCached(entity, trigger);
}
示例4: m_entity_OnClose
void m_entity_OnClose(MyEntity obj)
{
if (m_shotSmoke != null)
{
MyParticlesManager.RemoveParticleEffect(m_shotSmoke);
m_shotSmoke = null;
}
}
示例5: MyGridContactInfo
public MyGridContactInfo(ref HkContactPointEvent evnt, MyCubeGrid grid)
{
Event = evnt;
ContactPosition = grid.Physics.ClusterToWorld(evnt.ContactPoint.Position);
m_currentEntity = grid;
m_collidingEntity = Event.GetOtherEntity(grid) as MyEntity;
m_currentBlock = null;
m_otherBlock = null;
ImpulseMultiplier = 1;
}
示例6: Init
public override void Init(MyEntity entity, MyLargeTurretBase turretBase)
{
base.Init(entity, turretBase);
// backward compatibility with old mods/models
if (!m_gunBase.HasDummies)
{
Vector3 muzzleVec = -Entity.PositionComp.WorldMatrix.Forward * 0.8f;
m_gunBase.AddMuzzleMatrix(MyAmmoType.HighSpeed, Matrix.CreateTranslation(muzzleVec));
}
}
示例7: ValidatePosition
static bool ValidatePosition(MyEntity entity, Vector3D position)
{
float positionTolerancy = Math.Max(entity.PositionComp.MaximalSize * 0.1f, 0.1f);
float smallSpeed = 0.1f;
if (entity.m_serverLinearVelocity == Vector3.Zero || entity.m_serverLinearVelocity.Length() < smallSpeed)
// some tolerancy of position for not moving objects
positionTolerancy = Math.Max(entity.PositionComp.MaximalSize * 0.5f, 1.0f);
if ((position - entity.PositionComp.GetPosition()).Length() < positionTolerancy)
return false;
return true;
}
示例8: RemoveTriggerCached
private void RemoveTriggerCached(MyEntity entity, MyTriggerComponent trigger)
{
if (m_triggers.ContainsKey(entity) && m_triggers[entity].Contains(trigger))
{
if (m_triggers[entity].Count == 1)
{
m_triggers[entity].Clear();
m_triggers.Remove(entity);
}
else
m_triggers[entity].Remove(trigger);
}
}
示例9: QueueEntity
public void QueueEntity(MyEntity entity)
{
long time = Time();
time += EntityPreserveTime;
m_entities.Insert(new EntityReference
{
Entity = entity
}, time);
m_index.Add(entity.EntityId);
if (UpdateOrder == MyUpdateOrder.NoUpdate)
{
SetUpdateOrder(MyUpdateOrder.AfterSimulation);
}
}
示例10: Init
public virtual void Init(MyEntity entity, MyLargeTurretBase turretBase)
{
m_entity = entity;
m_turretBase = turretBase;
m_gunBase = turretBase.GunBase as MyGunBase;
// Check for the dummy cubes for the muzzle flash positions:
if (m_entity.Model != null)
{
if (m_entity.Model.Dummies.ContainsKey("camera"))
{
CameraDummy = m_entity.Model.Dummies["camera"];
}
m_gunBase.LoadDummies(m_entity.Model.Dummies);
}
m_entity.OnClose += m_entity_OnClose;
}
示例11: TakeMaterialsFromBuilder
public static void TakeMaterialsFromBuilder(List<MyObjectBuilder_CubeGrid> blocksToBuild, MyEntity builder)
{
Debug.Assert(blocksToBuild.Count == 1);
if (blocksToBuild.Count == 0)
return;
// Search for multiblock definition.
var firstBlock = blocksToBuild[0].CubeBlocks.FirstOrDefault();
Debug.Assert(firstBlock != null);
if (firstBlock == null )
return;
MyDefinitionId multiBlockDefId;
var compound = firstBlock as MyObjectBuilder_CompoundCubeBlock;
if (compound != null)
{
Debug.Assert(compound.Blocks != null && compound.Blocks.Length > 0 && compound.Blocks[0].MultiBlockDefinition != null);
if (compound.Blocks == null || compound.Blocks.Length == 0 || compound.Blocks[0].MultiBlockDefinition == null)
return;
multiBlockDefId = compound.Blocks[0].MultiBlockDefinition.Value;
}
else
{
Debug.Assert(firstBlock.MultiBlockDefinition != null);
if (firstBlock.MultiBlockDefinition == null)
return;
multiBlockDefId = firstBlock.MultiBlockDefinition.Value;
}
MyMultiBlockDefinition multiBlockDefinition = MyDefinitionManager.Static.TryGetMultiBlockDefinition(multiBlockDefId);
Debug.Assert(multiBlockDefinition != null);
if (multiBlockDefinition == null)
return;
MyCubeBuilder.BuildComponent.GetMultiBlockPlacementMaterials(multiBlockDefinition);
MyCubeBuilder.BuildComponent.AfterSuccessfulBuild(builder, instantBuild: false);
}
示例12: previewGrid_OnClose
void previewGrid_OnClose(MyEntity obj)
{
m_previewGrids.Remove(obj as MyCubeGrid);
if (m_previewGrids.Count == 0)
{
//TODO: show some notification that the paste failed
// Deactivation commented out because during clipboard moving grid can be hidden (it is closed, see Hide) and deactivation is not wanted.
//Deactivate();
}
}
示例13: DisablePhysicsRecursively
private void DisablePhysicsRecursively(MyEntity entity)
{
if (entity.Physics != null && entity.Physics.Enabled)
entity.Physics.Enabled = false;
var block = entity as MyCubeBlock;
if (block != null && block.UseObjectsComponent.DetectorPhysics != null && block.UseObjectsComponent.DetectorPhysics.Enabled)
block.UseObjectsComponent.DetectorPhysics.Enabled = false;
if (block != null)
block.NeedsUpdate = MyEntityUpdateEnum.NONE;
foreach (var child in entity.Hierarchy.Children)
DisablePhysicsRecursively(child.Container.Entity as MyEntity);
}
示例14: gunEntity_OnClose
void gunEntity_OnClose(MyEntity obj)
{
if (m_currentWeapon == obj)
m_currentWeapon = null;
}
示例15: ShouldDetect
private bool ShouldDetect(MyEntity entity)
{
if (entity == null)
return false;
if (entity == CubeGrid)
return false;
if (DetectPlayers)
{
if (entity is Character.MyCharacter)
return ShouldDetectRelation((entity as Character.MyCharacter).GetRelationTo(OwnerId));
if (entity is MyGhostCharacter)
return ShouldDetectRelation((entity as IMyControllableEntity).ControllerInfo.Controller.Player.GetRelationTo(OwnerId));
}
if (DetectFloatingObjects)
if (entity is MyFloatingObject)
return true;
var grid = entity as MyCubeGrid;
//GR: if grids are logically connected(not physically causes issues with detecting ships with landing gears) return false (mostly for not detecting Piston and Rotor top parts)
if ( grid != null && MyCubeGridGroups.Static.Logical.HasSameGroup(grid, CubeGrid) )
return false;
if (DetectSmallShips)
if (grid != null && grid.GridSizeEnum == MyCubeSize.Small)
return ShouldDetectGrid(grid);
if (DetectLargeShips)
if (grid != null && grid.GridSizeEnum == MyCubeSize.Large && !grid.IsStatic)
return ShouldDetectGrid(grid);
if (DetectStations)
if (grid != null && grid.GridSizeEnum == MyCubeSize.Large && grid.IsStatic)
return ShouldDetectGrid(grid);
if (DetectAsteroids)
if (entity is MyVoxelBase)
return true;
return false;
}