Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -27,7 +27,7 @@ namespace Barotrauma.Items.Components
public Character User;
[Editable(0.0f, 10000000.0f),
Serialize(500.0f, true, description: "The amount of force exerted on the submarine when the engine is operating at full power.")]
Serialize(500.0f, IsPropertySaveable.Yes, description: "The amount of force exerted on the submarine when the engine is operating at full power.")]
public float MaxForce
{
get { return maxForce; }
@@ -37,7 +37,7 @@ namespace Barotrauma.Items.Components
}
}
[Editable, Serialize("0.0,0.0", true,
[Editable, Serialize("0.0,0.0", IsPropertySaveable.Yes,
description: "The position of the propeller as an offset from the item's center (in pixels)."+
" Determines where the particles spawn and the position that causes characters to take damage from the engine if the PropellerDamage is defined.")]
public Vector2 PropellerPos
@@ -46,7 +46,7 @@ namespace Barotrauma.Items.Components
set;
}
[Editable, Serialize(false, true)]
[Editable, Serialize(false, IsPropertySaveable.Yes)]
public bool DisablePropellerDamage
{
get;
@@ -75,12 +75,12 @@ namespace Barotrauma.Items.Components
private const float TinkeringForceIncrease = 1.5f;
public Engine(Item item, XElement element)
public Engine(Item item, ContentXElement element)
: base(item, element)
{
IsActive = true;
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -93,7 +93,7 @@ namespace Barotrauma.Items.Components
InitProjSpecific(element);
}
partial void InitProjSpecific(XElement element);
partial void InitProjSpecific(ContentXElement element);
public override void Update(float deltaTime, Camera cam)
{
@@ -103,14 +103,16 @@ namespace Barotrauma.Items.Components
controlLockTimer -= deltaTime;
currPowerConsumption = Math.Abs(targetForce) / 100.0f * powerConsumption;
//engines consume more power when in a bad condition
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
if (powerConsumption == 0.0f)
{
prevVoltage = 1;
hasPower = true;
}
else
{
hasPower = Voltage > MinVoltage;
}
if (powerConsumption == 0.0f) { Voltage = 1.0f; }
prevVoltage = Voltage;
hasPower = Voltage > MinVoltage;
Force = MathHelper.Lerp(force, (Voltage < MinVoltage) ? 0.0f : targetForce, deltaTime * 10.0f);
if (Math.Abs(Force) > 1.0f)
@@ -154,6 +156,33 @@ namespace Barotrauma.Items.Components
}
}
/// <summary>
/// Power consumption of the engine. Only consume power when active and adjust consumption based on condition and target force.
/// </summary>
public override float GetCurrentPowerConsumption(Connection connection = null)
{
if (connection != this.powerIn)
{
return 0;
}
currPowerConsumption = Math.Abs(targetForce) / 100.0f * powerConsumption;
//engines consume more power when in a bad condition
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
return currPowerConsumption;
}
/// <summary>
/// When grid is resolved update the previous voltage
/// </summary>
public override void GridResolved(Connection connection)
{
if (connection == powerIn)
{
prevVoltage = Voltage;
}
}
private void UpdateAITargets(float noise)
{
if (item.AiTarget != null)