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


C# MyStringHash类代码示例

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


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

示例1: Init

		public void Init(MyStringHash sourceGroup, List<MyResourceSourceInfo> sourceResourceData)
		{
			Group = sourceGroup;

			var resourceData = sourceResourceData;
			bool hasResourceData = resourceData != null && resourceData.Count != 0;
			int resourceCount = hasResourceData ? resourceData.Count : 1;
		    Enabled = true;

			if(resourceCount != m_allocatedTypeCount)
				AllocateData(resourceCount);

			int resourceIndexCounter = 0;
			if (!hasResourceData)
			{
				m_resourceTypeToIndex.Add(MyResourceDistributorComponent.ElectricityId, resourceIndexCounter++);
				m_resourceIds.Add(MyResourceDistributorComponent.ElectricityId);
			} 
			else
			{
				foreach (var resourceInfo in resourceData)
				{
					m_resourceTypeToIndex.Add(resourceInfo.ResourceTypeId, resourceIndexCounter++);
					m_resourceIds.Add(resourceInfo.ResourceTypeId);
				    m_dataPerType[resourceIndexCounter - 1].DefinedOutput = resourceInfo.DefinedOutput;
					SetOutputByType(resourceInfo.ResourceTypeId, 0f);
					SetMaxOutputByType(resourceInfo.ResourceTypeId, m_dataPerType[GetTypeIndex(resourceInfo.ResourceTypeId)].DefinedOutput);
                    SetProductionEnabledByType(resourceInfo.ResourceTypeId, true);
				    m_dataPerType[resourceIndexCounter - 1].ProductionToCapacityMultiplier = (resourceInfo.ProductionToCapacityMultiplier != 0f ? resourceInfo.ProductionToCapacityMultiplier : 1f);

					if(resourceInfo.IsInfiniteCapacity)
						SetRemainingCapacityByType(resourceInfo.ResourceTypeId, float.PositiveInfinity);
				}
			}
		}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:35,代码来源:MyResourceSourceComponent.cs

