Unstable 0.17.2.0

This commit is contained in:
Markus Isberg
2022-03-30 00:06:59 +09:00
parent 4206f6db42
commit 2968e23ae8
100 changed files with 654 additions and 1379 deletions
@@ -1,4 +1,5 @@
using System;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
#if CLIENT
@@ -150,6 +151,20 @@ namespace Barotrauma.Items.Components
}
set
{
if (powerIn != null)
{
if (powerIn.Grid != null)
{
powerIn.Grid.Voltage = Math.Max(0.0f, value);
}
}
else if (powerOut != null)
{
if (powerOut.Grid != null)
{
powerOut.Grid.Voltage = Math.Max(0.0f, value);
}
}
voltage = Math.Max(0.0f, value);
}
}
@@ -198,6 +213,11 @@ namespace Barotrauma.Items.Components
powerOnSoundPlayed = false;
}
#endif
if (powerIn == null)
{
//power down the device here if it has no power connection (= receives power from contained battery cells instead of the "normal" power logic)
Voltage -= deltaTime;
}
}
public override void Update(float deltaTime, Camera cam)
@@ -450,11 +470,6 @@ namespace Barotrauma.Items.Components
//Determine if devices are adding a load or providing power, also resolve solo nodes
foreach (Powered powered in poweredList)
{
//Make voltage decay to ensure the device powers down.
//This only effects devices with no power input (whose voltage is set by other means, e.g. status effects from a contained battery)
//or devices that have been disconnected from the power grid - other devices use the voltage of the grid instead.
powered.Voltage -= deltaTime;
//Handle the device if it's got a power connection
if (powered.powerIn != null && powered.powerOut != powered.powerIn)
{
@@ -485,7 +500,7 @@ namespace Barotrauma.Items.Components
}
else
{
powered.CurrPowerConsumption = -powered.GetConnectionPowerOut(powered.powerIn, 0, powered.MinMaxPowerOut(powered.powerIn, 0), 0);
powered.CurrPowerConsumption = powered.GetConnectionPowerOut(powered.powerIn, 0, powered.MinMaxPowerOut(powered.powerIn, 0), 0);
powered.GridResolved(powered.powerIn);
}
}
@@ -526,7 +541,7 @@ namespace Barotrauma.Items.Components
else
{
//Perform power calculations for the singular connection
float loadOut = -powered.GetConnectionPowerOut(powered.powerOut, 0, powered.MinMaxPowerOut(powered.powerOut, 0), 0);
float loadOut = powered.GetConnectionPowerOut(powered.powerOut, 0, powered.MinMaxPowerOut(powered.powerOut, 0), 0);
if (powered is PowerTransfer pt2)
{
pt2.PowerLoad = loadOut;
@@ -652,7 +667,7 @@ namespace Barotrauma.Items.Components
public static bool ValidPowerConnection(Connection conn1, Connection conn2)
{
return conn1.IsPower && conn2.IsPower && (conn1.Item.HasTag("junctionbox") || conn2.Item.HasTag("junctionbox") || conn1.Item.HasTag("dock") || conn2.Item.HasTag("dock") || conn1.IsOutput != conn2.IsOutput);
return conn1.IsPower && conn2.IsPower && (conn1.Item.HasTag("junctionbox") || conn2.Item.HasTag("junctionbox") || conn1.IsOutput != conn2.IsOutput || (conn1.Item.HasTag("dock") && conn2.Item.HasTag("dock")));
}
/// <summary>