• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MyDefinitionId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MyDefinitionId的典型用法代码示例。如果您正苦于以下问题:C# MyDefinitionId类的具体用法?C# MyDefinitionId怎么用?C# MyDefinitionId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MyDefinitionId类属于命名空间,在下文中一共展示了MyDefinitionId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IsAllowed

        public bool IsAllowed(MyDefinitionId itemId)
        {
			if (!Enabled || !IsFunctional || !IsWorking || !ResourceSink.IsPowered)
                return false;

            return m_inventoryConstraint.Check(itemId);
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:7,代码来源:MyConveyorSorter.cs


示例2: LoadDefinition

        public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, bool merge = true)
        {
            InitBlockInfo(blockInfo, definition);

            if (definition.MultiBlock != null)
            {
                MyDefinitionId defId = new MyDefinitionId(typeof(MyObjectBuilder_MultiBlockDefinition), definition.MultiBlock);
                MyMultiBlockDefinition multiBlockDef = MyDefinitionManager.Static.GetMultiBlockDefinition(defId);
                if (multiBlockDef != null)
                {
                    foreach (var blockPart in multiBlockDef.BlockDefinitions)
                    {
                        MyCubeBlockDefinition cubeBlockDef = null;
                        MyDefinitionManager.Static.TryGetDefinition(blockPart.Id, out cubeBlockDef);
                        if (cubeBlockDef != null)
                        {
                            AddComponentsForBlock(blockInfo, cubeBlockDef);
                        }
                    }
                }
            }
            else
            {
                AddComponentsForBlock(blockInfo, definition);
            }

            if (merge) MergeSameComponents(blockInfo, definition);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:28,代码来源:MyHudBlockInfoExtensions.cs


示例3: Postprocess

        public void Postprocess()
        {
            List<MySpawnGroupDefinition> spawnGroups = new List<MySpawnGroupDefinition>();
            List<float> frequencies = new List<float>();

            foreach (var spawnGroupId in m_spawnGroups)
            {
                MySpawnGroupDefinition spawnGroupDef = null;
                var defId = new MyDefinitionId(typeof(MyObjectBuilder_SpawnGroupDefinition), spawnGroupId);
                MyDefinitionManager.Static.TryGetDefinition(defId, out spawnGroupDef);

                Debug.Assert(spawnGroupDef != null, "Could not find spawn group for pirate antenna " + Name);
                if (spawnGroupDef != null)
                {
                    spawnGroups.Add(spawnGroupDef);
                    frequencies.Add(spawnGroupDef.Frequency);
                }
            }

            m_spawnGroups = null;

            if (frequencies.Count != 0)
            {
                SpawnGroupSampler = new MyDiscreteSampler<MySpawnGroupDefinition>(spawnGroups, frequencies);
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:26,代码来源:MyPirateAntennaDefinition.cs


示例4: DoDamage

        public override void DoDamage(float damage, int itemInstanceId, Vector3D position, Vector3 normal, MyStringHash type)
        {
            MyEnvironmentItemData itemData = m_itemsData[itemInstanceId];
            MyDefinitionId id = new MyDefinitionId(Definition.ItemDefinitionType, itemData.SubtypeId);
            var itemDefinition = (MyTreeDefinition)MyDefinitionManager.Static.GetEnvironmentItemDefinition(id);


            int effectId;
            if (itemDefinition.CutEffect != null && MyParticlesLibrary.GetParticleEffectsID(itemDefinition.CutEffect, out effectId))
            {
                MyParticleEffect effect;
                if (MyParticlesManager.TryCreateParticleEffect(effectId, out effect))
                {
                    effect.WorldMatrix = MatrixD.CreateWorld(position, Vector3.CalculatePerpendicularVector(normal), normal);
                }
            }

            if (!Sync.IsServer)
            {
                return;
            }

            MyCutTreeInfo cutTreeInfo = default(MyCutTreeInfo);
            int index = -1;
            for (int i = 0; i < m_cutTreeInfos.Count; ++i)
            {
                cutTreeInfo = m_cutTreeInfos[i];
                if (itemInstanceId == cutTreeInfo.ItemInstanceId)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)            
            {
                cutTreeInfo = new MyCutTreeInfo();
                cutTreeInfo.ItemInstanceId = itemInstanceId;

                cutTreeInfo.MaxPoints = cutTreeInfo.HitPoints = itemDefinition.HitPoints;

                index = m_cutTreeInfos.Count;
                m_cutTreeInfos.Add(cutTreeInfo);
            }

            cutTreeInfo.LastHit = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            cutTreeInfo.HitPoints -= damage;

            if (cutTreeInfo.Progress >= 1)
            {
                CutTree(itemInstanceId, position, normal, type == MyDamageType.Drill ? 1.0f : 4.0f);
                m_cutTreeInfos.RemoveAtFast(index);
            }
            else
            {
                m_cutTreeInfos[index] = cutTreeInfo;
            }

            return;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:60,代码来源:MyTrees.cs


示例5: AddItem

        public void AddItem(MyDefinitionId groupId, int itemValue, int amount)
        {
            List<int> items = null;

            var group = MyDefinitionManager.Static.GetComponentGroup(groupId);
            if (group == null)
            {
                Debug.Assert(false, "Could not find component group definition for group " + groupId);
                return;
            }

            if (!m_groups.TryGetValue(groupId, out items))
            {
                items = m_listAllocator.Allocate();
                items.Clear();

                // We'll have the zero item allocated (for convenience), but it won't be used
                for (int i = 0; i <= group.GetComponentNumber(); ++i)
                {
                    items.Add(0);
                }
                m_groups.Add(groupId, items);
            }

            items[itemValue] += amount;
            m_totalItemCounter += amount;
        }
开发者ID:avivbeeri,项目名称:SpaceEngineers,代码行数:27,代码来源:MyCuttingSolver.cs


示例6: ProcessItems

        public override unsafe void ProcessItems(Dictionary<short, MyLodEnvironmentItemSet> items, List<MySurfaceParams> surfaceParamsPerLod, int[] surfaceParamLodOffsets, int changedLodMin, int changedLodMax)
        {
            m_minScannedLod = changedLodMin;

            using (var batch = new MyEnvironmentModelUpdateBatch(Sector))
                foreach (var group in items)
                {
                    MyRuntimeEnvironmentItemInfo it;
                    Sector.GetItemDefinition((ushort)group.Key, out it);
                    MyDefinitionId modelCollection = new MyDefinitionId(typeof(MyObjectBuilder_PhysicalModelCollectionDefinition), it.Subtype);

                    MyPhysicalModelCollectionDefinition modelCollectionDef = MyDefinitionManager.Static.GetDefinition<MyPhysicalModelCollectionDefinition>(modelCollection);
                    if (modelCollectionDef != null)
                    {
                        var info = group.Value;
                        int offt = info.LodOffsets[changedLodMin];

                        for (int i = offt; i < info.Items.Count; ++i)
                        {
                            var position = info.Items[i];

                            if (m_disabledItems.Contains(position) || IsObstructed(position)) continue;
                            var modelDef = modelCollectionDef.Items.Sample(MyHashRandomUtils.UniformFloatFromSeed(position));

                            batch.Add(modelDef, position);
                        }
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:29,代码来源:MyStaticEnvironmentModule.cs


示例7: Init

        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            if (objectBuilder.SubtypeName != null && objectBuilder.SubtypeName.Length > 0)
                m_physicalItemId = new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), objectBuilder.SubtypeName + "Item");
            PhysicalObject = (MyObjectBuilder_PhysicalGunObject)MyObjectBuilderSerializer.CreateNewObject(m_physicalItemId);
            base.Init(objectBuilder, m_physicalItemId);

            var definition = MyDefinitionManager.Static.GetPhysicalItemDefinition(m_physicalItemId);
            Init(null, definition.Model, null, null, null);
            Render.CastShadows = true;
            Render.NeedsResolveCastShadow = false;

            PhysicalObject.GunEntity = (MyObjectBuilder_EntityBase)objectBuilder.Clone();
            PhysicalObject.GunEntity.EntityId = this.EntityId;

            foreach (ToolSound toolSound in m_handItemDef.ToolSounds)
            {
                if (toolSound.type == null || toolSound.subtype == null || toolSound.sound == null)
                    continue;
                if (toolSound.type.Equals("Main"))
                {
                    if(toolSound.subtype.Equals("Idle"))
                        weldSoundIdle = new MySoundPair(toolSound.sound);
                    if (toolSound.subtype.Equals("Weld"))
                        weldSoundWeld = new MySoundPair(toolSound.sound);
                }
            }
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:28,代码来源:MyWelder.cs


示例8: Shoot

        public override void Shoot(MyShootActionEnum action, Vector3 direction, string gunAction)
        {
            if (MySession.Static.CreativeMode)
                return;

            base.Shoot(action, direction, gunAction);

            if (action == MyShootActionEnum.PrimaryAction && !m_firstShot)
            {
                if ((MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastKeyPress) >= 500)
                {
                    //MyRenderProxy.DebugDrawText2D(new Vector2(50.0f, 50.0f), "Holding cube placer", Color.Red, 1.0f);
                    // CH:TODO: This should probably be done only locally
                    var block = GetTargetBlock();
                    if (block != null)
                    {
                        MyDefinitionId welderDefinition = new MyDefinitionId(typeof(MyObjectBuilder_Welder));
                        if (Owner.CanSwitchToWeapon(welderDefinition))
                        {
                            Owner.SetupAutoswitch(new MyDefinitionId(typeof(MyObjectBuilder_Welder)), new MyDefinitionId(typeof(MyObjectBuilder_CubePlacer)));
                        }
                    }
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:25,代码来源:MyCubePlacer.cs


示例9: Remove

        public MyInventoryConstraint Remove(MyDefinitionId id)
        {

            m_constrainedIds.Remove(id);
            UpdateIcon();
            return this;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyInventoryConstraint.cs


示例10: Init

			public void Init(MyDefinitionId typeId, IMyConveyorEndpointBlock block)
			{
				FirstEndpoint = block.ConveyorEndpoint;
				ClearData();

				Add(typeId, block);
			}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:7,代码来源:MyResourceDistributorComponent.cs


示例11: GetItemAmountCombined

        public MyFixedPoint GetItemAmountCombined(MyInventoryBase inventory, MyDefinitionId contentId)
        {
            int amount = 0;
            var group = MyDefinitionManager.Static.GetGroupForComponent(contentId, out amount);
            if (group == null)
            {
                //MyComponentSubstitutionDefinition substitutions;
                //if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(contentId, out substitutions))
                //{
                //    foreach (var providingComponent in substitutions.ProvidingComponents)
                //    {
                //        amount += (int)inventory.GetItemAmount(providingComponent.Key) / providingComponent.Value;
                //    }
                //}

                return amount + inventory.GetItemAmount(contentId, substitute: true);
            }
            else
            {
                Clear();
                inventory.CountItems(m_componentCounts);
                AddItem(group.Id, amount, int.MaxValue);
                Solve(m_componentCounts);
                return GetSolvedItemCount();
            }
        }
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:26,代码来源:MyComponentCombiner.cs


示例12: Activate

        public override bool Activate()
        {
            var character = MySession.Static.LocalCharacter;

            MyDefinitionId weaponDefinition = new MyDefinitionId(typeof(MyObjectBuilder_CubePlacer));
            if (character != null)
            {
                if (!(character.CurrentWeapon != null && character.CurrentWeapon.DefinitionId == weaponDefinition))
                {
                    character.SwitchToWeapon(weaponDefinition);
                }

                MyCubeBuilder.Static.ActivateBlockCreation(((MyCubeBlockDefinition)Definition).Id);
            }
            else
            { }

            if (MyCubeBuilder.SpectatorIsBuilding)
            {
                MyCubeBuilder.Static.ActivateBlockCreation(((MyCubeBlockDefinition)Definition).Id);
                if (!MyCubeBuilder.Static.IsActivated)
                {
                    MyCubeBuilder.Static.Activate();
                }
            }
            return true;
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:27,代码来源:MyToolbarItemCubeBlock.cs


示例13: AddToDictionary

 private void AddToDictionary(Dictionary<MyDefinitionId, int> dict, MyDefinitionId myDefinitionId, int amount)
 {
     int presentAmount = 0;
     dict.TryGetValue(myDefinitionId, out presentAmount);
     presentAmount += amount;
     dict[myDefinitionId] = presentAmount;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyComponentList.cs


示例14: GetMainElement

        public MyDefinitionId GetMainElement(MyDefinitionId id)
        {
            MyDefinitionId result;
            if (m_groupMain.TryGetValue(id, out result))
                return result;

            return id;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:MySessionComponentEquivalency.cs


示例15: GetBaseBlock

        public MyDefinitionId GetBaseBlock(MyDefinitionId id)
        {
            MyDefinitionId definitionId;
            if (m_blockVariationToBaseBlock.TryGetValue(id, out definitionId))
                return definitionId;

            return id;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:MyGridPickupComponent.cs


示例16: CubeBlockType

 public CubeBlockType(MyDefinitionId definitionId)
     : base(definitionId)
 {
     if (!(Definition is MyCubeBlockDefinition))
         throw new InvalidOperationException(
             "Passed type/subtype is not a CubeBlock."
         );
 }
开发者ID:zrisher,项目名称:SEGarden,代码行数:8,代码来源:CubeBlockType.cs


示例17: RemoveItemsCombined

 protected internal void RemoveItemsCombined(MyInventoryBase inventory, int itemAmount, MyDefinitionId itemDefinitionId)
 {
     m_materialListCombined.Clear();
     m_materialListCombined.AddMaterial(itemDefinitionId, itemAmount);
     m_componentCombiner.RemoveItemsCombined(inventory, m_materialListCombined.TotalMaterials);
     m_materialListCombined.Clear();
     return;
 }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:8,代码来源:MyBuildComponentBase.cs


示例18: PhysicalItemType

 public PhysicalItemType(MyDefinitionId definitionId)
     : base(definitionId)
 {
     if (!(Definition is MyPhysicalItemDefinition))
         throw new InvalidOperationException(
             "Passed type/subtype is not a PhysicalItem."
         );
 }
开发者ID:zrisher,项目名称:SEGarden,代码行数:8,代码来源:PhysicalItemType.cs


示例19: Init

		public virtual void Init(MyObjectBuilder_Character characterBuilder)
		{
			if (characterBuilder == null)
				return;

			m_inertiaDampenersNotification = new MyHudNotification();
			m_jetpackToggleNotification = new MyHudNotification();

			CurrentAutoEnableDelay = characterBuilder.AutoenableJetpackDelay;

			if (ThrustComp != null)
				Character.Components.Remove<MyJetpackThrustComponent>();

		    var thrustProperties = Character.Definition.Jetpack.ThrustProperties;

		    FuelConverterDefinition = null;;
		    FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo { Efficiency = 1.0f } : Character.Definition.Jetpack.ThrustProperties.FuelConverter;

		    MyDefinitionId fuelId = new MyDefinitionId();
		    if (!FuelConverterDefinition.FuelId.IsNull())
		        fuelId = thrustProperties.FuelConverter.FuelId;

		    MyGasProperties fuelDef = null;
            if (MyFakes.ENABLE_HYDROGEN_FUEL)
                MyDefinitionManager.Static.TryGetDefinition(fuelId, out fuelDef);

            FuelDefinition = fuelDef ?? new MyGasProperties // Use electricity by default
            {
                Id = MyResourceDistributorComponent.ElectricityId,
                EnergyDensity = 1f,
            };

            ForceMagnitude = thrustProperties.ForceMagnitude;
			MinPowerConsumption = thrustProperties.MinPowerConsumption;
			MaxPowerConsumption = thrustProperties.MaxPowerConsumption;
		    MinPlanetaryInfluence = thrustProperties.MinPlanetaryInfluence;
		    MaxPlanetaryInfluence = thrustProperties.MaxPlanetaryInfluence;
		    EffectivenessAtMinInfluence = thrustProperties.EffectivenessAtMinInfluence;
		    EffectivenessAtMaxInfluence = thrustProperties.EffectivenessAtMaxInfluence;
		    NeedsAtmosphereForInfluence = thrustProperties.NeedsAtmosphereForInfluence;
		    ConsumptionFactorPerG = thrustProperties.ConsumptionFactorPerG;

			MyEntityThrustComponent thrustComp = new MyJetpackThrustComponent();
			thrustComp.Init();
			Character.Components.Add(thrustComp);


			ThrustComp.DampenersEnabled = characterBuilder.DampenersEnabled;

			foreach (Vector3I direction in Base6Directions.IntDirections)
			{
				ThrustComp.Register(Character, direction);	// Preferably there should be a jetpack entity (equipment) that could hold the thrusts instead of the character
			}
		    thrustComp.ResourceSink(Character).TemporaryConnectedEntity = Character;
            Character.SuitRechargeDistributor.AddSink(thrustComp.ResourceSink(Character));
			TurnOnJetpack(characterBuilder.JetpackEnabled, true, true, true);
		}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:57,代码来源:MyCharacterJetpackComponent.cs


示例20: Init

        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_WeaponBlockDefinition;

            WeaponDefinitionId = new MyDefinitionId(ob.WeaponDefinitionId.Type, ob.WeaponDefinitionId.Subtype);
            InventoryMaxVolume = ob.InventoryMaxVolume;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:9,代码来源:MyWeaponBlockDefinition.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MyDelegate类代码示例发布时间:2022-05-24
下一篇:
C# MyCueId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap