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

C# VRage.MyFixedPoint类代码示例

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

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



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


示例16: Min

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


示例17: CheckInventoryCapacity

        private bool CheckInventoryCapacity(MyInventory inventory, MyBlueprintDefinitionBase.Item[] items, MyFixedPoint amountMultiplier)
        {
            if (MySession.Static.CreativeMode)
                return true;

            MyFixedPoint resultVolume = 0;
            foreach (var item in items)
            {
                var def = MyDefinitionManager.Static.GetPhysicalItemDefinition(item.Id);
                resultVolume += (MyFixedPoint)def.Volume * item.Amount * amountMultiplier;
            }
            return inventory.CurrentVolume + resultVolume <= inventory.MaxVolume;
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:13,代码来源:MyAssembler.cs


示例18: Ceiling

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


示例19: IsIntegral

 public static bool IsIntegral(MyFixedPoint fp)
 {
     return fp.RawValue % Divider == 0;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:4,代码来源:MyFixedPoint.cs


示例20: InsertQueueItem

 protected override void InsertQueueItem(int idx, MyBlueprintDefinitionBase blueprint, MyFixedPoint amount)
 {
     if (idx == 0)
     {
         var queueItem = TryGetFirstQueueItem();
         if (queueItem.HasValue && queueItem.Value.Blueprint != blueprint)
             CurrentProgress = 0f;
     }
     base.InsertQueueItem(idx, blueprint, amount);
 }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:10,代码来源:MyAssembler.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Entity.MyEntity类代码示例发布时间:2022-05-26
下一篇:
C# VRTK.ControllerInteractionEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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