本文整理汇总了C#中VRage.Game.Entity.MyEntity类的典型用法代码示例。如果您正苦于以下问题:C# MyEntity类的具体用法?C# MyEntity怎么用?C# MyEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyEntity类属于VRage.Game.Entity命名空间,在下文中一共展示了MyEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
}
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:26,代码来源:MySmallObjectPhysicsStateGroup.cs
示例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;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyPhysicalInventoryItemExtensions.cs
示例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);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MySessionComponentTriggerSystem.cs
示例4: m_entity_OnClose
void m_entity_OnClose(MyEntity obj)
{
if (m_shotSmoke != null)
{
MyParticlesManager.RemoveParticleEffect(m_shotSmoke);
m_shotSmoke = null;
}
}
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:8,代码来源:MyLargeBarrelBase.cs
示例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;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:10,代码来源:MyGridContactInfo.cs
示例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));
}
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:11,代码来源:MyLargeInteriorBarrel.cs
示例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;
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:12,代码来源:MySmallObjectPhysicsStateGroup.cs
示例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);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:13,代码来源:MySessionComponentTriggerSystem.cs
示例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);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:17,代码来源:MyEnvironmentalEntityCacher.cs
示例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;
}
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:20,代码来源:MyLargeBarrelBase.cs
示例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);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:39,代码来源:MyMultiBlockClipboard.cs
示例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();
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:10,代码来源:MyGridClipboard.cs
示例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);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:15,代码来源:MyGridClipboard.cs
示例14: gunEntity_OnClose
void gunEntity_OnClose(MyEntity obj)
{
if (m_currentWeapon == obj)
m_currentWeapon = null;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:5,代码来源:MyCharacter.cs
示例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;
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:40,代码来源:MySensorBlock.cs
示例16: UnequipWeapon
public void UnequipWeapon()
{
if (m_leftHandItem != null && m_leftHandItem is IMyHandheldGunObject<MyDeviceBase>)
{
(m_leftHandItem as IMyHandheldGunObject<MyDeviceBase>).OnControlReleased();
m_leftHandItem.Close(); // no dual wielding now
m_leftHandItem = null;
TriggerCharacterAnimationEvent("unequip_left_tool", true);
}
if (m_currentWeapon != null)
{
var weaponEntity = m_currentWeapon as MyEntity;
SaveAmmoToWeapon();
m_currentWeapon.OnControlReleased();
var weaponSink = weaponEntity.Components.Get<MyResourceSinkComponent>();
if (weaponSink != null)
SuitRechargeDistributor.RemoveSink(weaponSink);
weaponEntity.OnClose -= gunEntity_OnClose;
MyEntities.Remove(weaponEntity);
weaponEntity.Close();
var useAnimationInsteadOfIK = MyPerGameSettings.CheckUseAnimationInsteadOfIK(m_currentWeapon);
m_currentWeapon = null;
if (ControllerInfo.IsLocallyHumanControlled() && MySector.MainCamera != null)
{
MySector.MainCamera.Zoom.ResetZoom();
}
if (useAnimationInsteadOfIK)
{
StopUpperAnimation(0.2f);
SwitchAnimation(m_currentMovementState, false);
}
TriggerCharacterAnimationEvent("unequip_left_tool", true);
TriggerCharacterAnimationEvent("unequip_right_tool", true);
MyAnalyticsHelper.ReportActivityEnd(this, "item_equip");
}
if (m_currentShotTime <= 0)
{
//Otherwise all upper players keep updating
StopUpperAnimation(0);
StopFingersAnimation(0);
}
//MyHud.Crosshair.Hide();
m_currentWeapon = null;
StopFingersAnimation(0);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:60,代码来源:MyCharacter.cs
示例17: EquipWeapon
private void EquipWeapon(IMyHandheldGunObject<MyDeviceBase> newWeapon, bool showNotification = false)
{
// Debug.Assert(newWeapon != null);
if (newWeapon == null)
return;
MyEntity gunEntity = (MyEntity)newWeapon;
gunEntity.Render.CastShadows = true;
gunEntity.Render.NeedsResolveCastShadow = false;
gunEntity.Save = false;
gunEntity.OnClose += gunEntity_OnClose;
MyEntities.Add(gunEntity);
m_handItemDefinition = null;
m_currentWeapon = newWeapon;
m_currentWeapon.OnControlAcquired(this);
UseAnimationForWeapon |= m_currentWeapon.ForceAnimationInsteadOfIK;
if (WeaponEquiped != null)
WeaponEquiped(m_currentWeapon);
MyAnalyticsHelper.ReportActivityStart(this, "item_equip", "character", "toolbar_item_usage", m_currentWeapon.GetType().Name);
// CH:TODO: The hand item definitions should be changed to handheld gun object definitions and should be taken according to m_currentWeapon typeId
if (m_currentWeapon.PhysicalObject != null)
{
var handItemId = m_currentWeapon.PhysicalObject.GetId();
m_handItemDefinition = MyDefinitionManager.Static.TryGetHandItemForPhysicalItem(handItemId);
System.Diagnostics.Debug.Assert(m_handItemDefinition != null, "Create definition for this hand item!");
}
else if (m_currentWeapon.DefinitionId.TypeId == typeof(MyObjectBuilder_CubePlacer))
{
var gunID = new MyDefinitionId(typeof(MyObjectBuilder_CubePlacer));
m_handItemDefinition = MyDefinitionManager.Static.TryGetHandItemDefinition(ref gunID);
System.Diagnostics.Debug.Assert(m_handItemDefinition != null, "Create definition for this hand item!");
}
//Setup correct worldmatrix to weapon
//CalculateDependentMatrices();
if (m_handItemDefinition != null && !string.IsNullOrEmpty(m_handItemDefinition.FingersAnimation))
{
string animationSubtype;
if (!m_characterDefinition.AnimationNameToSubtypeName.TryGetValue(m_handItemDefinition.FingersAnimation, out animationSubtype))
{
animationSubtype = m_handItemDefinition.FingersAnimation;
}
var def = MyDefinitionManager.Static.TryGetAnimationDefinition(animationSubtype);
if (!def.LeftHandItem.TypeId.IsNull)
{
m_currentWeapon.OnControlReleased();
(m_currentWeapon as MyEntity).Close(); //no dual wielding now
m_currentWeapon = null;
}
PlayCharacterAnimation(m_handItemDefinition.FingersAnimation, MyBlendOption.Immediate, def.Loop ? MyFrameOption.Loop : MyFrameOption.PlayOnce, 1.0f, 1, false, null);
if (UseNewAnimationSystem)
{
TriggerCharacterAnimationEvent("equip_left_tool", true);
TriggerCharacterAnimationEvent("equip_right_tool", true);
TriggerCharacterAnimationEvent(m_handItemDefinition.Id.SubtypeName.ToLower(), true);
TriggerCharacterAnimationEvent(m_handItemDefinition.FingersAnimation.ToLower(), true);
}
if (!def.LeftHandItem.TypeId.IsNull)
{
if (m_leftHandItem != null)
{
(m_leftHandItem as IMyHandheldGunObject<Sandbox.Game.Weapons.MyDeviceBase>).OnControlReleased();
m_leftHandItem.Close();
}
// CH: TODO: The entity id is not synced, but it never was in this place. It should be fixed later
long handItemId = MyEntityIdentifier.AllocateId();
uint? inventoryItemId = null;
var builder = GetObjectBuilderForWeapon(def.LeftHandItem, ref inventoryItemId, handItemId);
var leftHandItem = CreateGun(builder, inventoryItemId);
if (leftHandItem != null)
{
m_leftHandItem = leftHandItem as MyEntity;
leftHandItem.OnControlAcquired(this);
UpdateLeftHandItemPosition();
MyEntities.Add(m_leftHandItem);
}
}
}
else if (m_handItemDefinition != null)
{
if (UseNewAnimationSystem)
{
TriggerCharacterAnimationEvent("equip_left_tool", true);
TriggerCharacterAnimationEvent("equip_right_tool", true);
TriggerCharacterAnimationEvent(m_handItemDefinition.Id.SubtypeName.ToLower(), true);
}
//.........这里部分代码省略.........
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:101,代码来源:MyCharacter.cs
示例18: GetDamageFromFall
private DamageImpactEnum GetDamageFromFall(HkRigidBody collidingBody, MyEntity collidingEntity, ref HkContactPointEvent value)
{
//if (m_currentMovementState != MyCharacterMovementEnum.Falling || m_currentMovementState != MyCharacterMovementEnum.Jump) return DamageImpactEnum.NoDamage;
//if (!collidingBody.IsFixed && collidingBody.Mass < Physics.Mass * 50) return DamageImpactEnum.NoDamage;
float dotProd = Vector3.Dot(value.ContactPoint.Normal, Vector3.Normalize(Physics.HavokWorld.Gravity));
bool falledOnEntity = dotProd <= 0.0f;
if (!falledOnEntity) return DamageImpactEnum.NoDamage;
if (Math.Abs(value.SeparatingVelocity * dotProd) < MyPerGameSettings.CharacterDamageMinVelocity) return DamageImpactEnum.NoDamage;
if (Math.Abs(value.SeparatingVelocity * dotProd) > MyPerGameSettings.CharacterDamageDeadlyDamageVelocity) return DamageImpactEnum.DeadlyDamage;
if (Math.Abs(value.SeparatingVelocity * dotProd) > MyPerGameSettings.CharacterDamageMediumDamageVelocity) return DamageImpactEnum.MediumDamage;
return DamageImpactEnum.SmallDamage;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:19,代码来源:MyCharacter.cs
示例19: CloseInternal
private void CloseInternal()
{
if (m_currentWeapon != null)
{
((MyEntity)m_currentWeapon).Close();
m_currentWeapon = null;
}
if (m_leftHandItem != null)
{
m_leftHandItem.Close();
m_leftHandItem = null;
}
RemoveNotifications();
RadioBroadcaster.Enabled = false;
if (MyToolbarComponent.CharacterToolbar != null)
MyToolbarComponent.CharacterToolbar.ItemChanged -= Toolbar_ItemChanged;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:20,代码来源:MyCharacter.cs
示例20: GetDamageFromHit
private DamageImpactEnum GetDamageFromHit(HkRigidBody collidingBody, MyEntity collidingEntity, ref HkContactPointEvent value)
{
if (collidingBody.LinearVelocity.Length() < MyPerGameSettings.CharacterDamageHitObjectMinVelocity) return DamageImpactEnum.NoDamage;
if (collidingEntity == ManipulatedEntity) return DamageImpactEnum.NoDamage;
if (collidingBody.HasProperty(HkCharacterRigidBody.MANIPULATED_OBJECT)) return DamageImpactEnum.NoDamage;
var mass = (MyPerGameSettings.Destruction ? MyDestructionHelper.MassFromHavok(collidingBody.Mass) : collidingBody.Mass);
if (mass < MyPerGameSettings.CharacterDamageHitObjectMinMass) return DamageImpactEnum.NoDamage;
// Get the objects energies to calculate the damage - must be higher above treshold
float objectEnergy = Math.Abs(value.SeparatingVelocity) * mass;
if (objectEnergy > MyPerGameSettings.CharacterDamageHitObjectDeadlyEnergy) return DamageImpactEnum.DeadlyDamage;
if (objectEnergy > MyPerGameSettings.CharacterDamageHitObjectCriticalEnergy) return DamageImpactEnum.CriticalDamage;
if (objectEnergy > MyPerGameSettings.CharacterDamageHitObjectMediumEnergy) return DamageImpactEnum.MediumDamage;
if (objectEnergy > MyPerGameSettings.CharacterDamageHitObjectSmallEnergy) return DamageImpactEnum.SmallDamage;
return DamageImpactEnum.NoDamage;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:21,代码来源:MyCharacter.cs
注:本文中的VRage.Game.Entity.MyEntity类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论