本文整理汇总了C#中IMyCubeBlock类的典型用法代码示例。如果您正苦于以下问题:C# IMyCubeBlock类的具体用法?C# IMyCubeBlock怎么用?C# IMyCubeBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMyCubeBlock类属于命名空间,在下文中一共展示了IMyCubeBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToBlock
public Vector3 ToBlock(IMyCubeBlock block)
{
if (direction_block.HasValue && CubeBlock == block)
{
return direction_block.Value;
}
Vector3 result = Vector3.PositiveInfinity;
if (block.CubeGrid == CubeGrid && direction_local.HasValue)
{
MatrixD Transform = Matrix.Invert(block.LocalMatrix).GetOrientation();
result = Vector3.Transform(direction_local.Value, Transform);
}
else
{
MatrixD Transform = block.WorldMatrixNormalizedInv.GetOrientation();
result = Vector3.Transform(ToWorld(), Transform);
}
if (CubeBlock == null)
{
CubeBlock = block;
direction_block = result;
}
return result;
}
示例2: ShipController
public ShipController(IMyCubeBlock block)
: base(block)
{
myLogger = new Logger("ShipController", () => CubeBlock.CubeGrid.DisplayName);
myController = CubeBlock as Ingame.IMyShipController;
Registrar.Add(CubeBlock, this);
}
示例3: LastSeenTarget
public LastSeenTarget(LastSeen seen, IMyCubeBlock block = null)
{
m_lastSeen = seen;
m_block = block;
m_lastPostion = m_lastSeen.LastKnownPosition;
m_lastPositionUpdate = m_lastSeen.LastSeenAt;
}
示例4: MotorTurret
public MotorTurret(IMyCubeBlock block, StatorChangeHandler handler)
{
this.FaceBlock = block;
this.myLogger = new Logger("MotorTurret", block);
this.OnStatorChange = handler;
this.SetupStators();
}
示例5: LaserAntenna
public LaserAntenna(IMyCubeBlock block)
: base(block)
{
myLaserAntenna = CubeBlock as Ingame.IMyLaserAntenna;
myLogger = new Logger("LaserAntenna", () => CubeBlock.CubeGrid.DisplayName);
Registrar.Add(block, this);
}
示例6: ShipAutopilot
/// <summary>
/// Creates an Autopilot for the given ship controller.
/// </summary>
/// <param name="block">The ship controller to use</param>
public ShipAutopilot(IMyCubeBlock block)
{
this.m_block = new ShipControllerBlock(block);
this.m_logger = new Logger(GetType().Name, block);
this.m_interpreter = new Interpreter(m_block);
this.m_block.CubeBlock.OnClosing += CubeBlock_OnClosing;
((MyCubeBlock)block).ResourceSink.SetRequiredInputFuncByType(new MyDefinitionId(typeof(MyObjectBuilder_GasProperties), "Electricity"), PowerRequired);
if (Saver.Instance.LoadOldVersion(69))
{
int start = block.DisplayNameText.IndexOf('[') + 1, end = block.DisplayNameText.IndexOf(']');
if (start > 0 && end > start)
{
m_block.AutopilotTerminal.AutopilotCommands = new StringBuilder(block.DisplayNameText.Substring(start, end - start).Trim());
int lengthBefore = start - 1;
string nameBefore = lengthBefore > 0 ? m_block.Terminal.DisplayNameText.Substring(0, lengthBefore) : string.Empty;
end++;
int lengthAfter = m_block.Terminal.DisplayNameText.Length - end;
string nameAfter = lengthAfter > 0 ? m_block.Terminal.DisplayNameText.Substring(end, lengthAfter) : string.Empty;
m_block.Terminal.SetCustomName((nameBefore + nameAfter).Trim());
}
}
m_logger.debugLog("Created autopilot for: " + block.DisplayNameText);
Registrar.Add(block, this);
}
示例7: IsHacker
public static bool IsHacker(IMyCubeBlock block)
{
if (!(block is IMyLandingGear))
return false;
string descr = block.GetCubeBlockDefinition().DescriptionString;
return descr != null && descr.ToLower().Contains("hacker");
}
示例8: ManualMessage
public ManualMessage(IMyCubeBlock block)
{
m_logger = new Logger(GetType().Name, block);
m_block = block;
Registrar.Add(block, this);
}
示例9: Logger
/// <summary>
/// Creates a Logger that gets the context and states from block and supplied function.
/// </summary>
/// <param name="calling_class">the name of the class this Logger belongs to</param>
/// <param name="block">The block to get context and states from</param>
/// <param name="default_secondary">the secondary state used when one is not supplied to alwaysLog() or debugLog()</param>
public Logger(string calling_class, IMyCubeBlock block, Func<string> default_secondary = null)
{
this.m_classname = calling_class;
if (block == null)
{
f_context = () => "Null block";
return;
}
this.f_context = () => {
IMyCubeGrid grid = block.CubeGrid;
if (grid == null)
return "Null grid";
return grid.DisplayName + " - " + grid.EntityId;
};
if (default_secondary == null)
{
this.f_state_primary = () => block.DefinitionDisplayNameText;
this.f_state_secondary = () => block.getNameOnly() + " - " + block.EntityId;
}
else
{
this.f_state_primary = () => block.getNameOnly() + " - " + block.EntityId;
this.f_state_secondary = default_secondary;
}
}
示例10: Stator
public Stator(IMyCubeBlock block)
: base(block, AttachedGrid.AttachmentKind.Motor)
{
this.myLogger = new Logger("Stator", block);
this.myStator = block as IMyMotorStator;
Registrar.Add(this.myStator, this);
}
示例11: GuidedMissile
/// <summary>
/// Creates a missile with homing and target finding capabilities.
/// </summary>
public GuidedMissile(IMyEntity missile, IMyCubeBlock firedBy, TargetingOptions opt, Ammo ammo, LastSeen initialTarget = null, bool isSlave = false)
: base(missile, firedBy)
{
myLogger = new Logger("GuidedMissile", () => missile.getBestName(), () => m_stage.ToString());
myAmmo = ammo;
myDescr = ammo.Description;
if (ammo.Description.HasAntenna)
myAntenna = new MissileAntenna(missile);
TryHard = true;
AllGuidedMissiles.Add(this);
missile.OnClose += missile_OnClose;
if (myAmmo.IsCluster && !isSlave)
myCluster = new Cluster(myAmmo.MagazineDefinition.Capacity - 1);
accelerationPerUpdate = (myDescr.Acceleration + myAmmo.MissileDefinition.MissileAcceleration) / 60f;
addSpeedPerUpdate = myDescr.Acceleration / 60f;
Options = opt;
Options.TargetingRange = ammo.Description.TargetRange;
myTargetSeen = initialTarget;
myLogger.debugLog("Options: " + Options, "GuidedMissile()");
//myLogger.debugLog("AmmoDescription: \n" + MyAPIGateway.Utilities.SerializeToXML<Ammo.AmmoDescription>(myDescr), "GuidedMissile()");
}
示例12: ProgrammableBlock
public ProgrammableBlock(IMyCubeBlock block)
: base(block)
{
myLogger = new Logger("Programmable block", () => CubeBlock.CubeGrid.DisplayName);
myProgBlock = CubeBlock as Ingame.IMyProgrammableBlock;
Registrar.Add(CubeBlock, this);
}
示例13: BlockInstructions
protected BlockInstructions(IMyTerminalBlock block)
{
m_logger = new Logger("BlockInstructions", block as IMyCubeBlock);
m_block = block as IMyCubeBlock;
block.CustomNameChanged += BlockChange;
}
示例14: FromBlock
public static RelativeDirection3F FromBlock(IMyCubeBlock block, Vector3 blockDirection)
{
RelativeDirection3F result = new RelativeDirection3F(block.CubeGrid);
result.direction_block = blockDirection;
result.CubeBlock = block;
return result;
}
示例15: Solar
/// <param name="block">Must be an IMyTerminalBlock</param>
public Solar(IMyCubeBlock block)
{
myBlock = block;
myLogger = new Logger("Solar", block);
(myBlock as IMyTerminalBlock).CustomNameChanged += Solar_CustomNameChanged;
myBlock.OnClose += myBlock_OnClose;
}