本文整理汇总了C#中IMyEntity.GetAttachedGrids方法的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity.GetAttachedGrids方法的具体用法?C# IMyEntity.GetAttachedGrids怎么用?C# IMyEntity.GetAttachedGrids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyEntity
的用法示例。
在下文中一共展示了IMyEntity.GetAttachedGrids方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TurnOnShip
private void TurnOnShip(IMyEntity shipEntity, out int reactorCounter, out int batteryCounter)
{
reactorCounter = 0;
batteryCounter = 0;
var grids = shipEntity.GetAttachedGrids();
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)
{
item.RequestEnable(true);
if (item.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor))
reactorCounter++;
else
batteryCounter++;
}
}
}
示例2: DeleteShip
private void DeleteShip(IMyEntity shipEntity)
{
var grids = shipEntity.GetAttachedGrids(AttachedGrids.Static);
foreach (var cubeGrid in grids)
{
// ejects any player prior to deleting the grid.
cubeGrid.EjectControllingPlayers();
var name = cubeGrid.DisplayName;
// This will Delete the entity and sync to all.
// Using this, also works with player ejection in the same Tick.
cubeGrid.SyncObject.SendCloseRequest();
MyAPIGateway.Utilities.ShowMessage("ship", "'{0}' deleted.", name);
}
}
示例3: ChangeCubeShareMode
private void ChangeCubeShareMode(IMyEntity selectedShip, MyOwnershipShareModeEnum shareMode)
{
var grids = selectedShip.GetAttachedGrids(AttachedGrids.Static);
foreach (var grid in grids)
{
var blocks = new List<IMySlimBlock>();
grid.GetBlocks(blocks, f => f.FatBlock != null && f.FatBlock.OwnerId != 0);
foreach (var block in blocks)
block.FatBlock.ChangeOwner(block.FatBlock.OwnerId, shareMode);
}
}
示例4: MoveShipByOffset
private static bool MoveShipByOffset(IMyEntity cubeGrid, Vector3D worldOffset, bool safely, Action<Vector3D> updatedPosition, Action noSafeLocationMessage)
{
var grids = cubeGrid.GetAttachedGrids();
var currentPosition = cubeGrid.GetPosition();
Vector3D position = cubeGrid.GetPosition() + worldOffset;
if (safely)
{
var worldVolume = grids[0].WorldVolume;
foreach (var grid in grids)
{
worldVolume.Include(grid.WorldVolume);
}
// TODO: determine good location for moving one ship to another, checking for OrientedBoundingBox.Intersects() for a tighter fit.
if (!FindEntityFreePosition(ref position, cubeGrid, worldVolume))
{
if (noSafeLocationMessage != null)
noSafeLocationMessage.Invoke();
return false;
}
}
foreach (var grid in grids)
MessageSyncEntity.Process(grid, SyncEntityType.Position, position);
if (updatedPosition != null)
updatedPosition.Invoke(currentPosition);
return true;
}
示例5: MoveShipToShip
public static bool MoveShipToShip(IMyEntity shipGrid, IMyEntity targetshipGrid)
{
// TODO: determine good location for moving one ship to another, checking for OrientedBoundingBox.Intersects().
//// Move the ship the player is piloting.
//var cubeGrid = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetTopMostParent();
var grids = shipGrid.GetAttachedGrids();
//var worldOffset = position - MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetPosition();
MyAPIGateway.Utilities.ShowMessage("Incomplete", "This function not complete. Cannot transport piloted Ship to another ship.");
foreach (var grid in grids)
{
//grid.SetPosition(grid.GetPosition() + worldOffset);
}
//save teleport in history
//CommandBack.SaveTeleportInHistory(currentPosition);
return false;
}
示例6: GetPower
private bool GetPower(IMyEntity shipEntity)
{
var grids = shipEntity.GetAttachedGrids();
return false;
}
示例7: ChangeCubeShareMode
private void ChangeCubeShareMode(IMyEntity selectedShip, long oldPlayer, long newPlayer, MyOwnershipShareModeEnum shareMode)
{
var grids = selectedShip.GetAttachedGrids();
foreach (var grid in grids)
{
var blocks = new List<IMySlimBlock>();
// we only want to change the share of blocks you own currently.
grid.GetBlocks(blocks, f => f.FatBlock != null && f.FatBlock.OwnerId == oldPlayer);
foreach (var block in blocks)
block.FatBlock.ChangeOwner(newPlayer, shareMode);
}
}