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); }
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); }
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); } } } }
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; }
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; }
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."); } } }
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); } }