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
@@ -78,7 +78,7 @@ namespace Barotrauma.Items.Components
get { return connectedTransducers.Select(t => t.Transducer); }
}
[Serialize(DefaultSonarRange, false, description: "The maximum range of the sonar.")]
[Serialize(DefaultSonarRange, IsPropertySaveable.No, description: "The maximum range of the sonar.")]
public float Range
{
get { return range; }
@@ -92,29 +92,29 @@ namespace Barotrauma.Items.Components
}
}
[Serialize(false, false, description: "Should the sonar display the walls of the submarine it is inside.")]
[Serialize(false, IsPropertySaveable.No, description: "Should the sonar display the walls of the submarine it is inside.")]
public bool DetectSubmarineWalls
{
get;
set;
}
[Editable, Serialize(false, false, description: "Does the sonar have to be connected to external transducers to work.")]
[Editable, Serialize(false, IsPropertySaveable.No, description: "Does the sonar have to be connected to external transducers to work.")]
public bool UseTransducers
{
get;
set;
}
[Editable, Serialize(false, false, description: "Should the sonar view be centered on the transducers or the submarine's center of mass. Only has an effect if UseTransducers is enabled.")]
[Editable, Serialize(false, IsPropertySaveable.No, description: "Should the sonar view be centered on the transducers or the submarine's center of mass. Only has an effect if UseTransducers is enabled.")]
public bool CenterOnTransducers
{
get;
set;
}
[Editable, Serialize(false, false, description: "Does the sonar have mineral scanning mode. " +
"Only available in-game when the Item has no Steering component.")]
[Editable, Serialize(false, IsPropertySaveable.No, description: "Does the sonar have mineral scanning mode. " +
"Only available in-game when the Item has no Steering component.")]
public bool HasMineralScanner { get; set; }
public float Zoom
@@ -146,7 +146,7 @@ namespace Barotrauma.Items.Components
public override bool RecreateGUIOnResolutionChange => true;
public Sonar(Item item, XElement element)
public Sonar(Item item, ContentXElement element)
: base(item, element)
{
connectedTransducers = new List<ConnectedTransducer>();
@@ -155,12 +155,10 @@ namespace Barotrauma.Items.Components
CurrentMode = Mode.Passive;
}
partial void InitProjSpecific(XElement element);
partial void InitProjSpecific(ContentXElement element);
public override void Update(float deltaTime, Camera cam)
{
currPowerConsumption = (currentMode == Mode.Active) ? powerConsumption : powerConsumption * PassivePowerConsumption;
UpdateOnActiveEffects(deltaTime);
if (UseTransducers)
@@ -240,8 +238,19 @@ namespace Barotrauma.Items.Components
++pingIndex;
}
}
}
Voltage -= deltaTime;
/// <summary>
/// Power consumption of the sonar. Only consume power when active and adjust the consumption based on the sonar mode.
/// </summary>
public override float GetCurrentPowerConsumption(Connection connection = null)
{
if (connection != powerIn || !IsActive)
{
return 0;
}
return (currentMode == Mode.Active) ? powerConsumption : powerConsumption * PassivePowerConsumption;
}
public override bool Use(float deltaTime, Character character = null)
@@ -266,7 +275,8 @@ namespace Barotrauma.Items.Components
if (DetectSubmarineWalls && c.AnimController.CurrentHull == null && item.CurrentHull != null) { continue; }
if (Vector2.DistanceSquared(c.WorldPosition, item.WorldPosition) > range * range) { continue; }
string directionName = GetDirectionName(c.WorldPosition - item.WorldPosition);
#warning This is not the best key for a dictionary.
string directionName = GetDirectionName(c.WorldPosition - item.WorldPosition).Value;
if (!targetGroups.ContainsKey(directionName))
{
targetGroups.Add(directionName, new List<Character>());
@@ -289,9 +299,10 @@ namespace Barotrauma.Items.Components
if (character.IsOnPlayerTeam)
{
character.Speak(TextManager.GetWithVariables(dialogTag, new string[2] { "[direction]", "[count]" },
new string[2] { targetGroup.Key.ToString(), targetGroup.Value.Count.ToString() },
new bool[2] { true, false }), null, 0, "sonartarget" + targetGroup.Value[0].ID, 60);
character.Speak(TextManager.GetWithVariables(dialogTag,
("[direction]", targetGroup.Key.ToString(), FormatCapitals.Yes),
("[count]", targetGroup.Value.Count.ToString(), FormatCapitals.No)).Value,
null, 0, $"sonartarget{targetGroup.Value[0].ID}".ToIdentifier(), 60);
}
//prevent the character from reporting other targets in the group
@@ -304,7 +315,7 @@ namespace Barotrauma.Items.Components
return true;
}
private string GetDirectionName(Vector2 dir)
private LocalizedString GetDirectionName(Vector2 dir)
{
float angle = MathUtils.WrapAngleTwoPi((float)-Math.Atan2(dir.Y, dir.X) + MathHelper.PiOver2);