本文整理汇总了C#中IMyEntity类的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity类的具体用法?C# IMyEntity怎么用?C# IMyEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMyEntity类属于命名空间,在下文中一共展示了IMyEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReduceControl
void IMyPlayerCollection.ReduceControl(IMyControllableEntity entityWhichKeepsControl, IMyEntity entityWhichLoosesControl)
{
var e1 = entityWhichKeepsControl as Sandbox.Game.Entities.IMyControllableEntity;
var e2 = entityWhichLoosesControl as MyEntity;
if (e1 != null && e2 != null)
ReduceControl(e1, e2);
}
示例2: TryExtendControl
void IMyPlayerCollection.TryExtendControl(IMyControllableEntity entityWithControl, IMyEntity entityGettingControl)
{
var e1 = entityWithControl as Sandbox.Game.Entities.IMyControllableEntity;
var e2 = entityGettingControl as MyEntity;
if (e1 != null && e2 != null)
TryExtendControl(e1, e2);
}
示例3:
void Sandbox.ModAPI.Ingame.IMyLargeTurretBase.SetTarget(IMyEntity entity)
{
if (entity != null)
{
MyMultiplayer.RaiseEvent(this, x => x.SetTargetRequest, entity.EntityId, false);
}
}
示例4: GetWeaponsTargetingProjectile
public static short GetWeaponsTargetingProjectile(IMyEntity entity)
{
short result;
if (!WeaponsTargetingProjectile.TryGetValue(entity.EntityId, out result))
result = 0;
return result;
}
示例5: Use
public override void Use(UseActionEnum actionEnum, IMyEntity entity)
{
var user = entity as MyCharacter;
var block = Entity as MyCubeBlock;
if (block != null)
{
var relation = block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
if (!relation.IsFriendly())
{
if (user.ControllerInfo.IsLocallyHumanControlled())
{
MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
}
return;
}
}
switch (actionEnum)
{
case UseActionEnum.OpenInventory:
case UseActionEnum.OpenTerminal:
MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
break;
default:
//MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
break;
}
}
示例6: HandleAddDecal
/// <param name="damage">Not used for now but could be used as a multiplier instead of random decal size</param>
public static void HandleAddDecal(IMyEntity entity, MyHitInfo hitInfo, MyStringHash source = default(MyStringHash), object customdata = null, float damage = -1)
{
IMyDecalProxy proxy = entity as IMyDecalProxy;
if (proxy != null)
{
AddDecal(proxy, ref hitInfo, damage, source, customdata);
return;
}
MyCubeGrid grid = entity as MyCubeGrid;
if (grid != null)
{
var block = grid.GetTargetedBlock(hitInfo.Position);
if (block != null)
{
var compoundBlock = block.FatBlock as MyCompoundCubeBlock;
if (compoundBlock == null)
proxy = block;
else
proxy = compoundBlock;
}
}
if (proxy == null)
return;
AddDecal(proxy, ref hitInfo, damage, source, customdata);
}
示例7: FindPlayer
private IMyPlayer FindPlayer(IMyEntity entity)
{
List<IMyPlayer> players = new List<IMyPlayer>();
MyAPIGateway.Players.GetPlayers(players);
double nearestDistance = 5; // usually the distance between player and handtool is about 2 to 3, 5 is plenty
IMyPlayer nearestPlayer = null;
foreach (IMyPlayer player in players)
{
var character = player.GetCharacter();
if (character != null)
{
var distance = (((IMyEntity)character).GetPosition() - entity.GetPosition()).LengthSquared();
if (distance < nearestDistance)
{
nearestDistance = distance;
nearestPlayer = player;
}
}
}
return nearestPlayer;
}
示例8: HandleAddDecal
/// <param name="damage">Not used for now but could be used as a multiplier instead of random decal size</param>
public static void HandleAddDecal(IMyEntity entity, MyHitInfo hitInfo, MyStringHash source = default(MyStringHash), float damage = -1)
{
if (entity == null)
DebugNullEntity();
IMyDecalProxy proxy = entity as IMyDecalProxy;
if (proxy != null)
{
AddDecal(proxy, ref hitInfo, damage, source);
return;
}
MyCubeGrid grid = entity.GetTopMostParent() as MyCubeGrid;
if (grid != null)
{
var block = grid.GetTargetedBlock(hitInfo.Position);
if (block != null)
{
var compoundBlock = block.FatBlock as MyCompoundCubeBlock;
if (compoundBlock == null)
proxy = block;
else
proxy = compoundBlock;
}
}
if (proxy != null)
AddDecal(proxy, ref hitInfo, damage, source);
}
示例9: MyUseObjectCryoChamberDoor
public MyUseObjectCryoChamberDoor(IMyEntity owner, string dummyName, MyModelDummy dummyData, uint key)
{
CryoChamber = owner as MyCryoChamber;
Debug.Assert(CryoChamber != null, "MyUseObjectCryoChamberDoor should only be used with MyCryoChamber blocks!");
LocalMatrix = dummyData.Matrix;
}
示例10: EntityComponent
public EntityComponent(IMyEntity entity)
: base()
{
Entity = entity;
Log = new Logger("SEGarden.Logic.EntityComponent", (() => EntityId.ToString()));
//Log.Trace("Finished EntityComponent ctr", "ctr");
}
示例11: Character
public Character(IMyEntity entity)
: base(entity)
{
Log.ClassName = "GP.Concealment.World.Entities.Character";
Log.Trace("New Character " + Entity.EntityId + " " + DisplayName, "ctr");
CharacterEntity = Entity as IMyCharacter;
}
示例12: Waypoint
public Waypoint(Mover mover, AllNavigationSettings navSet, AllNavigationSettings.SettingsLevelName level, IMyEntity targetEntity, Vector3D worldOffset)
: base(mover, navSet)
{
this.m_logger = new Logger(GetType().Name, m_controlBlock.CubeBlock);
this.m_level = level;
this.m_targetEntity = targetEntity;
this.m_targetOffset = worldOffset;
m_logger.debugLog(targetEntity != targetEntity.GetTopMostParent(), "targetEntity is not top-most", Logger.severity.FATAL);
IMyCubeGrid asGrid = targetEntity as IMyCubeGrid;
if (asGrid != null && Attached.AttachedGrid.IsGridAttached(asGrid, m_controlBlock.CubeGrid, Attached.AttachedGrid.AttachmentKind.Physics))
{
m_logger.debugLog("Cannot fly to entity, attached: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
new GOLIS(mover, navSet, TargetPosition, level);
return;
}
if (targetEntity.Physics == null)
{
m_logger.debugLog("Target has no physics: " + targetEntity.getBestName() + ", creating GOLIS", Logger.severity.WARNING);
new GOLIS(mover, navSet, TargetPosition, level);
return;
}
var setLevel = navSet.GetSettingsLevel(level);
setLevel.NavigatorMover = this;
//setLevel.DestinationEntity = mover.Block.CubeBlock; // to force avoidance
m_logger.debugLog("created, level: " + level + ", target: " + targetEntity.getBestName() + ", target position: " + targetEntity.GetPosition() + ", offset: " + worldOffset + ", position: " + TargetPosition, Logger.severity.DEBUG);
}
示例13: ProtectedEntity
private void ProtectedEntity(IMyEntity entity, ProtectedItem item)
{
//Logging.WriteLineAndConsole(string.Format("Protecting: {0}", entity.EntityId));
//CubeGridEntity gridEntity = new CubeGridEntity((MyObjectBuilder_CubeGrid)entity.GetObjectBuilder(), entity);
CubeGridEntity gridEntity = (CubeGridEntity)GameEntityManager.GetEntity(entity.EntityId);
MyObjectBuilder_CubeGrid grid = (MyObjectBuilder_CubeGrid)entity.GetObjectBuilder();
int count = 0;
while (gridEntity.IsLoading)
{
if (count >= 20)
return;
Thread.Sleep(100);
count++;
}
bool found = false;
/*
foreach(CubeBlockEntity block in gridEntity.CubeBlocks)
{
if (block.IntegrityPercent != item.IntegrityIncrease || block.BuildPercent != item.IntegrityIncrease || block.BoneDamage > 0f)
{
found = true;
block.FixBones(0, 100);
block.IntegrityPercent = item.IntegrityIncrease;
block.BuildPercent = item.IntegrityIncrease;
}
}
*/
if(found)
Logging.WriteLineAndConsole(string.Format("Repaired Grid: {0}", gridEntity.EntityId));
}
示例14: Process
private static void Process(IMyEntity entity, MessageSyncEntity syncEntity)
{
if (MyAPIGateway.Multiplayer.MultiplayerActive)
ConnectionHelper.SendMessageToAll(syncEntity);
else
syncEntity.CommonProcess(entity);
}
示例15:
void Sandbox.ModAPI.Ingame.IMyLargeTurretBase.SetTarget(IMyEntity entity)
{
if (entity != null)
{
SyncObject.SendSetTarget(entity.EntityId, false);
}
}