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


C# VRage.MyFixedPoint类代码示例

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


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

示例1: MyInventoryItem

 public MyInventoryItem(MyFixedPoint amount, MyObjectBuilder_PhysicalObject content)
 {
     Debug.Assert(amount > 0, "Creating inventory item with zero amount!");
     ItemId = 0;
     Amount = amount;
     Content = content;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:7,代码来源:MyInventoryItem.cs

示例2: Spawn

        public static MyEntity Spawn(this MyPhysicalInventoryItem thisItem, MyFixedPoint amount, BoundingBoxD box, MyEntity owner = null)
        {
            if(amount < 0)
            {
                return null;
            }

            MatrixD spawnMatrix = MatrixD.Identity;
            spawnMatrix.Translation = box.Center;
            var entity = Spawn(thisItem, amount, spawnMatrix, owner);
            if (entity == null)
                return null;
            var size = entity.PositionComp.LocalVolume.Radius;
            var halfSize = box.Size / 2 - new Vector3(size);
            halfSize = Vector3.Max(halfSize, Vector3.Zero);
            box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
            var pos = MyUtils.GetRandomPosition(ref box);

            Vector3 forward = MyUtils.GetRandomVector3Normalized();
            Vector3 up = MyUtils.GetRandomVector3Normalized();
            while (forward == up)
                up = MyUtils.GetRandomVector3Normalized();

            Vector3 right = Vector3.Cross(forward, up);
            up = Vector3.Cross(right, forward);
            entity.WorldMatrix = MatrixD.CreateWorld(pos, forward, up);
            return entity;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyPhysicalInventoryItemExtensions.cs

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

示例4: Spawn

        public MyEntity Spawn(MyFixedPoint amount, MatrixD worldMatrix, MyEntity owner = null)
        {
            if (Content is MyObjectBuilder_BlockItem)
            {
                Debug.Assert(MyFixedPoint.IsIntegral(amount), "Spawning fractional number of grids!");

                var blockItem = Content as MyObjectBuilder_BlockItem;
                var builder = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_CubeGrid)) as MyObjectBuilder_CubeGrid;
                builder.GridSizeEnum = MyCubeSize.Small;
                builder.IsStatic = false;
                builder.PersistentFlags |= MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.Enabled;
                builder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);

                var block = MyObjectBuilderSerializer.CreateNewObject(blockItem.BlockDefId) as MyObjectBuilder_CubeBlock;
                builder.CubeBlocks.Add(block);

                MyCubeGrid firstGrid = null;
                for (int i = 0; i < amount; ++i)
                {
                    builder.EntityId = MyEntityIdentifier.AllocateId();
                    block.EntityId = MyEntityIdentifier.AllocateId();
                    MyCubeGrid newGrid = MyEntities.CreateFromObjectBuilder(builder) as MyCubeGrid;
                    firstGrid = firstGrid ?? newGrid;
                    MyEntities.Add(newGrid);
                    Sandbox.Game.Multiplayer.MySyncCreate.SendEntityCreated(builder);
                }
                return firstGrid;
            }
            else
                return MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(amount, Content),worldMatrix, owner != null ? owner.Physics : null);
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:31,代码来源:MyPhysicalInventoryItem.cs

示例5: Reload

        private static void Reload(IMyInventoryOwner gun, SerializableDefinitionId ammo, bool reactor = false)
        {
            var cGun = gun;
            Sandbox.ModAPI.IMyInventory inv = (Sandbox.ModAPI.IMyInventory)cGun.GetInventory(0);
            VRage.MyFixedPoint point = inv.GetItemAmount(ammo, MyItemFlags.None | MyItemFlags.Damaged);
            Util.GetInstance().Log(ammo.SubtypeName + " [ReloadGuns] Amount " + point.RawValue, "ItemManager.txt");
            if (point.RawValue > 1000000)
                return;
            //inv.Clear();
            VRage.MyFixedPoint amount = new VRage.MyFixedPoint();
            amount.RawValue = 2000000;

            MyObjectBuilder_InventoryItem ii;
            if (reactor)
            {
                ii = new MyObjectBuilder_InventoryItem()
                {
                    Amount = 10,
                    Content = new MyObjectBuilder_Ingot() { SubtypeName = ammo.SubtypeName }
                };
            }
            else
            {
                ii = new MyObjectBuilder_InventoryItem()
                {
                    Amount = 4,
                    Content = new MyObjectBuilder_AmmoMagazine() { SubtypeName = ammo.SubtypeName }
                };
            }
            inv.AddItems(amount, ii.PhysicalContent);

            point = inv.GetItemAmount(ammo, MyItemFlags.None | MyItemFlags.Damaged);
            Util.GetInstance().Log(ammo.SubtypeName + " [ReloadGuns] Amount " + point.RawValue, "ItemManager.txt");
        }
开发者ID:ESearcy,项目名称:PVE-AI-Drones-Drone-Conquest,代码行数:34,代码来源:ItemManager.cs

