Unstable 0.1400.7.0 (Coronavirus edition)

This commit is contained in:
Markus Isberg
2021-07-23 21:01:17 +03:00
parent ee5308b39f
commit 47707c824a
133 changed files with 1310 additions and 533 deletions
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -23,7 +24,7 @@ namespace Barotrauma.Items.Components
private int signalQueueSize;
private int delayTicks;
private Queue<DelayedSignal> signalQueue;
private readonly Queue<DelayedSignal> signalQueue;
private DelayedSignal prevQueuedSignal;
@@ -37,7 +38,7 @@ namespace Barotrauma.Items.Components
if (value == delay) { return; }
delay = value;
delayTicks = (int)(delay / Timing.Step);
signalQueueSize = delayTicks * 2;
signalQueueSize = Math.Max(delayTicks, 1) * 2;
}
}
@@ -74,7 +75,14 @@ namespace Barotrauma.Items.Components
var signalOut = signalQueue.Peek();
signalOut.SendDuration -= 1;
item.SendSignal(new Signal(signalOut.Signal.value, strength: signalOut.Signal.strength), "signal_out");
if (signalOut.SendDuration <= 0) { signalQueue.Dequeue(); } else { break; }
if (signalOut.SendDuration <= 0)
{
signalQueue.Dequeue();
}
else
{
break;
}
}
}
@@ -27,7 +27,7 @@ namespace Barotrauma.Items.Components
return retVal;
}
public static bool operator==(Signal a, Signal b) =>
public static bool operator ==(Signal a, Signal b) =>
a.value == b.value &&
a.stepsTaken == b.stepsTaken &&
a.sender == b.sender &&
@@ -35,6 +35,6 @@ namespace Barotrauma.Items.Components
MathUtils.NearlyEqual(a.power, b.power) &&
MathUtils.NearlyEqual(a.strength, b.strength);
public static bool operator!=(Signal a, Signal b) => !(a == b);
public static bool operator !=(Signal a, Signal b) => !(a == b);
}
}
@@ -77,11 +77,10 @@ namespace Barotrauma.Items.Components
//item in water -> we definitely want to send the True output
isInWater = true;
}
else if (item.CurrentHull != null)
else if (item.CurrentHull != null && item.CurrentHull.WaterPercentage > 0.0f)
{
//item in not water -> check if there's water anywhere within the rect of the item
if (item.CurrentHull.Surface > item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height + 1 &&
item.CurrentHull.Surface > item.Rect.Y - item.Rect.Height)
//(center of the) item in not water -> check if the water surface is below the bottom of the item's rect
if (item.CurrentHull.Surface > item.Rect.Y - item.Rect.Height)
{
isInWater = true;
}
@@ -22,7 +22,9 @@ namespace Barotrauma.Items.Components
private string prevSignal;
private int[] channelMemory = new int[ChannelMemorySize];
private readonly int[] channelMemory = new int[ChannelMemorySize];
private Connection signalOutConnection;
[Serialize(CharacterTeamType.None, true, description: "WiFi components can only communicate with components that have the same Team ID.", alwaysUseInstanceValues: true)]
public CharacterTeamType TeamID { get; set; }
@@ -93,6 +95,10 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
if (item.Connections != null)
{
signalOutConnection = item.Connections.Find(c => c.Name == "signal_out");
}
if (channelMemory.All(m => m == 0))
{
for (int i = 0; i < channelMemory.Length; i++)
@@ -155,6 +161,10 @@ namespace Barotrauma.Items.Components
public void TransmitSignal(Signal signal, bool sentFromChat)
{
if (sentFromChat)
{
item.LastSentSignalRecipients.Clear();
}
var senderComponent = signal.source?.GetComponent<WifiComponent>();
if (senderComponent != null && !CanReceive(senderComponent)) { return; }
@@ -168,10 +178,14 @@ namespace Barotrauma.Items.Components
//signal strength diminishes by distance
float sentSignalStrength = signal.strength *
MathHelper.Clamp(1.0f - (Vector2.Distance(item.WorldPosition, wifiComp.item.WorldPosition) / wifiComp.range), 0.0f, 1.0f);
Signal s = new Signal(signal.value, signal.stepsTaken, sender: signal.sender, source: signal.source,
Signal s = new Signal(signal.value, ++signal.stepsTaken, sender: signal.sender, source: signal.source,
power: 0.0f, strength: sentSignalStrength);
wifiComp.item.SendSignal(s, "signal_out");
if (wifiComp.signalOutConnection != null)
{
wifiComp.item.SendSignal(s, wifiComp.signalOutConnection);
}
if (signal.source != null)
{
foreach (Connection receiver in wifiComp.item.LastSentSignalRecipients)
@@ -844,10 +844,11 @@ namespace Barotrauma.Items.Components
ClearConnections();
base.RemoveComponentSpecific();
#if CLIENT
if (DraggingWire == this) { draggingWire = null; }
overrideSprite?.Remove();
overrideSprite = null;
wireSprite = null;
#endif
}
}
}
}