Unstable v0.19.3.0

This commit is contained in:
Juan Pablo Arce
2022-09-02 15:10:56 -03:00
parent 28789616bd
commit 3f2c843247
336 changed files with 7152 additions and 7739 deletions
@@ -401,14 +401,14 @@ namespace Barotrauma.Items.Components
msg.WriteVariableUInt32((uint)connection.Wires.Count);
foreach (Wire wire in connection.Wires)
{
msg.Write(wire?.Item == null ? (ushort)0 : wire.Item.ID);
msg.WriteUInt16(wire?.Item == null ? (ushort)0 : wire.Item.ID);
}
}
msg.Write((ushort)DisconnectedWires.Count);
msg.WriteUInt16((ushort)DisconnectedWires.Count);
foreach (Wire disconnectedWire in DisconnectedWires)
{
msg.Write(disconnectedWire.Item.ID);
msg.WriteUInt16(disconnectedWire.Item.ID);
}
}
}
@@ -155,7 +155,7 @@ namespace Barotrauma.Items.Components
{
//use semicolon as a separator because comma may be needed in the signals (for color or vector values for example)
//kind of hacky, we should probably add support for (string) arrays to SerializableEntityEditor so this wouldn't be needed
get { return signals == null ? "" : string.Join(";", signals); }
get { return signals == null ? string.Empty : string.Join(";", signals); }
set
{
if (value == null) { return; }
@@ -167,7 +167,31 @@ namespace Barotrauma.Items.Components
}
}
public override bool RecreateGUIOnResolutionChange => true;
private bool[] elementStates;
[Serialize("", IsPropertySaveable.Yes, description: "", alwaysUseInstanceValues: true)]
public string ElementStates
{
get { return elementStates == null ? string.Empty : string.Join(",", elementStates); }
set
{
if (value == null) { return; }
if (customInterfaceElementList.Count > 0)
{
string[] splitValues = value == "" ? Array.Empty<string>() : value.Split(',');
for (int i = 0; i < customInterfaceElementList.Count && i < splitValues.Length; i++)
{
if (!bool.TryParse(splitValues[i], out bool val)) { continue; }
customInterfaceElementList[i].State = val;
#if CLIENT
if (uiElements != null && i < uiElements.Count && uiElements[i] is GUITickBox tickBox)
{
tickBox.Selected = val;
}
#endif
}
}
}
}
private readonly List<CustomInterfaceElement> customInterfaceElementList = new List<CustomInterfaceElement>();
@@ -207,8 +231,10 @@ namespace Barotrauma.Items.Components
}
IsActive = true;
InitProjSpecific();
//load these here to ensure the UI elements (created in InitProjSpecific) are up-to-date
Labels = element.GetAttributeString("labels", "");
Signals = element.GetAttributeString("signals", "");
ElementStates = element.GetAttributeString("elementstates", "");
}
private void UpdateLabels(string[] newLabels)
@@ -386,6 +412,7 @@ namespace Barotrauma.Items.Components
{
labels = customInterfaceElementList.Select(ci => ci.Label).ToArray();
signals = customInterfaceElementList.Select(ci => ci.Signal).ToArray();
elementStates = customInterfaceElementList.Select(ci => ci.State).ToArray();
return base.Save(parentElement);
}
@@ -253,7 +253,13 @@ namespace Barotrauma.Items.Components
public void CheckIfNeedsUpdate()
{
if (item.body == null && powerConsumption <= 0.0f && Parent == null && turret == null && IsOn &&
if (!IsOn)
{
base.IsActive = false;
return;
}
if (item.body == null && powerConsumption <= 0.0f && Parent == null && turret == null &&
(statusEffectLists == null || !statusEffectLists.ContainsKey(ActionType.OnActive)) &&
(IsActiveConditionals == null || IsActiveConditionals.Count == 0))
{
@@ -268,7 +274,7 @@ namespace Barotrauma.Items.Components
}
else
{
IsActive = true;
base.IsActive = true;
}
}
@@ -374,7 +374,7 @@ namespace Barotrauma.Items.Components
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
{
msg.Write(isOn);
msg.WriteBoolean(isOn);
}
public void ClientEventRead(IReadMessage msg, float sendingTime)