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


C# MyDefinitionId类代码示例

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


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


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