示例6: MyInventory

        public MyInventory(MyFixedPoint maxVolume, Vector3 size, MyInventoryFlags flags, IMyInventoryOwner owner)
        {
            m_maxVolume = MyPerGameSettings.ConstrainInventory() ? maxVolume * MySession.Static.InventoryMultiplier : MyFixedPoint.MaxValue;
            m_size = size;
            m_flags = flags;
            m_owner = owner;

            Clear();

            SyncObject = new MySyncInventory();
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:11,代码来源:MyInventory.cs

示例7: MyInventory

        public MyInventory(MyFixedPoint maxVolume, MyFixedPoint maxMass, Vector3 size, MyInventoryFlags flags, IMyInventoryOwner owner)
        {
            m_maxVolume = maxVolume;
            m_maxMass = maxMass;
            m_size = size;
            m_flags = flags;
            m_owner = owner;

            Clear();

            SyncObject = new MySyncInventory();

            //ContentsChanged += OnContentsChanged;
        }
开发者ID:avivbeeri,项目名称:SpaceEngineers,代码行数:14,代码来源:MyInventory.cs

示例8: TransferItems

        /// <summary>
        /// Transfers safely given item from one to another inventory, uses ItemsCanBeAdded and ItemsCanBeRemoved checks
        /// </summary>
        /// <returns>true if items were succesfully transfered, otherwise, false</returns>
        public static bool TransferItems(MyInventoryBase sourceInventory, MyInventoryBase destinationInventory, IMyInventoryItem item, MyFixedPoint amount)
        {
            if (sourceInventory == null)
            {
                System.Diagnostics.Debug.Fail("Source inventory is null!");
                return false;
            }
            if (destinationInventory == null)
            {
                System.Diagnostics.Debug.Fail("Destionation inventory is null!");
                return false;
            }
            if (item == null)
            {
                System.Diagnostics.Debug.Fail("Item is null!");
                return false;
            }
            if (amount == 0)
            {
                return true;
            }


            if (destinationInventory.ItemsCanBeAdded(amount, item) && sourceInventory.ItemsCanBeRemoved(amount, item))
            {
                if (Sync.IsServer)
                {
                    if (destinationInventory.Add(item, amount))
                    {
                        if (sourceInventory.Remove(item, amount))
                        {
                            // successfull transaction
                            return true;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Fail("Error! Items were added to inventory, but can't be removed!");
                        }
                    }
                }
                else
                {
                    MySyncInventory.SendTransferItemsMessage(sourceInventory, destinationInventory, item, amount);
                }
            }
            
            return false;
        }
开发者ID:avivbeeri,项目名称:SpaceEngineers,代码行数:52,代码来源:MyInventoryBase.cs

示例9: PostprocessAddSubblueprint

        private void PostprocessAddSubblueprint(MyBlueprintDefinitionBase blueprint, MyFixedPoint blueprintAmount)
        {
            for (int i = 0; i < blueprint.Prerequisites.Length; ++i)
            {
                Item prerequisite = blueprint.Prerequisites[i];
                prerequisite.Amount *= blueprintAmount;
                AddToItemList(m_tmpPrerequisiteList, prerequisite);
            }

            for (int i = 0; i < blueprint.Results.Length; ++i)
            {
                Item result = blueprint.Results[i];
                result.Amount *= blueprintAmount;
                AddToItemList(m_tmpResultList, result);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:16,代码来源:MyCompositeBlueprintDefinition.cs

示例10: Spawn

        public MyEntity Spawn(MyFixedPoint amount, BoundingBoxD box, MyEntity owner = null)
        {
            var entity = Spawn(amount, MatrixD.Identity, owner);
            var size = entity.PositionComp.LocalVolume.Radius;
            var halfSize = box.Size / 2 - new Vector3(size);
            halfSize = Vector3.Max(halfSize, Vector3.Zero);
            box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
            var pos = MyUtils.GetRandomPosition(ref box);

            Vector3 forward = MyUtils.GetRandomVector3Normalized();
            Vector3 up = MyUtils.GetRandomVector3Normalized();
            while (forward == up)
                up = MyUtils.GetRandomVector3Normalized();

            Vector3 right = Vector3.Cross(forward, up);
            up = Vector3.Cross(right, forward);
            entity.WorldMatrix = MatrixD.CreateWorld(pos, forward, up);
            return entity;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:19,代码来源:MyInventoryItem.cs

示例11: RemoveItems

        public MyEntity RemoveItems(uint itemId, MyFixedPoint? amount = null, bool sendEvent = true, bool spawn = false, MatrixD? spawnPos = null)
        {
            var item = GetItemByID(itemId);
            var am = amount.HasValue ? amount.Value : (item.HasValue ? item.Value.Amount : 1);
            MyEntity spawned = null;
            if (Sync.IsServer)
            {
                if (item.HasValue && RemoveItemsInternal(itemId, am, sendEvent))
                {
                    if (spawn)
                    {
                        MyEntity owner;
                        if (Owner is MyEntity)
                        {
                            owner = Owner as MyEntity;
                        }
                        else
                        {
                            owner = Container.Entity as MyEntity;
                        }

                        if (!spawnPos.HasValue)
                            spawnPos = MatrixD.CreateWorld(owner.PositionComp.GetPosition() + owner.PositionComp.WorldMatrix.Forward + owner.PositionComp.WorldMatrix.Up, owner.PositionComp.WorldMatrix.Forward, owner.PositionComp.WorldMatrix.Up);
                        spawned = item.Value.Spawn(am, spawnPos.Value, owner);

                        if (spawned != null && spawnPos.HasValue)
                        {
                            if (owner == MySession.Static.LocalCharacter)
                            {
                                MyGuiAudio.PlaySound(MyGuiSounds.PlayDropItem);
                            }
                            else
                            {
                                MyEntity3DSoundEmitter emitter = MyAudioComponent.TryGetSoundEmitter();
                                if (emitter != null)
                                {
                                    emitter.SetPosition(spawnPos.Value.Translation);
                                    emitter.PlaySound(dropSound);
                                }
                            }
                        }
                    }
                }
            }
            return spawned;
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:46,代码来源:MyInventory.cs

示例12: Update

        public override ChangeInfo Update(MyEntity owner, long playerID = 0)
        {
            ChangeInfo changed = ChangeInfo.None;
            bool enable = true;

            if (MyCubeBuilder.Static == null)
                return changed;
            var blockDefinition = MyCubeBuilder.Static.IsActivated ? MyCubeBuilder.Static.ToolbarBlockDefinition : null;
            var blockDef = (this.Definition as Sandbox.Definitions.MyCubeBlockDefinition);
            if ((MyCubeBuilder.Static.BlockCreationIsActivated || MyCubeBuilder.Static.MultiBlockCreationIsActivated) && blockDefinition != null && (!MyFakes.ENABLE_BATTLE_SYSTEM || !MySession.Static.Battle))
            {
                if (blockDefinition.BlockPairName == blockDef.BlockPairName)
                {
                    WantsToBeSelected = true;
                }
                else if (blockDef.BlockStages != null && blockDef.BlockStages.Contains(blockDefinition.Id))
                {
                    WantsToBeSelected = true;
                }
                else
                {
                    WantsToBeSelected = false;
                }
            }
            else
            {
                WantsToBeSelected = false;
            }

            var character = MySession.Static.LocalCharacter;
            if (MyFakes.ENABLE_GATHERING_SMALL_BLOCK_FROM_GRID)
            {
                if (blockDef.CubeSize == MyCubeSize.Small && character != null)
                {
                    var inventory = character.GetInventory();
                    MyFixedPoint amount = inventory != null ? inventory.GetItemAmount(Definition.Id) : 0;
                    if (m_lastAmount != amount)
                    {
                        m_lastAmount = amount;
                        changed |= ChangeInfo.IconText;
                    }

                    if (MySession.Static.SurvivalMode)
                    {
                        enable &= m_lastAmount > 0;
                    }
                    else
                    {
                        // so that we correctly set icontext when changing from enabled to disabled even when the amount is the same
                        changed |= ChangeInfo.IconText;
                    }
                }
            }

            if (MyPerGameSettings.EnableResearch && MySessionComponentResearch.Static != null && (blockDef.CubeSize == MyCubeSize.Large))
                enable &= MySessionComponentResearch.Static.CanUse(character, Definition.Id);

            changed |= SetEnabled(enable);

            return changed;
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:61,代码来源:MyToolbarItemCubeBlock.cs

示例13: Consume

		public void Consume(MyFixedPoint amount, MyConsumableItemDefinition definition)
		{
			if (definition == null)
				return;

			MyEntityStat stat;
			var regenEffect = new MyObjectBuilder_EntityStatRegenEffect();
			regenEffect.Interval = 1.0f;
			regenEffect.MaxRegenRatio = 1.0f;
			regenEffect.MinRegenRatio = 0.0f;

			foreach (var statValue in definition.Stats)
			{
				if (Stats.TryGetValue(MyStringHash.GetOrCompute(statValue.Name), out stat))
				{
					regenEffect.TickAmount = statValue.Value*(float)amount;
					regenEffect.Duration = statValue.Time;
					stat.AddEffect(regenEffect);
				}
			}
		}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:21,代码来源:MyCharacterStatComponent.cs

示例14: Round

 public static MyFixedPoint Round(MyFixedPoint a)
 {
     a.RawValue = (a.RawValue + Divider / 2) / Divider;
     return a;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:5,代码来源:MyFixedPoint.cs

示例15: Max

 public static MyFixedPoint Max(MyFixedPoint a, MyFixedPoint b)
 {
     return a > b ? a : b;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:4,代码来源:MyFixedPoint.cs


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