示例2: Init

        public virtual void Init(MyObjectBuilder_Base objectBuilder)
        {
            var builder = (MyObjectBuilder_EntityStat) objectBuilder;

            MyEntityStatDefinition definition;
            MyDefinitionManager.Static.TryGetDefinition<MyEntityStatDefinition>(new MyDefinitionId(builder.TypeId, builder.SubtypeId), out definition);

            Debug.Assert(definition != null);
            StatDefinition = definition;

            System.Diagnostics.Debug.Assert(!float.IsNaN(definition.MaxValue) && !float.IsNaN(definition.MinValue) && !float.IsNaN(definition.DefaultValue), "Invalid values in stat definition!");

            m_maxValue = definition.MaxValue;
            m_minValue = definition.MinValue;
            m_currentValue = builder.Value * m_maxValue;
            m_defaultValue = definition.DefaultValue;
            
            m_lastSyncValue = m_currentValue;
            m_statId = MyStringHash.GetOrCompute(definition.Name);

            m_regenAmountMultiplier = builder.StatRegenAmountMultiplier;
            m_regenAmountMultiplierDuration = builder.StatRegenAmountMultiplierDuration;
            m_regenAmountMultiplierTimeStart = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            m_regenAmountMultiplierTimeAlive = 0;
            m_regenAmountMultiplierActive = m_regenAmountMultiplierDuration > 0;

            ClearEffects();
            if (builder.Effects != null)
            {
                foreach (var effectBuilder in builder.Effects)
                {
                    AddEffect(effectBuilder);
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:35,代码来源:MyEntityStat.cs

示例3: HandleAddDecal

        /// <param name="damage">Not used for now but could be used as a multiplier instead of random decal size</param>
        public static void HandleAddDecal(IMyEntity entity, MyHitInfo hitInfo, MyStringHash source = default(MyStringHash), object customdata = null, float damage = -1)
        {
            IMyDecalProxy proxy = entity as IMyDecalProxy;
            if (proxy != null)
            {
                AddDecal(proxy, ref hitInfo, damage, source, customdata);
                return;
            }

            MyCubeGrid grid = entity as MyCubeGrid;
            if (grid != null)
            {
                var block = grid.GetTargetedBlock(hitInfo.Position);
                if (block != null)
                {
                    var compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                    if (compoundBlock == null)
                        proxy = block;
                    else
                        proxy = compoundBlock;
                }
            }

            if (proxy == null)
                return;

            AddDecal(proxy, ref hitInfo, damage, source, customdata);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:29,代码来源:MyDecals.cs

示例4: HandleAddDecal

        /// <param name="damage">Not used for now but could be used as a multiplier instead of random decal size</param>
        public static void HandleAddDecal(IMyEntity entity, MyHitInfo hitInfo, MyStringHash source = default(MyStringHash), float damage = -1)
        {
            if (entity == null)
                DebugNullEntity();

            IMyDecalProxy proxy = entity as IMyDecalProxy;
            if (proxy != null)
            {
                AddDecal(proxy, ref hitInfo, damage, source);
                return;
            }

            MyCubeGrid grid = entity.GetTopMostParent() as MyCubeGrid;
            if (grid != null)
            {
                var block = grid.GetTargetedBlock(hitInfo.Position);
                if (block != null)
                {
                    var compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                    if (compoundBlock == null)
                        proxy = block;
                    else
                        proxy = compoundBlock;
                }
            }

            if (proxy != null)
                AddDecal(proxy, ref hitInfo, damage, source);
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:30,代码来源:MyDecals.cs

示例5: Init

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

            var ob = builder as MyObjectBuilder_PhysicalItemDefinition;
            MyDebug.AssertDebug(ob != null);
            this.Size = ob.Size;
            this.Mass = ob.Mass;
            this.Model = ob.Model;
            this.Models = ob.Models;
            this.Volume = ob.Volume.HasValue? ob.Volume.Value / 1000f : ob.Size.Volume;
            if (string.IsNullOrEmpty(ob.IconSymbol))
                this.IconSymbol = null;
            else
                this.IconSymbol = MyStringId.GetOrCompute(ob.IconSymbol);
            PhysicalMaterial = MyStringHash.GetOrCompute(ob.PhysicalMaterial);
            VoxelMaterial = MyStringHash.GetOrCompute(ob.VoxelMaterial);
            CanSpawnFromScreen = ob.CanSpawnFromScreen;
            RotateOnSpawnX = ob.RotateOnSpawnX;
            RotateOnSpawnY = ob.RotateOnSpawnY;
            RotateOnSpawnZ = ob.RotateOnSpawnZ;
            Health = ob.Health;
            if (ob.DestroyedPieceId.HasValue)
            {
                DestroyedPieceId = ob.DestroyedPieceId.Value;
            }
            DestroyedPieces = ob.DestroyedPieces;
            if (ob.ExtraInventoryTooltipLine != null)
                ExtraInventoryTooltipLine = new StringBuilder().Append(Environment.NewLine).Append(ob.ExtraInventoryTooltipLine);
            else
                ExtraInventoryTooltipLine = new StringBuilder();
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:32,代码来源:MyPhysicalItemDefinition.cs

示例6: MyModelInstanceData

 public MyModelInstanceData(MyStringHash subtypeId, MyInstanceFlagsEnum flags, float maxViewDistance, BoundingBox modelBox)
 {
     SubtypeId = subtypeId;
     Flags = flags;
     MaxViewDistance = maxViewDistance;
     ModelBox = modelBox;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:7,代码来源:MyEnvironmentSector.cs

示例7: Init

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

            var thrustBuilder = builder as MyObjectBuilder_ThrustDefinition;
            MyDebug.AssertDebug(thrustBuilder != null, "Initializing thrust definition using wrong object builder.");

	        ResourceSinkGroup = MyStringHash.GetOrCompute(thrustBuilder.ResourceSinkGroup);
            FuelConverter = thrustBuilder.FuelConverter;
			SlowdownFactor = thrustBuilder.SlowdownFactor;
            ForceMagnitude = thrustBuilder.ForceMagnitude;
            MaxPowerConsumption = thrustBuilder.MaxPowerConsumption;
            MinPowerConsumption = thrustBuilder.MinPowerConsumption;
            FlameDamageLengthScale = thrustBuilder.FlameDamageLengthScale;
            FlameDamage = thrustBuilder.FlameDamage;
            FlameLengthScale = thrustBuilder.FlameLengthScale;
            FlameFullColor = thrustBuilder.FlameFullColor;
            FlameIdleColor = thrustBuilder.FlameIdleColor;
            FlamePointMaterial = thrustBuilder.FlamePointMaterial;
            FlameLengthMaterial = thrustBuilder.FlameLengthMaterial;
            FlameGlareMaterial = thrustBuilder.FlameGlareMaterial;
            FlameVisibilityDistance = thrustBuilder.FlameVisibilityDistance;
            FlameGlareSize = thrustBuilder.FlameGlareSize;
            FlameGlareQuerySize = thrustBuilder.FlameGlareQuerySize;

            EffectivenessAtMinInfluence = thrustBuilder.EffectivenessAtMinInfluence;
            EffectivenessAtMaxInfluence = thrustBuilder.EffectivenessAtMaxInfluence;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:28,代码来源:MyThrustDefinition.cs

示例8: Init

        public virtual void Init(MyObjectBuilder_Base objectBuilder)
        {
            var builder = (MyObjectBuilder_EntityStat) objectBuilder;

            MyEntityStatDefinition definition;
            MyDefinitionManager.Static.TryGetDefinition<MyEntityStatDefinition>(new MyDefinitionId(builder.TypeId, builder.SubtypeId), out definition);

            Debug.Assert(definition != null);
            StatDefinition = definition;

            m_maxValue = builder.MaxValue * 100.0f;
            m_minValue = 0.0f;
            m_currentValue = builder.Value * m_maxValue;
            
            m_lastSyncValue = m_currentValue;
            m_statId = MyStringHash.GetOrCompute(definition.Name);

            if (builder.Effects != null)
            {
                foreach (var effectBuilder in builder.Effects)
                {
                    AddEffect(effectBuilder);
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:25,代码来源:MyEntityStat.cs

示例9: 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

示例10: MyRepairBlueprintToProduce

 public MyRepairBlueprintToProduce(MyFixedPoint amount, MyBlueprintDefinitionBase blueprint, uint inventoryItemId, MyObjectBuilderType inventoryItemType, MyStringHash inventoryItemSubtypeId) : base(amount, blueprint)
 {
     System.Diagnostics.Debug.Assert(Blueprint is MyRepairBlueprintDefinition, "MyRepairBlueprintToProduce class should be used together with blueprints type of MyRepairBlueprintDefinition only!");
     InventoryItemId = inventoryItemId;
     InventoryItemType = inventoryItemType;
     InventoryItemSubtypeId = inventoryItemSubtypeId;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyCraftingComponentBase.cs

示例11: MyDamageInformation

 public MyDamageInformation(bool isDeformation, float amount, MyStringHash type, long attackerId)
 {
     IsDeformation = isDeformation;
     Amount = amount;
     Type = type;
     AttackerId = attackerId;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyDamageInformation.cs

示例12: GetInventory

        public static MyInventoryBase GetInventory(this MyEntity entity, MyStringHash inventoryId)
        {
            MyInventoryBase inventory = null;

            inventory = entity.Components.Get<MyInventoryBase>();
            if (inventory != null)
            {
                if (inventoryId.Equals(MyStringHash.GetOrCompute(inventory.InventoryId.ToString())))
                {
                    return inventory;
                }
            }

            if (inventory is MyInventoryAggregate)
            {
                var aggregate = inventory as MyInventoryAggregate;
                m_tmpList.Clear();
                aggregate.GetComponentsFlattened(m_tmpList);
                foreach (var component in m_tmpList)
                {
                    var componentInventory = component as MyInventoryBase;
                    if (inventoryId.Equals(MyStringHash.GetOrCompute(componentInventory.InventoryId.ToString())))
                    {
                        return componentInventory;
                    }
                }
            }

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

示例13: Init

	    public void Init(MyStringHash sourceGroup, MyResourceSourceInfo sourceResourceData)
	    {
            MyUtils.Init(ref m_singleHelperList);
	        m_singleHelperList.Add(sourceResourceData);
            Init(sourceGroup, m_singleHelperList);
            m_singleHelperList.Clear();
	    }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:7,代码来源:MyResourceSourceComponent.cs

示例14: Init

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

            MyDebug.AssertDebug(builder is MyObjectBuilder_ProductionBlockDefinition);
            var obDefinition = builder as MyObjectBuilder_ProductionBlockDefinition;

            this.InventoryMaxVolume = obDefinition.InventoryMaxVolume;
            this.InventorySize = obDefinition.InventorySize;
	        ResourceSinkGroup = MyStringHash.GetOrCompute(obDefinition.ResourceSinkGroup);
            this.StandbyPowerConsumption = obDefinition.StandbyPowerConsumption;
            this.OperationalPowerConsumption = obDefinition.OperationalPowerConsumption;

            System.Diagnostics.Debug.Assert(obDefinition.BlueprintClasses != null, "Production block has no blueprint classes specified");
            if (obDefinition.BlueprintClasses == null)
                InitializeLegacyBlueprintClasses(obDefinition);

            BlueprintClasses = new List<MyBlueprintClassDefinition>();
            for (int i = 0; i < obDefinition.BlueprintClasses.Length; ++i)
            {
                var className = obDefinition.BlueprintClasses[i];
                var classDef = MyDefinitionManager.Static.GetBlueprintClass(className);
                System.Diagnostics.Debug.Assert(classDef != null, "Production block references non-existent blueprint class");
                if (classDef == null) continue;

                BlueprintClasses.Add(classDef);
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyProductionBlockDefinition.cs

示例15: Init

        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            var ob = builder as MyObjectBuilder_OreDetectorDefinition;
	        ResourceSinkGroup = MyStringHash.GetOrCompute(ob.ResourceSinkGroup);
            MaximumRange = ob.MaximumRange;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyOreDetectorDefinition.cs


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