Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2023-10-19 12:18:30 -03:00
613 changed files with 22122 additions and 11481 deletions
@@ -24,7 +24,7 @@ namespace Barotrauma.Items.Components
/// </summary>
Vector2 DrawSize { get; }
void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1);
void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1, Color? overrideColor = null);
#endif
}
@@ -113,8 +113,8 @@ namespace Barotrauma.Items.Components
private bool drawable = true;
[Serialize(PropertyConditional.Comparison.And, IsPropertySaveable.No)]
public PropertyConditional.Comparison IsActiveConditionalComparison
[Serialize(PropertyConditional.LogicalOperatorType.And, IsPropertySaveable.No)]
public PropertyConditional.LogicalOperatorType IsActiveConditionalComparison
{
get;
set;
@@ -160,6 +160,12 @@ namespace Barotrauma.Items.Components
protected set;
}
[Serialize(false, IsPropertySaveable.Yes), ConditionallyEditable(ConditionallyEditable.ConditionType.OnlyByStatusEffectsAndNetwork, onlyInEditors: false)]
public bool LockGuiFramePosition { get; set; }
[Serialize("0,0", IsPropertySaveable.Yes), ConditionallyEditable(ConditionallyEditable.ConditionType.OnlyByStatusEffectsAndNetwork, onlyInEditors: false)]
public Point GuiFrameOffset { get; set; }
[Serialize(false, IsPropertySaveable.No, description: "Can the item be selected by interacting with it.")]
public bool CanBeSelected
{
@@ -252,6 +258,9 @@ namespace Barotrauma.Items.Components
/// </summary>
public float Speed => item.Speed;
public readonly record struct ItemUseInfo(Item Item, Character User);
public readonly NamedEvent<ItemUseInfo> OnUsed = new();
public readonly bool InheritStatusEffects;
public ItemComponent(Item item, ContentXElement element)
@@ -340,15 +349,10 @@ namespace Barotrauma.Items.Components
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "activeconditional":
case "isactiveconditional":
case "isactive":
IsActiveConditionals = IsActiveConditionals ?? new List<PropertyConditional>();
foreach (XAttribute attribute in subElement.Attributes())
{
if (PropertyConditional.IsValid(attribute))
{
IsActiveConditionals.Add(new PropertyConditional(attribute));
}
}
IsActiveConditionals ??= new List<PropertyConditional>();
IsActiveConditionals.AddRange(PropertyConditional.FromXElement(subElement));
break;
case "requireditem":
case "requireditems":
@@ -494,7 +498,7 @@ namespace Barotrauma.Items.Components
case "trigger_in":
if (signal.value != "0")
{
item.Use(1.0f, signal.sender);
item.Use(1.0f, user: signal.sender);
}
break;
case "toggle":
@@ -531,7 +535,7 @@ namespace Barotrauma.Items.Components
}
item.ParentInventory.RemoveItem(item);
}
Entity.Spawner.AddItemToRemoveQueue(item);
RemoveItem(item);
}
else
{
@@ -547,12 +551,23 @@ namespace Barotrauma.Items.Components
}
this.Item.ParentInventory.RemoveItem(this.Item);
}
Entity.Spawner.AddItemToRemoveQueue(this.Item);
RemoveItem(this.Item);
}
else
{
this.Item.Condition += transferAmount;
}
static void RemoveItem(Item item)
{
if (Screen.Selected is { IsEditor: true })
{
item?.Remove();
}
else
{
Entity.Spawner?.AddItemToRemoveQueue(item);
}
}
}
else
{
@@ -753,7 +768,7 @@ namespace Barotrauma.Items.Components
/// </summary>
private bool CheckIdCardAccess(RelatedItem relatedItem, IdCard idCard)
{
if (item.Submarine != null)
if (item.Submarine != null && item.Submarine != GameMain.NetworkMember?.RespawnManager?.RespawnShuttle)
{
//id cards don't work in enemy subs (except on items that only require the default "idcard" tag)
if (idCard.TeamID != CharacterTeamType.None && idCard.TeamID != item.Submarine.TeamID && relatedItem.Identifiers.Any(id => id != "idcard"))
@@ -913,7 +928,16 @@ namespace Barotrauma.Items.Components
ParseMsg();
OverrideRequiredItems(componentElement);
}
#if CLIENT
if (GuiFrame != null)
{
GuiFrame.RectTransform.ScreenSpaceOffset = GuiFrameOffset;
if (guiFrameDragHandle != null)
{
guiFrameDragHandle.Enabled = !LockGuiFramePosition;
}
}
#endif
if (item.Submarine != null) { SerializableProperty.UpgradeGameVersion(this, originalElement, item.Submarine.Info.GameVersion); }
}
@@ -929,6 +953,11 @@ namespace Barotrauma.Items.Components
public virtual void OnScaleChanged() { }
/// <summary>
/// Called when the item has an ItemContainer and the contents inside of it changed.
/// </summary>
public virtual void OnInventoryChanged() { }
public static ItemComponent Load(ContentXElement element, Item item, bool errorMessages = true)
{
Type type;