当前位置: 首页>>代码示例>>C#>>正文


C# IMyCubeBlock.getBestName方法代码示例

本文整理汇总了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;
		}
开发者ID:Sutima,项目名称:Autopilot,代码行数:22,代码来源:Ammo.cs

示例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()");
		}
开发者ID:helppass,项目名称:Autopilot,代码行数:22,代码来源:TargetingBase.cs

示例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);
        }
开发者ID:Souper07,项目名称:Autopilot,代码行数:17,代码来源:Ammo.cs


注:本文中的IMyCubeBlock.getBestName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。