本文整理汇总了C#中IMyEntity类的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity类的具体用法?C# IMyEntity怎么用?C# IMyEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMyEntity类属于命名空间,在下文中一共展示了IMyEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyPlayerCollection_ModAPI.cs
示例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);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyPlayerCollection_ModAPI.cs
示例3:
void Sandbox.ModAPI.Ingame.IMyLargeTurretBase.SetTarget(IMyEntity entity)
{
if (entity != null)
{
MyMultiplayer.RaiseEvent(this, x => x.SetTargetRequest, entity.EntityId, false);
}
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:7,代码来源:MyLargeTurretBase_ModAPI.cs
示例4: GetWeaponsTargetingProjectile
public static short GetWeaponsTargetingProjectile(IMyEntity entity)
{
short result;
if (!WeaponsTargetingProjectile.TryGetValue(entity.EntityId, out result))
result = 0;
return result;
}
开发者ID:helppass,项目名称:Autopilot,代码行数:7,代码来源:TargetingBase.cs
示例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;
}
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:29,代码来源:MyUseObjectInventory.cs
示例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);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:29,代码来源:MyDecals.cs
示例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;
}
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:25,代码来源:HandtoolCache.cs
示例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);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:30,代码来源:MyDecals.cs
示例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;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyUseObjectCryoChamberDoor.cs
示例10: EntityComponent
public EntityComponent(IMyEntity entity)
: base()
{
Entity = entity;
Log = new Logger("SEGarden.Logic.EntityComponent", (() => EntityId.ToString()));
//Log.Trace("Finished EntityComponent ctr", "ctr");
}
开发者ID:zrisher,项目名称:SEGarden,代码行数:7,代码来源:EntityComponent.cs
示例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;
}
开发者ID:zrisher,项目名称:GardenPerformance,代码行数:7,代码来源:Character.cs
示例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);
}
开发者ID:Souper07,项目名称:Autopilot,代码行数:30,代码来源:Waypoint.cs
示例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));
}
开发者ID:afinegan,项目名称:EssentialsPlugin,代码行数:33,代码来源:ProcessProtection.cs
示例14: Process
private static void Process(IMyEntity entity, MessageSyncEntity syncEntity)
{
if (MyAPIGateway.Multiplayer.MultiplayerActive)
ConnectionHelper.SendMessageToAll(syncEntity);
else
syncEntity.CommonProcess(entity);
}
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:7,代码来源:MessageSyncEntity.cs
示例15:
void Sandbox.ModAPI.Ingame.IMyLargeTurretBase.SetTarget(IMyEntity entity)
{
if (entity != null)
{
SyncObject.SendSetTarget(entity.EntityId, false);
}
}
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:7,代码来源:MyLargeTurretBase_ModAPI.cs
示例16: NavInfo
public NavInfo(Vector3D fromPosition, Vector3D toPosition, IMyEntity shipControls)
{
_fromPosition = fromPosition;
_toPosition = toPosition;
_shipControls = shipControls;
Init();
}
开发者ID:ESearcy,项目名称:PVE-AI-Drones-Drone-Conquest,代码行数:7,代码来源:NavInfo.cs
示例17: AddChild
/// <summary>
/// Adds the child.
/// </summary>
/// <param name="child">The child.</param>
/// <param name="preserveWorldPos">if set to <c>true</c> [preserve absolute position].</param>
public void AddChild(IMyEntity child, bool preserveWorldPos = false, bool insertIntoSceneIfNeeded = true)
{
//MyEntities.Remove(child); // if it's already in the world, remove it
MyHierarchyComponentBase childHierarchy = child.Components.Get<MyHierarchyComponentBase>();
childHierarchy.Parent = this;
if (preserveWorldPos)
{
var tmpWorldMatrix = child.WorldMatrix;
this.Children.Add(childHierarchy);
child.WorldMatrix = tmpWorldMatrix;
}
else
{
this.Children.Add(childHierarchy);
MyPositionComponentBase positionComponent = Container.Get<MyPositionComponentBase>();
MyPositionComponentBase childPositionComponent = child.Components.Get<MyPositionComponentBase>();
var m = positionComponent.WorldMatrix;
childPositionComponent.UpdateWorldMatrix(ref m);
}
if (Container.Entity.InScene && !child.InScene && insertIntoSceneIfNeeded)
child.OnAddedToScene(Container.Entity);
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:34,代码来源:MyHierarchyComponentBase.cs
示例18: TurnOnShip
private void TurnOnShip(IMyEntity shipEntity, out int reactorCounter, out int batteryCounter)
{
reactorCounter = 0;
batteryCounter = 0;
var grids = shipEntity.GetAttachedGrids(AttachedGrids.Static);
foreach (var cubeGrid in grids)
{
var blocks = new List<Sandbox.ModAPI.IMySlimBlock>();
cubeGrid.GetBlocks(blocks, f => f.FatBlock != null
&& f.FatBlock is IMyFunctionalBlock
&& (f.FatBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor)
|| f.FatBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_BatteryBlock)));
var list = blocks.Select(f => (IMyFunctionalBlock)f.FatBlock).Where(f => !f.Enabled).ToArray();
foreach (var item in list)
{
MessageSyncBlock.Process(item, SyncBlockType.PowerOn);
if (item.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor))
reactorCounter++;
else
batteryCounter++;
}
}
}
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:27,代码来源:CommandShipOn.cs
示例19: RepairShip
private void RepairShip(IMyEntity shipEntity)
{
// We SHOULD NOT make any changes directly to the prefab, we need to make a Value copy using Clone(), and modify that instead.
var gridObjectBuilder = shipEntity.GetObjectBuilder().Clone() as MyObjectBuilder_CubeGrid;
shipEntity.Physics.Deactivate();
// This will Delete the entity and sync to all.
// Using this, also works with player ejection in the same Tick.
shipEntity.SyncObject.SendCloseRequest();
gridObjectBuilder.EntityId = 0;
if (gridObjectBuilder.Skeleton == null)
gridObjectBuilder.Skeleton = new List<BoneInfo>();
else
gridObjectBuilder.Skeleton.Clear();
foreach (var cube in gridObjectBuilder.CubeBlocks)
{
cube.IntegrityPercent = cube.BuildPercent;
cube.DeformationRatio = 0;
// No need to set bones for individual blocks like rounded armor, as this is taken from the definition within the game itself.
}
var tempList = new List<MyObjectBuilder_EntityBase>();
tempList.Add(gridObjectBuilder);
tempList.CreateAndSyncEntities();
MyAPIGateway.Utilities.ShowMessage("repair", "Ship '{0}' has been repairded.", shipEntity.DisplayName);
}
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:31,代码来源:CommandShipRepair.cs
示例20: Use
public void Use(UseActionEnum actionEnum, IMyEntity entity)
{
var user = entity as MyCharacter;
switch(actionEnum)
{
case UseActionEnum.Manipulate:
if (!m_buttonPanel.IsWorking)
return;
if (!m_buttonPanel.AnyoneCanUse && !m_buttonPanel.HasLocalPlayerAccess())
{
MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
return;
}
m_buttonPanel.Toolbar.UpdateItem(m_index);
m_buttonPanel.Toolbar.ActivateItemAtIndex(m_index);
m_buttonPanel.PressButton(m_index);
break;
case UseActionEnum.OpenTerminal:
if (!m_buttonPanel.HasLocalPlayerAccess())
return;
MyToolbarComponent.CurrentToolbar = m_buttonPanel.Toolbar;
MyGuiScreenBase screen = MyGuiScreenCubeBuilder.Static;
if (screen == null)
screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, m_buttonPanel);
MyToolbarComponent.AutoUpdate = false;
screen.Closed += (source) => MyToolbarComponent.AutoUpdate = true;
MyGuiSandbox.AddScreen(screen);
break;
default:
break;
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:32,代码来源:MyUseObjectPanelButton.cs
注:本文中的IMyEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论