本文整理汇总了C#中IMyCubeBlock.getBestName方法的典型用法代码示例。如果您正苦于以下问题:C# IMyCubeBlock.getBestName方法的具体用法?C# IMyCubeBlock.getBestName怎么用?C# IMyCubeBlock.getBestName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyCubeBlock
的用法示例。
在下文中一共展示了IMyCubeBlock.getBestName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLoadedAmmo
public static Ammo GetLoadedAmmo(IMyCubeBlock weapon)
{
var invOwn = (weapon as IMyInventoryOwner);
if (invOwn == null)
throw new InvalidOperationException("not an IMyInventoryOwner: " + weapon.getBestName());
var inv = invOwn.GetInventory(0).GetItems();
if (inv.Count == 0)
return null;
Ammo value;
MyDefinitionId magazineId = inv[0].Content.GetId();
if (KnownDefinitions_Ammo.TryGetValue(magazineId, out value))
return value;
MyAmmoMagazineDefinition magDef = MyDefinitionManager.Static.GetAmmoMagazineDefinition(magazineId);
if (magDef == null)
throw new InvalidOperationException("inventory contains item that is not a magazine: " + weapon.getBestName());
value = new Ammo(magDef);
KnownDefinitions_Ammo.Add(magazineId, value);
return value;
}
示例2: TargetingBase
public TargetingBase(IMyEntity entity, IMyCubeBlock controllingBlock)
{
if (entity == null)
throw new ArgumentNullException("entity");
if (controllingBlock == null)
throw new ArgumentNullException("controllingBlock");
myLogger = new Logger("TargetingBase", () => entity.getBestName());
MyEntity = entity;
CubeBlock = controllingBlock;
FuncBlock = controllingBlock as IMyFunctionalBlock;
myTarget = new NoTarget();
CurrentTarget = myTarget;
Options = new TargetingOptions();
entity.OnClose += obj => {
if (WeaponsTargetingProjectile != null)
CurrentTarget = null;
};
myLogger.debugLog("entity: " + MyEntity.getBestName() + ", block: " + CubeBlock.getBestName(), "TargetingBase()");
}
示例3: GetLoadedAmmo
public static Ammo GetLoadedAmmo(IMyCubeBlock weapon)
{
MyEntity entity = (MyEntity)weapon;
if (!entity.HasInventory)
throw new InvalidOperationException("Has no inventory: " + weapon.getBestName());
MyInventoryBase inv = entity.GetInventoryBase(0);
if (inv.GetItemsCount() == 0)
return null;
MyDefinitionId magazineId;
try { magazineId = inv.GetItems()[0].Content.GetId(); }
catch (IndexOutOfRangeException)
{ return null; }
return GetAmmo(magazineId);
}