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

This commit is contained in:
EvilFactory
2025-04-10 10:37:09 -03:00
296 changed files with 8420 additions and 2945 deletions
@@ -640,6 +640,18 @@ namespace Barotrauma.Items.Components
OnViewUpdateProjSpecific();
}
public void RemoveWire(Wire wireItem)
{
foreach (CircuitBoxWire wire in Wires.ToImmutableArray())
{
if (wire.BackingWire.TryUnwrap(out var backingWire) && backingWire == wireItem.Item)
{
RemoveWireCollectionUnsafe(wire);
}
}
OnViewUpdateProjSpecific();
}
private void RemoveWireCollectionUnsafe(CircuitBoxWire wire)
{
foreach (CircuitBoxOutputConnection output in Outputs)
@@ -198,6 +198,13 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize("0,0", IsPropertySaveable.No, description: "Offset of the light from the position of the item (in pixels).")]
public Vector2 LightOffset
{
get;
set;
}
/// <summary>
/// Returns true if the red component of the light is twice as bright as the blue and green. Can be used by StatusEffects.
/// </summary>
@@ -304,17 +311,18 @@ namespace Barotrauma.Items.Components
(statusEffectLists == null || !statusEffectLists.ContainsKey(ActionType.OnActive)) &&
(IsActiveConditionals == null || IsActiveConditionals.Count == 0))
{
if (item.body == null || item.body.Enabled ||
(item.ParentInventory is ItemInventory itemInventory && !itemInventory.Container.HideItems))
{
lightBrightness = 1.0f;
SetLightSourceState(true, lightBrightness);
}
else
PhysicsBody body = ParentBody ?? item.body;
if ((body == null || !body.Enabled) &&
(item.FindParentInventory(static it => it is ItemInventory { Container.HideItems: true }) != null))
{
lightBrightness = 0.0f;
SetLightSourceState(false, 0.0f);
}
else
{
lightBrightness = 1.0f;
SetLightSourceState(true, lightBrightness);
}
isOn = true;
SetLightSourceTransformProjSpecific();
base.IsActive = false;
@@ -366,7 +374,7 @@ namespace Barotrauma.Items.Components
SetLightSourceTransformProjSpecific();
PhysicsBody body = ParentBody ?? item.body;
if (body != null && !body.Enabled && !visibleInContainer)
if ((body == null || !body.Enabled) && !visibleInContainer)
{
lightBrightness = 0.0f;
SetLightSourceState(false, 0.0f);
@@ -272,8 +272,15 @@ namespace Barotrauma.Items.Components
if (worldBorders.Intersects(detectRect))
{
MotionDetected = true;
return;
foreach (Structure wall in Structure.WallList)
{
if (wall.Submarine == sub &&
wall.WorldRect.Intersects(detectRect))
{
MotionDetected = true;
return;
}
}
}
}
}
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
partial class WifiComponent : ItemComponent, IServerSerializable
partial class WifiComponent : ItemComponent, IServerSerializable, IClientSerializable
{
private static readonly List<WifiComponent> list = new List<WifiComponent>();
@@ -56,7 +56,6 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "Can the component communicate with wifi components in another team's submarine (e.g. enemy sub in Combat missions, respawn shuttle). Needs to be enabled on both the component transmitting the signal and the component receiving it.", alwaysUseInstanceValues: true)]
public bool AllowCrossTeamCommunication
{
@@ -376,5 +375,25 @@ namespace Barotrauma.Items.Components
element.Add(new XAttribute("channelmemory", string.Join(',', channelMemory)));
return element;
}
protected void SharedEventWrite(IWriteMessage msg)
{
msg.WriteRangedInteger(Channel, MinChannel, MaxChannel);
for (int i = 0; i < ChannelMemorySize; i++)
{
msg.WriteRangedInteger(channelMemory[i], MinChannel, MaxChannel);
}
}
protected void SharedEventRead(IReadMessage msg)
{
Channel = msg.ReadRangedInteger(MinChannel, MaxChannel);
for (int i = 0; i < ChannelMemorySize; i++)
{
channelMemory[i] = msg.ReadRangedInteger(MinChannel, MaxChannel);
}
}
}
}
@@ -84,6 +84,13 @@ namespace Barotrauma.Items.Components
public float Length { get; private set; }
[Serialize(0.3f, IsPropertySaveable.No), Editable(MinValueFloat = 0.01f, MaxValueFloat = 10.0f, DecimalCount = 2)]
public float Width
{
get;
set;
}
[Serialize(5000.0f, IsPropertySaveable.No, description: "The maximum distance the wire can extend (in pixels).")]
public float MaxLength
{
@@ -885,8 +892,13 @@ namespace Barotrauma.Items.Components
protected override void RemoveComponentSpecific()
{
if (item.Container?.GetComponent<CircuitBox>() is { } circuitBox)
{
circuitBox.RemoveWire(this);
}
ClearConnections();
base.RemoveComponentSpecific();
#if CLIENT
if (DraggingWire == this) { draggingWire = null; }
overrideSprite?.Remove();