Build 0.18.5.0
This commit is contained in:
@@ -270,7 +270,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Body?.SetTransform(Body.SimPosition + ConvertUnits.ToSimUnits(amount), 0.0f);
|
||||
}
|
||||
|
||||
if (linkedGap != null)
|
||||
{
|
||||
RefreshLinkedGap();
|
||||
linkedGap.Rect = item.Rect;
|
||||
}
|
||||
#if CLIENT
|
||||
UpdateConvexHulls();
|
||||
#endif
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private Character prevEquipper;
|
||||
|
||||
public override bool IsAttached => Attached;
|
||||
|
||||
private bool attachable, attached, attachedByDefault;
|
||||
private Voronoi2.VoronoiCell attachTargetCell;
|
||||
private PhysicsBody body;
|
||||
@@ -71,6 +73,7 @@ namespace Barotrauma.Items.Components
|
||||
set
|
||||
{
|
||||
attached = value;
|
||||
item.CheckCleanable();
|
||||
item.SetActiveSprite();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -20,6 +19,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private CoroutineHandle pickingCoroutine;
|
||||
|
||||
public virtual bool IsAttached => false;
|
||||
|
||||
public List<InvSlotType> AllowedSlots
|
||||
{
|
||||
get { return allowedSlots; }
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Barotrauma.Items.Components
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No, description: "Can the item hit broken doors.")]
|
||||
[Serialize(true, IsPropertySaveable.No, description: "Can the item hit doors.")]
|
||||
public bool HitItems { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No, description: "Can the item hit broken doors.")]
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Barotrauma.Items.Components
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool RemoveContainedItemsOnDeconstruct { get; set; }
|
||||
|
||||
private readonly ImmutableArray<SlotRestrictions> slotRestrictions;
|
||||
private ImmutableArray<SlotRestrictions> slotRestrictions;
|
||||
|
||||
readonly List<ISerializableEntity> targets = new List<ISerializableEntity>();
|
||||
|
||||
@@ -215,13 +215,21 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
public List<RelatedItem> ContainableItems { get; }
|
||||
public List<RelatedItem> ContainableItems { get; private set; }
|
||||
|
||||
public ItemContainer(Item item, ContentXElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
LoadContainableRestrictions(element);
|
||||
InitProjSpecific(element);
|
||||
}
|
||||
|
||||
public void LoadContainableRestrictions(ContentXElement element)
|
||||
{
|
||||
int totalCapacity = capacity;
|
||||
|
||||
ContainableItems?.Clear();
|
||||
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
@@ -242,7 +250,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
Inventory = new ItemInventory(item, this, totalCapacity, SlotsPerRow);
|
||||
|
||||
|
||||
List<SlotRestrictions> newSlotRestrictions = new List<SlotRestrictions>(totalCapacity);
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
@@ -253,7 +261,7 @@ namespace Barotrauma.Items.Components
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "subcontainer") { continue; }
|
||||
|
||||
|
||||
int subCapacity = subElement.GetAttributeInt("capacity", 1);
|
||||
int subMaxStackSize = subElement.GetAttributeInt("maxstacksize", maxStackSize);
|
||||
|
||||
@@ -281,7 +289,6 @@ namespace Barotrauma.Items.Components
|
||||
capacity = totalCapacity;
|
||||
slotRestrictions = newSlotRestrictions.ToImmutableArray();
|
||||
System.Diagnostics.Debug.Assert(totalCapacity == slotRestrictions.Length);
|
||||
InitProjSpecific(element);
|
||||
}
|
||||
|
||||
public int GetMaxStackSize(int slotIndex)
|
||||
|
||||
@@ -114,6 +114,20 @@ namespace Barotrauma.Items.Components
|
||||
private set;
|
||||
} = true;
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool NonInteractableWhenFlippedX
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool NonInteractableWhenFlippedY
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Controller(Item item, ContentXElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
@@ -571,6 +585,18 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
{
|
||||
if (item.FlippedX && NonInteractableWhenFlippedX)
|
||||
{
|
||||
item.NonInteractable = true;
|
||||
}
|
||||
else if (item.FlippedY && NonInteractableWhenFlippedY)
|
||||
{
|
||||
item.NonInteractable = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
@@ -435,7 +435,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("GridUpdate", sw.ElapsedTicks);
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Power", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
#endif
|
||||
|
||||
@@ -592,7 +592,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("PowerUpdate", sw.ElapsedTicks);
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Power", sw.ElapsedTicks);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace Barotrauma
|
||||
Beard,
|
||||
Moustache,
|
||||
FaceAttachment,
|
||||
JobIndicator,
|
||||
Husk,
|
||||
Herpes
|
||||
}
|
||||
@@ -128,7 +127,6 @@ namespace Barotrauma
|
||||
case WearableType.Beard:
|
||||
case WearableType.Moustache:
|
||||
case WearableType.FaceAttachment:
|
||||
case WearableType.JobIndicator:
|
||||
case WearableType.Husk:
|
||||
case WearableType.Herpes:
|
||||
Limb = LimbType.Head;
|
||||
|
||||
@@ -29,6 +29,20 @@ namespace Barotrauma
|
||||
|
||||
public static IReadOnlyCollection<Item> DangerousItems { get { return dangerousItems; } }
|
||||
|
||||
private static readonly List<Item> repairableItems = new List<Item>();
|
||||
|
||||
/// <summary>
|
||||
/// Items that have one more more Repairable component
|
||||
/// </summary>
|
||||
public static IReadOnlyCollection<Item> RepairableItems => repairableItems;
|
||||
|
||||
private static readonly List<Item> cleanableItems = new List<Item>();
|
||||
|
||||
/// <summary>
|
||||
/// Items that may potentially need to be cleaned up (pickable, not attached to a wall, and not inside a valid container)
|
||||
/// </summary>
|
||||
public static IReadOnlyCollection<Item> CleanableItems => cleanableItems;
|
||||
|
||||
public new ItemPrefab Prefab => base.Prefab as ItemPrefab;
|
||||
|
||||
public static bool ShowLinks = true;
|
||||
@@ -186,6 +200,7 @@ namespace Barotrauma
|
||||
if (value != container)
|
||||
{
|
||||
container = value;
|
||||
CheckCleanable();
|
||||
SetActiveSprite();
|
||||
}
|
||||
}
|
||||
@@ -1009,10 +1024,9 @@ namespace Barotrauma
|
||||
|
||||
InsertToList();
|
||||
ItemList.Add(this);
|
||||
if (Prefab.IsDangerous)
|
||||
{
|
||||
dangerousItems.Add(this);
|
||||
}
|
||||
if (Prefab.IsDangerous) { dangerousItems.Add(this); }
|
||||
if (Repairables.Any()) { repairableItems.Add(this); }
|
||||
CheckCleanable();
|
||||
|
||||
DebugConsole.Log("Created " + Name + " (" + ID + ")");
|
||||
|
||||
@@ -1022,6 +1036,9 @@ namespace Barotrauma
|
||||
ApplyStatusEffects(ActionType.OnSpawn, 1.0f);
|
||||
Components.ForEach(c => c.ApplyStatusEffects(ActionType.OnSpawn, 1.0f));
|
||||
RecalculateConditionValues();
|
||||
#if CLIENT
|
||||
Submarine.ForceVisibilityRecheck();
|
||||
#endif
|
||||
}
|
||||
|
||||
partial void InitProjSpecific();
|
||||
@@ -1150,6 +1167,7 @@ namespace Barotrauma
|
||||
drawableComponents.Add(drawable);
|
||||
hasComponentsToDraw = true;
|
||||
#if CLIENT
|
||||
Submarine.ForceVisibilityRecheck();
|
||||
cachedVisibleExtents = null;
|
||||
#endif
|
||||
}
|
||||
@@ -1281,6 +1299,27 @@ namespace Barotrauma
|
||||
|
||||
partial void SetActiveSpriteProjSpecific();
|
||||
|
||||
/// <summary>
|
||||
/// Recheck if the item needs to be included in the list of cleanable items
|
||||
/// </summary>
|
||||
public void CheckCleanable()
|
||||
{
|
||||
var pickable = GetComponent<Pickable>();
|
||||
if (pickable != null && !pickable.IsAttached &&
|
||||
Prefab.PreferredContainers.Any() &&
|
||||
(container == null || container.HasTag("allowcleanup")))
|
||||
{
|
||||
if (!cleanableItems.Contains(this))
|
||||
{
|
||||
cleanableItems.Add(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanableItems.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount, bool ignoreContacts = false)
|
||||
{
|
||||
if (!MathUtils.IsValid(amount))
|
||||
@@ -2526,7 +2565,7 @@ namespace Barotrauma
|
||||
ic.WasUsed = true;
|
||||
#if CLIENT
|
||||
ic.PlaySound(ActionType.OnUse, character);
|
||||
#endif
|
||||
#endif
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character, targetLimb);
|
||||
|
||||
if (ic.DeleteOnUse) { remove = true; }
|
||||
@@ -2704,6 +2743,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
SetContainedItemPositions();
|
||||
#if CLIENT
|
||||
Submarine.ForceVisibilityRecheck();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Equip(Character character)
|
||||
@@ -3368,8 +3410,7 @@ namespace Barotrauma
|
||||
{
|
||||
ic.ShallowRemove();
|
||||
}
|
||||
ItemList.Remove(this);
|
||||
dangerousItems.Remove(this);
|
||||
RemoveFromLists();
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
@@ -3427,8 +3468,8 @@ namespace Barotrauma
|
||||
ic.GuiFrame = null;
|
||||
#endif
|
||||
}
|
||||
ItemList.Remove(this);
|
||||
dangerousItems.Remove(this);
|
||||
|
||||
RemoveFromLists();
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
@@ -3461,6 +3502,14 @@ namespace Barotrauma
|
||||
RemoveProjSpecific();
|
||||
}
|
||||
|
||||
private void RemoveFromLists()
|
||||
{
|
||||
ItemList.Remove(this);
|
||||
dangerousItems.Remove(this);
|
||||
repairableItems.Remove(this);
|
||||
cleanableItems.Remove(this);
|
||||
}
|
||||
|
||||
partial void RemoveProjSpecific();
|
||||
|
||||
public static void RemoveByPrefab(ItemPrefab prefab)
|
||||
|
||||
Reference in New Issue
Block a user