Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -57,7 +57,7 @@ namespace Barotrauma.Items.Components
//how many items can be contained
private int capacity;
[Serialize(5, false, description: "How many items can be contained inside this item.")]
[Serialize(5, IsPropertySaveable.No, description: "How many items can be contained inside this item.")]
public int Capacity
{
get { return capacity; }
@@ -66,7 +66,7 @@ namespace Barotrauma.Items.Components
//how many items can be contained
private int maxStackSize;
[Serialize(64, false, description: "How many items can be stacked in one slot. Does not increase the maximum stack size of the items themselves, e.g. a stack of bullets could have a maximum size of 8 but the number of bullets in a specific weapon could be restricted to 6.")]
[Serialize(64, IsPropertySaveable.No, description: "How many items can be stacked in one slot. Does not increase the maximum stack size of the items themselves, e.g. a stack of bullets could have a maximum size of 8 but the number of bullets in a specific weapon could be restricted to 6.")]
public int MaxStackSize
{
get { return maxStackSize; }
@@ -74,7 +74,7 @@ namespace Barotrauma.Items.Components
}
private bool hideItems;
[Serialize(true, false, description: "Should the items contained inside this item be hidden."
[Serialize(true, IsPropertySaveable.No, description: "Should the items contained inside this item be hidden."
+ " If set to false, you should use the ItemPos and ItemInterval properties to determine where the items get rendered.")]
public bool HideItems
{
@@ -85,55 +85,55 @@ namespace Barotrauma.Items.Components
Drawable = !hideItems;
}
}
[Serialize("0.0,0.0", false, description: "The position where the contained items get drawn at (offset from the upper left corner of the sprite in pixels).")]
[Serialize("0.0,0.0", IsPropertySaveable.No, description: "The position where the contained items get drawn at (offset from the upper left corner of the sprite in pixels).")]
public Vector2 ItemPos { get; set; }
[Serialize("0.0,0.0", false, description: "The interval at which the contained items are spaced apart from each other (in pixels).")]
[Serialize("0.0,0.0", IsPropertySaveable.No, description: "The interval at which the contained items are spaced apart from each other (in pixels).")]
public Vector2 ItemInterval { get; set; }
[Serialize(100, false, description: "How many items are placed in a row before starting a new row.")]
[Serialize(100, IsPropertySaveable.No, description: "How many items are placed in a row before starting a new row.")]
public int ItemsPerRow { get; set; }
[Serialize(true, false, description: "Should the inventory of this item be visible when the item is selected.")]
[Serialize(true, IsPropertySaveable.No, description: "Should the inventory of this item be visible when the item is selected.")]
public bool DrawInventory
{
get;
set;
}
[Serialize(true, false, "Allow dragging and dropping items to deposit items into this inventory.")]
[Serialize(true, IsPropertySaveable.No, "Allow dragging and dropping items to deposit items into this inventory.")]
public bool AllowDragAndDrop
{
get;
set;
}
[Serialize(true, false)]
[Serialize(true, IsPropertySaveable.No)]
public bool AllowSwappingContainedItems
{
get;
set;
}
[Serialize(false, false, description: "If set to true, interacting with this item will make the character interact with the contained item(s), automatically picking them up if they can be picked up.")]
[Serialize(false, IsPropertySaveable.No, description: "If set to true, interacting with this item will make the character interact with the contained item(s), automatically picking them up if they can be picked up.")]
public bool AutoInteractWithContained
{
get;
set;
}
[Serialize(true, false)]
[Serialize(true, IsPropertySaveable.No)]
public bool AllowAccess { get; set; }
[Serialize(false, false)]
[Serialize(false, IsPropertySaveable.No)]
public bool AccessOnlyWhenBroken { get; set; }
[Serialize(5, false, description: "How many inventory slots the inventory has per row.")]
[Serialize(5, IsPropertySaveable.No, description: "How many inventory slots the inventory has per row.")]
public int SlotsPerRow { get; set; }
private readonly HashSet<string> containableRestrictions = new HashSet<string>();
[Editable, Serialize("", true, description: "Define items (by identifiers or tags) that bots should place inside this container. If empty, no restrictions are applied.")]
[Editable, Serialize("", IsPropertySaveable.Yes, description: "Define items (by identifiers or tags) that bots should place inside this container. If empty, no restrictions are applied.")]
public string ContainableRestrictions
{
get { return string.Join(",", containableRestrictions); }
@@ -143,46 +143,46 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(true, true, description: "Should this container be automatically filled with items?")]
[Editable, Serialize(true, IsPropertySaveable.Yes, description: "Should this container be automatically filled with items?")]
public bool AutoFill { get; set; }
private float itemRotation;
[Serialize(0.0f, false, description: "The rotation in which the contained sprites are drawn (in degrees).")]
[Serialize(0.0f, IsPropertySaveable.No, description: "The rotation in which the contained sprites are drawn (in degrees).")]
public float ItemRotation
{
get { return MathHelper.ToDegrees(itemRotation); }
set { itemRotation = MathHelper.ToRadians(value); }
}
[Serialize("", false, description: "Specify an item for the container to spawn with.")]
[Serialize("", IsPropertySaveable.No, description: "Specify an item for the container to spawn with.")]
public string SpawnWithId
{
get;
set;
}
[Serialize(false, false, description: "Should the items configured using SpawnWithId spawn if this item is broken.")]
[Serialize(false, IsPropertySaveable.No, description: "Should the items configured using SpawnWithId spawn if this item is broken.")]
public bool SpawnWithIdWhenBroken
{
get;
set;
}
[Serialize(false, false, description: "Should the items be injected into the user.")]
[Serialize(false, IsPropertySaveable.No, description: "Should the items be injected into the user.")]
public bool AutoInject
{
get;
set;
}
[Serialize(0.5f, false, description: "The health threshold that the user must reach in order to activate the autoinjection.")]
[Serialize(0.5f, IsPropertySaveable.No, description: "The health threshold that the user must reach in order to activate the autoinjection.")]
public float AutoInjectThreshold
{
get;
set;
}
[Serialize(false, false)]
[Serialize(false, IsPropertySaveable.No)]
public bool RemoveContainedItemsOnDeconstruct { get; set; }
private SlotRestrictions[] slotRestrictions;
@@ -202,20 +202,20 @@ namespace Barotrauma.Items.Components
if (!isRestrictionsDefined) { return true; }
return containableRestrictions.Any(id => item.Prefab.Identifier == id || item.HasTag(id));
}
private ImmutableHashSet<string> containableItemIdentifiers;
public IEnumerable<string> ContainableItemIdentifiers => containableItemIdentifiers;
private ImmutableHashSet<Identifier> containableItemIdentifiers;
public IEnumerable<Identifier> ContainableItemIdentifiers => containableItemIdentifiers;
public override bool RecreateGUIOnResolutionChange => true;
public List<RelatedItem> ContainableItems { get; }
public ItemContainer(Item item, XElement element)
public ItemContainer(Item item, ContentXElement element)
: base(item, element)
{
int totalCapacity = capacity;
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -223,7 +223,7 @@ namespace Barotrauma.Items.Components
RelatedItem containable = RelatedItem.Load(subElement, returnEmpty: false, parentDebugName: item.Name);
if (containable == null)
{
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFile + "\" - containable with no identifiers.");
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - containable with no identifiers.");
continue;
}
ContainableItems ??= new List<RelatedItem>();
@@ -242,7 +242,7 @@ namespace Barotrauma.Items.Components
}
int subContainerIndex = capacity;
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
if (subElement.Name.ToString().ToLowerInvariant() != "subcontainer") { continue; }
@@ -250,14 +250,14 @@ namespace Barotrauma.Items.Components
int subMaxStackSize = subElement.GetAttributeInt("maxstacksize", maxStackSize);
List<RelatedItem> subContainableItems = null;
foreach (XElement subSubElement in subElement.Elements())
foreach (var subSubElement in subElement.Elements())
{
if (subSubElement.Name.ToString().ToLowerInvariant() != "containable") { continue; }
RelatedItem containable = RelatedItem.Load(subSubElement, returnEmpty: false, parentDebugName: item.Name);
if (containable == null)
{
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFile + "\" - containable with no identifiers.");
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - containable with no identifiers.");
continue;
}
subContainableItems ??= new List<RelatedItem>();
@@ -283,7 +283,7 @@ namespace Barotrauma.Items.Components
return slotRestrictions[slotIndex].MaxStackSize;
}
partial void InitProjSpecific(XElement element);
partial void InitProjSpecific(ContentXElement element);
public void OnItemContained(Item containedItem)
{
@@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components
if (item.GetComponent<Planter>() != null)
{
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier ?? "null") + ":GardeningPlanted:" + containedItem.prefab.Identifier);
GameAnalyticsManager.AddDesignEvent("MicroInteraction:" + (GameMain.GameSession?.GameMode?.Preset.Identifier.Value ?? "null") + ":GardeningPlanted:" + containedItem.Prefab.Identifier);
}
//no need to Update() if this item has no statuseffects and no physics body
@@ -424,7 +424,7 @@ namespace Barotrauma.Items.Components
}
}
public override bool HasRequiredItems(Character character, bool addMessage, string msg = null)
public override bool HasRequiredItems(Character character, bool addMessage, LocalizedString msg = null)
{
return AllowAccess && (!AccessOnlyWhenBroken || Item.Condition <= 0) && base.HasRequiredItems(character, addMessage, msg);
}
@@ -648,7 +648,7 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
Inventory.AllowSwappingContainedItems = AllowSwappingContainedItems;
containableItemIdentifiers = slotRestrictions.SelectMany(s => s.ContainableItems?.SelectMany(ri => ri.Identifiers) ?? Enumerable.Empty<string>()).ToImmutableHashSet();
containableItemIdentifiers = slotRestrictions.SelectMany(s => s.ContainableItems?.SelectMany(ri => ri.Identifiers) ?? Enumerable.Empty<Identifier>()).ToImmutableHashSet();
if (item.Submarine == null || !item.Submarine.Loading)
{
SpawnAlwaysContainedItems();
@@ -716,7 +716,7 @@ namespace Barotrauma.Items.Components
else
{
IsActive = true;
Entity.Spawner?.AddToSpawnQueue(prefab, Inventory, spawnIfInventoryFull: false, onSpawned: (Item item) => { alwaysContainedItemsSpawned = true; });
Entity.Spawner?.AddItemToSpawnQueue(prefab, Inventory, spawnIfInventoryFull: false, onSpawned: (Item item) => { alwaysContainedItemsSpawned = true; });
}
}
}
@@ -745,7 +745,7 @@ namespace Barotrauma.Items.Components
Inventory.AllItemsMod.ForEach(it => it.Drop(null));
}
public override void Load(XElement componentElement, bool usePrefabValues, IdRemap idRemap)
public override void Load(ContentXElement componentElement, bool usePrefabValues, IdRemap idRemap)
{
base.Load(componentElement, usePrefabValues, idRemap);