Unstable 1.8.4.0
This commit is contained in:
@@ -87,7 +87,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Math.Abs(charge - lastSentCharge) / adjustedCapacity > 0.05f)
|
||||
{
|
||||
#if SERVER
|
||||
if (GameMain.Server != null && (!item.Submarine?.Loading ?? true)) { item.CreateServerEvent(this); }
|
||||
if (GameMain.Server != null && item.FullyInitialized) { item.CreateServerEvent(this); }
|
||||
#endif
|
||||
lastSentCharge = charge;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -231,7 +232,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
float maxOverVoltage = Math.Max(OverloadVoltage, 1.0f);
|
||||
|
||||
Overload = Voltage > maxOverVoltage;
|
||||
Overload = Voltage > maxOverVoltage && GameMain.GameSession is not { RoundDuration: < 5 };
|
||||
|
||||
if (Overload && (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer))
|
||||
{
|
||||
@@ -378,14 +379,30 @@ namespace Barotrauma.Items.Components
|
||||
foreach (Connection c in item.Connections)
|
||||
{
|
||||
connectionDirty[c] = true;
|
||||
if (c.IsPower)
|
||||
{
|
||||
ChangedConnections.Add(c);
|
||||
if (connectedRecipients.TryGetValue(c, out var recipients))
|
||||
{
|
||||
recipients.Where(c => c.IsPower).ForEach(c => ChangedConnections.Add(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetConnectionDirty(Connection connection)
|
||||
{
|
||||
var connections = item.Connections;
|
||||
if (connections == null || !connections.Contains(connection)) return;
|
||||
if (connections == null || !connections.Contains(connection)) { return; }
|
||||
connectionDirty[connection] = true;
|
||||
if (connection.IsPower)
|
||||
{
|
||||
ChangedConnections.Add(connection);
|
||||
if (connectedRecipients.TryGetValue(connection, out var recipients))
|
||||
{
|
||||
recipients.Where(c => c.IsPower).ForEach(c => ChangedConnections.Add(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
|
||||
@@ -157,6 +157,13 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (powerOut?.Grid != null) { return powerOut.Grid.Voltage; }
|
||||
}
|
||||
|
||||
if (this is PowerTransfer && item.Condition <= 0.0f)
|
||||
{
|
||||
//if the junction box or other power transfer device is broken,
|
||||
//it cannot be supplying any power (voltage = 0)
|
||||
return 0.0f;
|
||||
}
|
||||
return PowerConsumption <= 0.0f ? 1.0f : voltage;
|
||||
}
|
||||
set
|
||||
@@ -170,6 +177,8 @@ namespace Barotrauma.Items.Components
|
||||
/// Can be used by status effects or sounds to check if the item has enough power to run
|
||||
/// </summary>
|
||||
public float RelativeVoltage => minVoltage <= 0.0f ? 1.0f : MathHelper.Clamp(Voltage / minVoltage, 0.0f, 1.0f);
|
||||
|
||||
public virtual bool HasPower => Voltage >= MinVoltage;
|
||||
|
||||
public bool PoweredByTinkering { get; set; }
|
||||
|
||||
@@ -208,7 +217,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (!powerOnSoundPlayed && powerOnSound != null)
|
||||
{
|
||||
SoundPlayer.PlaySound(powerOnSound.Sound, item.WorldPosition, powerOnSound.Volume, powerOnSound.Range, hullGuess: item.CurrentHull, ignoreMuffling: powerOnSound.IgnoreMuffling, freqMult: powerOnSound.GetRandomFrequencyMultiplier());
|
||||
SoundPlayer.PlaySound(powerOnSound, item.WorldPosition, hullGuess: item.CurrentHull);
|
||||
powerOnSoundPlayed = true;
|
||||
}
|
||||
}
|
||||
@@ -668,6 +677,8 @@ namespace Barotrauma.Items.Components
|
||||
return
|
||||
conn1.IsPower && conn2.IsPower &&
|
||||
conn1.Item.Condition > 0.0f && conn2.Item.Condition > 0.0f &&
|
||||
conn1.Item.GetComponent<PowerTransfer>() is not { CanTransfer: false } &&
|
||||
conn2.Item.GetComponent<PowerTransfer>() is not { CanTransfer: false } &&
|
||||
(conn1.Item.HasTag(Tags.JunctionBox) || conn2.Item.HasTag(Tags.JunctionBox) || conn1.Item.HasTag(Tags.DockingPort) || conn2.Item.HasTag(Tags.DockingPort) || conn1.IsOutput != conn2.IsOutput);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user