Unstable v0.1300.0.1

This commit is contained in:
Markus Isberg
2021-03-05 17:00:56 +02:00
parent 64cdb32078
commit cb969c959f
199 changed files with 6043 additions and 3911 deletions
@@ -154,7 +154,7 @@ namespace Barotrauma.Items.Components
var prevDockingTarget = DockingTarget;
Undock(applyEffects: false);
Dock(prevDockingTarget);
Lock(true, applyEffects: false);
Lock(isNetworkMessage: true, applyEffects: false);
}
}
@@ -240,7 +240,7 @@ namespace Barotrauma.Items.Components
}
public void Lock(bool isNetworkMessage, bool forcePosition = false, bool applyEffects = true)
public void Lock(bool isNetworkMessage, bool applyEffects = true)
{
#if CLIENT
if (GameMain.Client != null && !isNetworkMessage) { return; }
@@ -262,20 +262,17 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnUse, 1.0f);
}
if (forcePosition)
Vector2 jointDiff = joint.WorldAnchorB - joint.WorldAnchorA;
if (item.Submarine.PhysicsBody.Mass < DockingTarget.item.Submarine.PhysicsBody.Mass ||
DockingTarget.item.Submarine.Info.IsOutpost)
{
Vector2 jointDiff = joint.WorldAnchorB - joint.WorldAnchorA;
if (item.Submarine.PhysicsBody.Mass < DockingTarget.item.Submarine.PhysicsBody.Mass ||
DockingTarget.item.Submarine.Info.IsOutpost)
{
item.Submarine.SubBody.SetPosition(item.Submarine.SubBody.Position + ConvertUnits.ToDisplayUnits(jointDiff));
}
else if (DockingTarget.item.Submarine.PhysicsBody.Mass < item.Submarine.PhysicsBody.Mass ||
item.Submarine.Info.IsOutpost)
{
DockingTarget.item.Submarine.SubBody.SetPosition(DockingTarget.item.Submarine.SubBody.Position - ConvertUnits.ToDisplayUnits(jointDiff));
}
item.Submarine.SubBody.SetPosition(item.Submarine.SubBody.Position + ConvertUnits.ToDisplayUnits(jointDiff));
}
else if (DockingTarget.item.Submarine.PhysicsBody.Mass < item.Submarine.PhysicsBody.Mass ||
item.Submarine.Info.IsOutpost)
{
DockingTarget.item.Submarine.SubBody.SetPosition(DockingTarget.item.Submarine.SubBody.Position - ConvertUnits.ToDisplayUnits(jointDiff));
}
ConnectWireBetweenPorts();
CreateJoint(true);
@@ -988,7 +985,7 @@ namespace Barotrauma.Items.Components
}
else
{
Lock(isNetworkMessage: false, forcePosition: true);
Lock(isNetworkMessage: false);
}
}
else
@@ -305,9 +305,21 @@ namespace Barotrauma.Items.Components
private void ToggleState(ActionType actionType, Character user)
{
if (toggleCooldownTimer > 0.0f && user != lastUser) { OnFailedToOpen(); return; }
if (toggleCooldownTimer > 0.0f && user != lastUser)
{
OnFailedToOpen();
return;
}
toggleCooldownTimer = ToggleCoolDown;
if (IsStuck || IsJammed) { toggleCooldownTimer = 1.0f; OnFailedToOpen(); return; }
if (IsStuck || IsJammed)
{
#if CLIENT
if (IsStuck) { HintManager.OnTryOpenStuckDoor(user); }
#endif
toggleCooldownTimer = 1.0f;
OnFailedToOpen();
return;
}
lastUser = user;
SetState(PredictedState == null ? !isOpen : !PredictedState.Value, false, true, forcedOpen: actionType == ActionType.OnPicked);
}
@@ -12,7 +12,8 @@ namespace Barotrauma.Items.Components
{
partial class RangedWeapon : ItemComponent
{
private float reload, reloadTimer;
private float reload;
public float ReloadTimer { get; private set; }
private Vector2 barrelPos;
@@ -75,17 +76,17 @@ namespace Barotrauma.Items.Components
public override void Equip(Character character)
{
reloadTimer = Math.Min(reload, 1.0f);
ReloadTimer = Math.Min(reload, 1.0f);
IsActive = true;
}
public override void Update(float deltaTime, Camera cam)
{
reloadTimer -= deltaTime;
ReloadTimer -= deltaTime;
if (reloadTimer < 0.0f)
if (ReloadTimer < 0.0f)
{
reloadTimer = 0.0f;
ReloadTimer = 0.0f;
IsActive = false;
}
}
@@ -101,10 +102,10 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null || character.Removed) { return false; }
if ((item.RequireAimToUse && !character.IsKeyDown(InputType.Aim)) || reloadTimer > 0.0f) { return false; }
if ((item.RequireAimToUse && !character.IsKeyDown(InputType.Aim)) || ReloadTimer > 0.0f) { return false; }
IsActive = true;
reloadTimer = reload;
ReloadTimer = reload;
if (item.AiTarget != null)
{
@@ -854,9 +854,11 @@ namespace Barotrauma.Items.Components
object value = property.GetValue(target);
if (door.Stuck > 0)
{
bool isCutting = effect.propertyEffects[i].GetType() == typeof(float) && (float)effect.propertyEffects[i] < 0;
var progressBar = user.UpdateHUDProgressBar(door, door.Item.WorldPosition, door.Stuck / 100, Color.DarkGray * 0.5f, Color.White,
effect.propertyEffects[i].GetType() == typeof(float) && (float)effect.propertyEffects[i] < 0 ? "progressbar.cutting" : "progressbar.welding");
textTag: isCutting ? "progressbar.cutting" : "progressbar.welding");
if (progressBar != null) { progressBar.Size = new Vector2(60.0f, 20.0f); }
if (!isCutting) { HintManager.OnWeldingDoor(user); }
}
}
}
@@ -771,6 +771,10 @@ namespace Barotrauma.Items.Components
brokenEffects.ForEach(e => e.SetUser(user));
}
}
#if CLIENT
HintManager.OnStatusEffectApplied(this, type, character);
#endif
}
public virtual void Load(XElement componentElement, bool usePrefabValues, IdRemap idRemap)
@@ -212,6 +212,7 @@ namespace Barotrauma.Items.Components
progressState = 0.0f;
timeUntilReady = 0.0f;
UpdateRequiredTimeProjSpecific();
inputContainer.Inventory.Locked = false;
outputContainer.Inventory.Locked = false;
@@ -279,6 +280,7 @@ namespace Barotrauma.Items.Components
if (powerConsumption <= 0) { Voltage = 1.0f; }
timeUntilReady -= deltaTime * Math.Min(Voltage, 1.0f);
UpdateRequiredTimeProjSpecific();
if (timeUntilReady > 0.0f) { return; }
@@ -360,6 +362,8 @@ namespace Barotrauma.Items.Components
}
}
partial void UpdateRequiredTimeProjSpecific();
private bool CanBeFabricated(FabricationRecipe fabricableItem)
{
if (fabricableItem == null) { return false; }
@@ -221,6 +221,13 @@ namespace Barotrauma.Items.Components
}
}
#if CLIENT
if(PowerOn && AvailableFuel < 1)
{
HintManager.OnReactorOutOfFuel(this);
}
#endif
prevAvailableFuel = AvailableFuel;
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam)
{
currPowerConsumption = powerConsumption;
currPowerConsumption = (currentMode == Mode.Active) ? powerConsumption : powerConsumption * 0.1f;
UpdateOnActiveEffects(deltaTime);
@@ -22,6 +22,11 @@ namespace Barotrauma.Items.Components
private const float AutoPilotMaxSpeed = 0.5f;
private const float AIPilotMaxSpeed = 1.0f;
/// <summary>
/// How fast the steering vector adjusts when the nav terminal is operated by something else than a character (= signals)
/// </summary>
const float DefaultSteeringAdjustSpeed = 0.2f;
private Vector2 targetVelocity;
private Vector2 steeringInput;
@@ -543,6 +548,10 @@ namespace Barotrauma.Items.Components
{
TargetVelocity *= 100.0f / velMagnitude;
}
#if CLIENT
HintManager.OnAutoPilotPathUpdated(this);
#endif
}
private float? GetNodePenalty(PathNode node, PathNode nextNode)
@@ -700,7 +709,10 @@ namespace Barotrauma.Items.Components
{
if (connection.Name == "velocity_in")
{
TargetVelocity = XMLExtensions.ParseVector2(signal, errorMessages: false);
steeringAdjustSpeed = DefaultSteeringAdjustSpeed;
steeringInput = XMLExtensions.ParseVector2(signal, errorMessages: false);
steeringInput.X = MathHelper.Clamp(steeringInput.X, -100.0f, 100.0f);
steeringInput.Y = MathHelper.Clamp(steeringInput.Y, -100.0f, 100.0f);
}
else
{
@@ -4,7 +4,7 @@ using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class AndComponent : ItemComponent
{
{
protected string output, falseOutput;
//an array to keep track of how long ago a non-zero signal was received on both inputs
@@ -27,14 +27,41 @@ namespace Barotrauma.Items.Components
public string Output
{
get { return output; }
set { output = value; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
[InGameEditable, Serialize("", true, description: "The signal sent when the condition is met (if empty, no signal is sent).", alwaysUseInstanceValues: true)]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
public AndComponent(Item item, XElement element)
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
namespace Barotrauma.Items.Components
{
@@ -10,6 +11,9 @@ namespace Barotrauma.Items.Components
private string output = "0,0,0,0";
[InGameEditable, Serialize(false, true, description: "When enabled makes the component translate the signal from HSV into RGB where red is the hue between 0 and 360, green is the saturation between 0 and 1 and blue is the value between 0 and 1.", alwaysUseInstanceValues: true)]
public bool UseHSV { get; set; }
public ColorComponent(Item item, XElement element)
: base(item, element)
{
@@ -24,10 +28,23 @@ namespace Barotrauma.Items.Components
private void UpdateOutput()
{
output = receivedSignal[0].ToString("G", CultureInfo.InvariantCulture);
output += "," + receivedSignal[1].ToString("G", CultureInfo.InvariantCulture);
output += "," + receivedSignal[2].ToString("G", CultureInfo.InvariantCulture);
output += "," + receivedSignal[3].ToString("G", CultureInfo.InvariantCulture);
float signalR = receivedSignal[0],
signalG = receivedSignal[1],
signalB = receivedSignal[2],
signalA = receivedSignal[3];
if (UseHSV)
{
Color hsvColor = ToolBox.HSVToRGB(signalR, signalG, signalB);
signalR = hsvColor.R / (float) byte.MaxValue;
signalG = hsvColor.G / (float) byte.MaxValue;
signalB = hsvColor.B / (float) byte.MaxValue;
}
output = signalR.ToString("G", CultureInfo.InvariantCulture);
output += "," + signalG.ToString("G", CultureInfo.InvariantCulture);
output += "," + signalB.ToString("G", CultureInfo.InvariantCulture);
output += "," + signalA.ToString("G", CultureInfo.InvariantCulture);
}
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f, float signalStrength = 1.0f)
@@ -15,18 +15,45 @@ namespace Barotrauma.Items.Components
//the output is sent if both inputs have received a signal within the timeframe
protected float timeFrame;
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the condition is met.", alwaysUseInstanceValues: true)]
[InGameEditable, Serialize("1", true, description: "The signal sent when the condition is met.", alwaysUseInstanceValues: true)]
public string Output
{
get { return output; }
set { output = value; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
[InGameEditable, Serialize("", true, description: "The signal this item outputs when the condition is not met.", alwaysUseInstanceValues: true)]
[InGameEditable, Serialize("", true, description: "The signal sent when the condition is met (if empty, no signal is sent).", alwaysUseInstanceValues: true)]
public string FalseOutput
{
get { return falseOutput; }
set { falseOutput = value; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
[InGameEditable(DecimalCount = 2), Serialize(0.0f, true, description: "The maximum amount of time between the received signals. If set to 0, the signals must be received at the same time.", alwaysUseInstanceValues: true)]
@@ -74,11 +74,48 @@ namespace Barotrauma.Items.Components
}
}
private string output;
[InGameEditable, Serialize("1", true, description: "The signal the item outputs when it has detected movement.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
public string Output
{
get { return output; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
private string falseOutput;
[InGameEditable, Serialize("", true, description: "The signal the item outputs when it has not detected movement.", alwaysUseInstanceValues: true)]
public string FalseOutput { get; set; }
public string FalseOutput
{
get { return falseOutput; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
[Editable(DecimalCount = 3), Serialize(0.01f, true, description: "How fast the objects within the detector's range have to be moving (in m/s).", alwaysUseInstanceValues: true)]
public float MinimumVelocity
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using System;
using System.Text.RegularExpressions;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -17,8 +18,22 @@ namespace Barotrauma.Items.Components
private bool nonContinuousOutputSent;
private string output;
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signal matches the regular expression.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
public string Output
{
get { return output; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
[InGameEditable, Serialize(false, true, description: "Should the component output a value of a capture group instead of a constant signal.", alwaysUseInstanceValues: true)]
public bool UseCaptureGroup { get; set; }
@@ -52,6 +67,17 @@ namespace Barotrauma.Items.Components
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output string. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
public RegExFindComponent(Item item, XElement element)
: base(item, element)
{
@@ -1,17 +1,56 @@
using System.Xml.Linq;
using System;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class SignalCheckComponent : ItemComponent
{
private string output;
[InGameEditable, Serialize("1", true, description: "The signal this item outputs when the received signal matches the target signal.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
public string Output
{
get { return output; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
private string falseOutput;
[InGameEditable, Serialize("0", true, description: "The signal this item outputs when the received signal does not match the target signal.", alwaysUseInstanceValues: true)]
public string FalseOutput { get; set; }
public string FalseOutput
{
get { return falseOutput; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
[InGameEditable, Serialize("", true, description: "The value to compare the received signals against.", alwaysUseInstanceValues: true)]
public string TargetSignal { get; set; }
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
public SignalCheckComponent(Item item, XElement element)
: base(item, element)
{
@@ -1,4 +1,5 @@
using System.Xml.Linq;
using System;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
@@ -9,11 +10,48 @@ namespace Barotrauma.Items.Components
private bool fireInRange;
[InGameEditable, Serialize("1", true, description: "The signal the item outputs when it has detected movement.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
private string output;
[InGameEditable, Serialize("1", true, description: "The signal the item outputs when it has detected a fire.", alwaysUseInstanceValues: true)]
public string Output
{
get { return output; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
[InGameEditable, Serialize("0", true, description: "The signal the item outputs when it has not detected movement.", alwaysUseInstanceValues: true)]
public string FalseOutput { get; set; }
private string falseOutput;
[InGameEditable, Serialize("0", true, description: "The signal the item outputs when it has not detected a fire.", alwaysUseInstanceValues: true)]
public string FalseOutput
{
get { return falseOutput; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
public SmokeDetector(Item item, XElement element)
: base(item, element)
@@ -12,11 +12,48 @@ namespace Barotrauma.Items.Components
private bool isInWater;
private float stateSwitchDelay;
private string output;
[InGameEditable, Serialize("1", true, description: "The signal the item sends out when it's underwater.", alwaysUseInstanceValues: true)]
public string Output { get; set; }
public string Output
{
get { return output; }
set
{
if (value == null) { return; }
output = value;
if (output.Length > MaxOutputLength)
{
output = output.Substring(0, MaxOutputLength);
}
}
}
private string falseOutput;
[InGameEditable, Serialize("0", true, description: "The signal the item sends out when it's not underwater.", alwaysUseInstanceValues: true)]
public string FalseOutput { get; set; }
public string FalseOutput
{
get { return falseOutput; }
set
{
if (value == null) { return; }
falseOutput = value;
if (falseOutput.Length > MaxOutputLength)
{
falseOutput = falseOutput.Substring(0, MaxOutputLength);
}
}
}
private int maxOutputLength;
[Editable, Serialize(200, false, description: "The maximum length of the output strings. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxOutputLength
{
get { return maxOutputLength; }
set
{
maxOutputLength = Math.Max(value, 0);
}
}
public WaterDetector(Item item, XElement element)
: base(item, element)
@@ -767,7 +767,6 @@ namespace Barotrauma.Items.Components
TryLaunch(deltaTime, ignorePower: true);
}
private bool outOfAmmo;
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
if (character.AIController.SelectedAiTarget?.Entity is Character previousTarget &&
@@ -834,7 +833,7 @@ namespace Barotrauma.Items.Components
}
if (container == null || container.ContainableItems.Count == 0)
{
if (!outOfAmmo && character.IsOnPlayerTeam)
if (character.IsOnPlayerTeam)
{
character.Speak(TextManager.GetWithVariable("DialogCannotLoadTurret", "[itemname]", item.Name, true), null, 0.0f, "cannotloadturret", 30.0f);
}
@@ -850,7 +849,7 @@ namespace Barotrauma.Items.Components
}
loadItemsObjective.Abandoned += CheckRemainingAmmo;
loadItemsObjective.Completed += CheckRemainingAmmo;
return outOfAmmo;
return false;
void CheckRemainingAmmo()
{
@@ -1203,8 +1202,7 @@ namespace Barotrauma.Items.Components
resetUserTimer = 10.0f;
break;
case "trigger_in":
if (signal == "0") { return; }
lightComponent.IsOn = !lightComponent.IsOn;
if (signal == "0") { return; }
item.Use((float)Timing.Step, sender);
user = sender;
resetUserTimer = 10.0f;