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

This commit is contained in:
EvilFactory
2023-12-14 11:56:39 -03:00
376 changed files with 7775 additions and 2879 deletions
@@ -26,7 +26,8 @@ namespace Barotrauma.Items.Components
RequiredSignalCount = element.GetChildElements("TerminalButton").Count(c => c.GetAttribute("style") != null);
if (RequiredSignalCount < 1)
{
DebugConsole.ThrowError($"Error in item \"{item.Name}\": no TerminalButton elements defined for the ButtonTerminal component!");
DebugConsole.ThrowError($"Error in item \"{item.Name}\": no TerminalButton elements defined for the ButtonTerminal component!",
contentPackage: element.ContentPackage);
}
InitProjSpecific(element);
}
@@ -29,6 +29,9 @@ namespace Barotrauma.Items.Components
// We don't want the components and wires to transfer between subs as it would cause issues.
public override bool DontTransferInventoryBetweenSubs => true;
// We don't want to sell the components and wires inside the circuit box
public override bool DisallowSellingItemsFromContainer => true;
public Option<CircuitBoxConnection> FindInputOutputConnection(Identifier connectionName)
{
foreach (CircuitBoxInputConnection input in Inputs)
@@ -154,7 +157,7 @@ namespace Barotrauma.Items.Components
delayedElementToLoad = Option.None;
}
private void LoadFromXML(ContentXElement loadElement)
public void LoadFromXML(ContentXElement loadElement)
{
foreach (var subElement in loadElement.Elements())
{
@@ -395,8 +398,8 @@ namespace Barotrauma.Items.Components
{
Components.Add(new CircuitBoxComponent(id, spawnedItem, pos, this, usedResource));
onItemSpawned?.Invoke(spawnedItem);
OnViewUpdateProjSpecific();
});
OnViewUpdateProjSpecific();
return true;
}
@@ -383,6 +383,12 @@ namespace Barotrauma.Items.Components
wire.RemoveConnection(item);
}
}
c.Grid = null;
}
foreach (var connection in Connections)
{
Powered.ChangedConnections.Remove(connection);
connection.Recipients.Clear();
}
Connections.Clear();
@@ -305,16 +305,17 @@ namespace Barotrauma.Items.Components
(statusEffectLists == null || !statusEffectLists.ContainsKey(ActionType.OnActive)) &&
(IsActiveConditionals == null || IsActiveConditionals.Count == 0))
{
if (item.body != null && !item.body.Enabled)
{
lightBrightness = 0.0f;
SetLightSourceState(false, 0.0f);
}
else
if (item.body == null || item.body.Enabled ||
(item.ParentInventory is ItemInventory itemInventory && !itemInventory.Container.HideItems))
{
lightBrightness = 1.0f;
SetLightSourceState(true, lightBrightness);
}
else
{
lightBrightness = 0.0f;
SetLightSourceState(false, 0.0f);
}
isOn = true;
SetLightSourceTransformProjSpecific();
base.IsActive = false;
@@ -341,8 +342,22 @@ namespace Barotrauma.Items.Components
#if CLIENT
Light.ParentSub = item.Submarine;
#endif
bool visibleInContainer;
var ownerCharacter = item.GetRootInventoryOwner() as Character;
if ((item.Container != null && ownerCharacter == null) ||
if (ownerCharacter != null && item.RootContainer?.GetComponent<Holdable>() is not { IsActive: true })
{
//if the item is in a character inventory, the light should only be visible if the character is holding the item
//(not if it's e.q. inside a wearable item, or in a rifle worn on the back)
visibleInContainer = false;
}
else
{
visibleInContainer = item.FindParentInventory(static it => it is ItemInventory { Container.HideItems: true }) == null;
}
if ((item.Container != null && !visibleInContainer && ownerCharacter == null) ||
(ownerCharacter != null && ownerCharacter.InvisibleTimer > 0.0f))
{
lightBrightness = 0.0f;
@@ -352,7 +367,7 @@ namespace Barotrauma.Items.Components
SetLightSourceTransformProjSpecific();
PhysicsBody body = ParentBody ?? item.body;
if (body != null && !body.Enabled)
if (body != null && !body.Enabled && !visibleInContainer)
{
lightBrightness = 0.0f;
SetLightSourceState(false, 0.0f);
@@ -432,6 +447,11 @@ namespace Barotrauma.Items.Components
target.SightRange = Math.Max(target.SightRange, target.MaxSightRange * lightBrightness);
}
public override void Drop(Character dropper, bool setTransform = true)
{
SetLightSourceTransform();
}
partial void SetLightSourceState(bool enabled, float brightness);
public void SetLightSourceTransform()