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


C# MyCharacter.GetInventory方法代码示例

本文整理汇总了C#中Sandbox.Game.Entities.Character.MyCharacter.GetInventory方法的典型用法代码示例。如果您正苦于以下问题:C# MyCharacter.GetInventory方法的具体用法?C# MyCharacter.GetInventory怎么用?C# MyCharacter.GetInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Game.Entities.Character.MyCharacter的用法示例。


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

示例1: AddItems

        private void AddItems(MyCharacter character)
        {
            character.GetInventory(0).Clear();

            var ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(StartingWeaponId.SubtypeName);
            if (character.WeaponTakesBuilderFromInventory(StartingWeaponId))            
            {
                character.GetInventory(0).AddItems(1, ob);
            }

            if (HumanoidDefinition.InventoryContentGenerated && MyFakes.ENABLE_RANDOM_INVENTORY)
            {

                MyContainerTypeDefinition cargoContainerDefinition = MyDefinitionManager.Static.GetContainerTypeDefinition(HumanoidDefinition.InventoryContainerTypeId.SubtypeName);
                    if (cargoContainerDefinition != null)
                    {
                        character.GetInventory(0).GenerateContent(cargoContainerDefinition);
                    }
                    else
                    {
                        Debug.Fail("CargoContainer type definition " + HumanoidDefinition.InventoryContainerTypeId + " wasn't found.");
                    }
            }
            else
            {
                foreach (var weaponDef in HumanoidDefinition.InventoryItems)
                {
                    ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(weaponDef.SubtypeName);
                    character.GetInventory(0).AddItems(1, ob);
                }
            }

            character.SwitchToWeapon(StartingWeaponId);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:34,代码来源:MyHumanoidBot.cs

示例2: AddItems

        private void AddItems(MyCharacter character)
        {
            character.GetInventory(0).Clear();

            var ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(StartingWeaponId.SubtypeName);
            character.GetInventory(0).AddItems(1, ob);

            foreach (var weaponDef in HumanoidDefinition.InventoryItems)
            {
                ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(weaponDef.SubtypeName);
                character.GetInventory(0).AddItems(1, ob);
            }

            character.SwitchToWeapon(StartingWeaponId);
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:15,代码来源:MyHumanoidBot.cs

示例3: AddItems

        protected override void AddItems(MyCharacter character)
        {
            base.AddItems(character);

            var ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(StartingWeaponId.SubtypeName);
            if (character.WeaponTakesBuilderFromInventory(StartingWeaponId))
            {
                character.GetInventory(0).AddItems(1, ob);
            }

            // else // allowing the inventory items to be added
            {
                foreach (var weaponDef in HumanoidDefinition.InventoryItems)
                {
                    ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(weaponDef.SubtypeName);
                    character.GetInventory(0).AddItems(1, ob);
                }
            }

            character.SwitchToWeapon(StartingWeaponId);

            {
                MyDefinitionId weaponDefinitionId;
                weaponDefinitionId = new MyDefinitionId(typeof(MyObjectBuilder_WeaponDefinition), StartingWeaponId.SubtypeName);

                MyWeaponDefinition weaponDefinition;

                if (MyDefinitionManager.Static.TryGetWeaponDefinition(weaponDefinitionId, out weaponDefinition)) //GetWeaponDefinition(StartingWeaponId);
                {
                    if (weaponDefinition.HasAmmoMagazines())
                    {
                        var ammo = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_AmmoMagazine>(weaponDefinition.AmmoMagazinesId[0].SubtypeName);
                        character.GetInventory(0).AddItems(3, ammo);
                    }
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:37,代码来源:MyHumanoidBot.cs

示例4: CreateCharacterBase

        private static MyCharacter CreateCharacterBase(MatrixD worldMatrix, ref Vector3 velocity, string characterName, string model, Vector3? colorMask, bool AIMode, bool useInventory = true, MyBotDefinition botDefinition = null)
        {
            MyCharacter character = new MyCharacter();
            MyObjectBuilder_Character objectBuilder = MyCharacter.Random();
            objectBuilder.CharacterModel = model ?? objectBuilder.CharacterModel;

            if (colorMask.HasValue)
                objectBuilder.ColorMaskHSV = colorMask.Value;

            objectBuilder.JetpackEnabled = MySession.Static.CreativeMode;
            objectBuilder.Battery = new MyObjectBuilder_Battery { CurrentCapacity = 1 };
            objectBuilder.AIMode = AIMode;
            objectBuilder.DisplayName = characterName;
            objectBuilder.LinearVelocity = velocity;
            objectBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
            character.Init(objectBuilder);

            MyEntities.RaiseEntityCreated(character);
            MyEntities.Add(character);

            System.Diagnostics.Debug.Assert(character.GetInventory() as MyInventory != null, "Null or unexpected inventory type returned!");
            if (useInventory)
                MyWorldGenerator.InitInventoryWithDefaults(character.GetInventory() as MyInventory);
            else if (botDefinition != null)
            {
                // use inventory from bot definition
                botDefinition.AddItems(character);
            }
            //character.PositionComp.SetWorldMatrix(worldMatrix);
            if (velocity.Length() > 0)
            {
                var jetpack = character.JetpackComp;

                if (jetpack != null)
                    jetpack.EnableDampeners(false, false);
            }

            return character;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:39,代码来源:MyCharacter.cs

示例5: AddConstruction

        public override bool AddConstruction(MyCharacter character)
        {
            // The new ship creation clipboard is handled separately
            if (m_shipCreationClipboard.IsActive)
            {
                return m_shipCreationClipboard.PasteGrid(character.GetInventory());
            }

            if (MyFakes.ENABLE_MULTIBLOCKS && MultiBlockCreationIsActivated)
            {
                if (m_multiBlockCreationClipboard.PasteGrid(character.GetInventory(), false))
                {
                    if (MySession.Static.SimpleSurvival)
                        m_lastBlockBuildTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                    return true;
                }
                return false;
            }

            var gizmoSpace = m_gizmo.SpaceDefault;

            if (gizmoSpace.Enabled && BuildInputValid && gizmoSpace.m_buildAllowed && !MyEntities.MemoryLimitReachedReport)
            {
                m_blocksBuildQueue.Clear();
                bool added = AddBlocksToBuildQueueOrSpawn(gizmoSpace);
                if (added)
                {
                    if (CurrentGrid != null && m_blocksBuildQueue.Count > 0)
                        CurrentGrid.BuildBlocks(MyToolbar.ColorMaskHSV, m_blocksBuildQueue);

                    if (MySession.Static.SimpleSurvival)
                        m_lastBlockBuildTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                }
                return added;
            }

            return false;
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:38,代码来源:MyCubeBuilder.cs

示例6: AddItems

        protected virtual void AddItems(MyCharacter character)
        {
            character.GetInventory(0).Clear();

            if (AgentDefinition.InventoryContentGenerated)
            {
                MyContainerTypeDefinition cargoContainerDefinition = MyDefinitionManager.Static.GetContainerTypeDefinition(AgentDefinition.InventoryContainerTypeId.SubtypeName);
                if (cargoContainerDefinition != null)
                {
                    character.GetInventory(0).GenerateContent(cargoContainerDefinition);
                }
                else
                {
                    Debug.Fail("CargoContainer type definition " + AgentDefinition.InventoryContainerTypeId + " wasn't found.");
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:17,代码来源:MyAgentBot.cs

示例7:

        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            if (!MarkedForClose)
            {
                if (!MySession.Static.CreativeMode)
                {
                    var amount = Item.Amount;
                    amount = MyFixedPoint.Min(amount, user.GetInventory().ComputeAmountThatFits(Item.Content.GetId()));
                    if (amount == 0)
                    {
                        if (MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastTimePlayedSound > 2500)
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudVocInventoryFull);
                            m_lastTimePlayedSound = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                        }

                        MyHud.Notifications.Add(MyNotificationSingletons.InventoryFull);
                        return;
                    }
                }
                if (MySession.ControlledEntity == user)
                    MyAudio.Static.PlaySound(TAKE_ITEM_SOUND.SoundId);
                //user.StartSecondarySound(TAKE_ITEM_SOUND);
                user.GetInventory().TakeFloatingObject(this);
            }
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:26,代码来源:MyFloatingObject.cs


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