本文整理汇总了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);
}
示例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);
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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.");
}
}
}
示例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);
}
}