Merge branch 'master' into new-netcode
Conflicts: Subsurface/Source/Characters/AI/EnemyAIController.cs Subsurface/Source/DebugConsole.cs Subsurface/Source/Items/Components/Machines/Radar.cs Subsurface/Source/Items/Item.cs
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
<!-- spike/tentacle thingy -->
|
<!-- spike/tentacle thingy -->
|
||||||
<limb id = "13" width="10" height="30" mass = "6" attackpriority="2" flip="true" pullpos="0.0,25.0">
|
<limb id = "13" width="10" height="30" mass = "6" attackpriority="2" flip="true" pullpos="0.0,25.0">
|
||||||
<sprite texture="Content/Characters/Husk/DivingSuit.png" sourcerect="110,76,18,52" depth="0.05" origin="0.5,0.5"/>
|
<sprite texture="Content/Characters/Husk/DivingSuit.png" sourcerect="110,76,18,52" depth="0.05" origin="0.5,0.5"/>
|
||||||
<attack range="70" duration="0.2" bleedingdamage="0.5" damage="10" stun="0.5" torque="-50" damagetype="slash" targetforce="10">
|
<attack range="70" duration="0.2" bleedingdamage="0.5" damage="10" stun="0.5" force="1" torque="-50" damagetype="slash" targetforce="10">
|
||||||
<StatusEffect type="OnUse" target="Character" HuskInfectionState="0.01" disabledeltatime="true"/>
|
<StatusEffect type="OnUse" target="Character" HuskInfectionState="0.01" disabledeltatime="true"/>
|
||||||
<StatusEffect type="OnUse" target="This" Health="1.0" disabledeltatime="true"/>
|
<StatusEffect type="OnUse" target="This" Health="1.0" disabledeltatime="true"/>
|
||||||
</attack>
|
</attack>
|
||||||
@@ -110,6 +110,6 @@
|
|||||||
|
|
||||||
<ai attackhumans="500" attackrooms="5.0" attackweaker="50" attackstronger="-30"
|
<ai attackhumans="500" attackrooms="5.0" attackweaker="50" attackstronger="-30"
|
||||||
sight="0.5" hearing="1.0"
|
sight="0.5" hearing="1.0"
|
||||||
attackcooldown="5.0"/>
|
attackcooldown="1.0"/>
|
||||||
</Character>
|
</Character>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
class EnemyAIController : AIController
|
class EnemyAIController : AIController
|
||||||
{
|
{
|
||||||
private const float UpdateTargetsInterval = 5.0f;
|
private const float UpdateTargetsInterval = 0.5f;
|
||||||
|
|
||||||
private const float RaycastInterval = 1.0f;
|
private const float RaycastInterval = 1.0f;
|
||||||
|
|
||||||
@@ -32,7 +32,6 @@ namespace Barotrauma
|
|||||||
private float raycastTimer;
|
private float raycastTimer;
|
||||||
|
|
||||||
private Vector2 prevPosition;
|
private Vector2 prevPosition;
|
||||||
private float distanceAccumulator;
|
|
||||||
|
|
||||||
//a timer for attacks such as biting that last for a specific amount of time
|
//a timer for attacks such as biting that last for a specific amount of time
|
||||||
//the duration is determined by the attackDuration of the attacking limb
|
//the duration is determined by the attackDuration of the attacking limb
|
||||||
@@ -106,8 +105,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
UpdateDistanceAccumulator();
|
|
||||||
|
|
||||||
bool ignorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
bool ignorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||||
|
|
||||||
if (steeringManager is IndoorsSteeringManager)
|
if (steeringManager is IndoorsSteeringManager)
|
||||||
@@ -186,14 +183,6 @@ namespace Barotrauma
|
|||||||
coolDownTimer -= deltaTime;
|
coolDownTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateDistanceAccumulator()
|
|
||||||
{
|
|
||||||
Limb limb = Character.AnimController.Limbs[0];
|
|
||||||
distanceAccumulator += (limb.SimPosition - prevPosition).Length();
|
|
||||||
|
|
||||||
prevPosition = limb.body.SimPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateAttack(float deltaTime)
|
private void UpdateAttack(float deltaTime)
|
||||||
{
|
{
|
||||||
if (selectedAiTarget == null || selectedAiTarget.Entity == null || selectedAiTarget.Entity.Removed)
|
if (selectedAiTarget == null || selectedAiTarget.Entity == null || selectedAiTarget.Entity.Removed)
|
||||||
@@ -212,6 +201,11 @@ namespace Barotrauma
|
|||||||
if (selectedAiTarget.Entity != null && Character.Submarine == null && selectedAiTarget.Entity.Submarine != null) attackSimPosition += ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
|
if (selectedAiTarget.Entity != null && Character.Submarine == null && selectedAiTarget.Entity.Submarine != null) attackSimPosition += ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Math.Abs(Character.AnimController.movement.X) > 0.1f && !Character.AnimController.InWater)
|
||||||
|
{
|
||||||
|
Character.AnimController.TargetDir = Character.SimPosition.X < attackSimPosition.X ? Direction.Right : Direction.Left;
|
||||||
|
}
|
||||||
|
|
||||||
if (coolDownTimer > 0.0f)
|
if (coolDownTimer > 0.0f)
|
||||||
{
|
{
|
||||||
UpdateCoolDown(attackSimPosition, deltaTime);
|
UpdateCoolDown(attackSimPosition, deltaTime);
|
||||||
@@ -377,15 +371,6 @@ namespace Barotrauma
|
|||||||
//sight/hearing range
|
//sight/hearing range
|
||||||
public void UpdateTargets(Character character)
|
public void UpdateTargets(Character character)
|
||||||
{
|
{
|
||||||
if (distanceAccumulator<5.0f && Rand.Range(1,3)==1)
|
|
||||||
{
|
|
||||||
selectedAiTarget = null;
|
|
||||||
character.AnimController.TargetMovement = -character.AnimController.TargetMovement;
|
|
||||||
state = AiState.None;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
distanceAccumulator = 0.0f;
|
|
||||||
|
|
||||||
wallAttackPos = Vector2.Zero;
|
wallAttackPos = Vector2.Zero;
|
||||||
|
|
||||||
selectedAiTarget = null;
|
selectedAiTarget = null;
|
||||||
@@ -426,13 +411,11 @@ namespace Barotrauma
|
|||||||
valueModifier = attackRooms;
|
valueModifier = attackRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
dist = Vector2.Distance(
|
dist = Vector2.Distance(character.WorldPosition, target.WorldPosition);
|
||||||
character.WorldPosition,
|
|
||||||
target.WorldPosition);
|
|
||||||
|
|
||||||
//if the target has been within range earlier, the character will notice it more easily
|
//if the target has been within range earlier, the character will notice it more easily
|
||||||
//(i.e. remember where the target was)
|
//(i.e. remember where the target was)
|
||||||
if (targetMemories.ContainsKey(target)) dist *= 0.5f;
|
if (targetMemories.ContainsKey(target)) dist *= 0.1f;
|
||||||
|
|
||||||
//ignore target if it's too far to see or hear
|
//ignore target if it's too far to see or hear
|
||||||
if (dist > target.SightRange * sight && dist > target.SoundRange * hearing) continue;
|
if (dist > target.SightRange * sight && dist > target.SoundRange * hearing) continue;
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ namespace Barotrauma
|
|||||||
int width = 500, height = 400;
|
int width = 500, height = 400;
|
||||||
|
|
||||||
GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f);
|
GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f);
|
||||||
|
backFrame.Padding = Vector4.Zero;
|
||||||
|
|
||||||
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", backFrame);
|
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", backFrame);
|
||||||
frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f);
|
frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f);
|
||||||
|
|||||||
@@ -220,7 +220,10 @@ namespace Barotrauma
|
|||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
NewMessage("heal: restore the controlled character to full health", Color.Cyan);
|
NewMessage("heal: restore the controlled character to full health", Color.Cyan);
|
||||||
|
NewMessage("heal [character name]: restore the specified character to full health", Color.Cyan);
|
||||||
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
||||||
|
NewMessage("revive [character name]: bring the specified character back from the dead", Color.Cyan);
|
||||||
|
NewMessage("killmonsters: immediately kills all AI-controlled enemies in the level", Color.Cyan);
|
||||||
|
|
||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
@@ -458,44 +461,11 @@ namespace Barotrauma
|
|||||||
case "control":
|
case "control":
|
||||||
if (commands.Length < 2) break;
|
if (commands.Length < 2) break;
|
||||||
|
|
||||||
int characterIndex;
|
var character = FindMatchingCharacter(commands);
|
||||||
string characterName;
|
|
||||||
if (int.TryParse(commands.Last(), out characterIndex))
|
|
||||||
{
|
|
||||||
characterName = string.Join(" ", commands.Skip(1).Take(commands.Length-2)).ToLowerInvariant();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
characterName = string.Join(" ", commands.Skip(1)).ToLowerInvariant();
|
|
||||||
characterIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var matchingCharacters = Character.CharacterList.FindAll(c => !c.IsRemotePlayer && c.Name.ToLowerInvariant() == characterName);
|
if (character != null)
|
||||||
|
|
||||||
if (!matchingCharacters.Any())
|
|
||||||
{
|
{
|
||||||
ThrowError("Matching characters not found");
|
Character.Controlled = character;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (characterIndex==-1)
|
|
||||||
{
|
|
||||||
Character.Controlled = matchingCharacters.First();
|
|
||||||
if (matchingCharacters.Count > 1)
|
|
||||||
{
|
|
||||||
NewMessage(
|
|
||||||
"Found multiple matching characters. "+
|
|
||||||
"Use \"control [charactername] [0-"+(matchingCharacters.Count-1)+"]\" to choose which character to control.",
|
|
||||||
Color.LightGray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (characterIndex<0 || characterIndex>= matchingCharacters.Count)
|
|
||||||
{
|
|
||||||
ThrowError("Character index out of range. Select an index between 0 and " + (matchingCharacters.Count - 1));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Character.Controlled = matchingCharacters[characterIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -522,18 +492,39 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "heal":
|
case "heal":
|
||||||
if (Character.Controlled != null)
|
Character healedCharacter = null;
|
||||||
|
if (commands.Length == 1)
|
||||||
{
|
{
|
||||||
Character.Controlled.AddDamage(CauseOfDeath.Damage, -Character.Controlled.MaxHealth, null);
|
healedCharacter = Character.Controlled;
|
||||||
Character.Controlled.Oxygen = 100.0f;
|
|
||||||
Character.Controlled.Bleeding = 0.0f;
|
|
||||||
Character.Controlled.SetStun(0.0f, true);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
healedCharacter = FindMatchingCharacter(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (healedCharacter != null)
|
||||||
|
{
|
||||||
|
healedCharacter.AddDamage(CauseOfDeath.Damage, -healedCharacter.MaxHealth, null);
|
||||||
|
healedCharacter.Oxygen = 100.0f;
|
||||||
|
healedCharacter.Bleeding = 0.0f;
|
||||||
|
healedCharacter.Stun = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "revive":
|
case "revive":
|
||||||
if (Character.Controlled != null)
|
Character reveivedCharacter = null;
|
||||||
|
if (commands.Length == 1)
|
||||||
{
|
{
|
||||||
Character.Controlled.Revive(false);
|
reveivedCharacter = Character.Controlled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reveivedCharacter = FindMatchingCharacter(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reveivedCharacter != null)
|
||||||
|
{
|
||||||
|
reveivedCharacter.Revive(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "freeze":
|
case "freeze":
|
||||||
@@ -835,6 +826,53 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Character FindMatchingCharacter(string[] commands)
|
||||||
|
{
|
||||||
|
if (commands.Length < 2) return null;
|
||||||
|
|
||||||
|
int characterIndex;
|
||||||
|
string characterName;
|
||||||
|
if (int.TryParse(commands.Last(), out characterIndex))
|
||||||
|
{
|
||||||
|
characterName = string.Join(" ", commands.Skip(1).Take(commands.Length - 2)).ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
characterName = string.Join(" ", commands.Skip(1)).ToLowerInvariant();
|
||||||
|
characterIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var matchingCharacters = Character.CharacterList.FindAll(c => !c.IsRemotePlayer && c.Name.ToLowerInvariant() == characterName);
|
||||||
|
|
||||||
|
if (!matchingCharacters.Any())
|
||||||
|
{
|
||||||
|
NewMessage("Matching characters not found", Color.Red);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (characterIndex == -1)
|
||||||
|
{
|
||||||
|
if (matchingCharacters.Count > 1)
|
||||||
|
{
|
||||||
|
NewMessage(
|
||||||
|
"Found multiple matching characters. " +
|
||||||
|
"Use \"" + commands[0] + " [charactername] [0-" + (matchingCharacters.Count - 1) + "]\" to choose a specific character.",
|
||||||
|
Color.LightGray);
|
||||||
|
}
|
||||||
|
return matchingCharacters[0];
|
||||||
|
}
|
||||||
|
else if (characterIndex < 0 || characterIndex >= matchingCharacters.Count)
|
||||||
|
{
|
||||||
|
ThrowError("Character index out of range. Select an index between 0 and " + (matchingCharacters.Count - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return matchingCharacters[characterIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void NewMessage(string msg, Color color)
|
public static void NewMessage(string msg, Color color)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty((msg))) return;
|
if (String.IsNullOrEmpty((msg))) return;
|
||||||
|
|||||||
@@ -310,15 +310,19 @@ namespace Barotrauma
|
|||||||
int centerWidth = Math.Max(rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width, 0);
|
int centerWidth = Math.Max(rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width, 0);
|
||||||
int centerHeight = Math.Max(rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height, 0);
|
int centerHeight = Math.Max(rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height, 0);
|
||||||
|
|
||||||
|
Vector2 scale = new Vector2(
|
||||||
|
MathHelper.Clamp((float)rect.Width / (uiSprite.Slices[0].Width + uiSprite.Slices[2].Width),0, 1),
|
||||||
|
MathHelper.Clamp((float)rect.Height / (uiSprite.Slices[0].Height + uiSprite.Slices[6].Height), 0, 1));
|
||||||
|
|
||||||
for (int x = 0; x < 3; x++)
|
for (int x = 0; x < 3; x++)
|
||||||
{
|
{
|
||||||
int width = x == 1 ? centerWidth : uiSprite.Slices[x].Width;
|
float width = (x == 1 ? centerWidth : uiSprite.Slices[x].Width) * scale.X;
|
||||||
for (int y = 0; y < 3; y++)
|
for (int y = 0; y < 3; y++)
|
||||||
{
|
{
|
||||||
int height = y == 1 ? centerHeight : uiSprite.Slices[x + y * 3].Height;
|
float height = (y == 1 ? centerHeight : uiSprite.Slices[x + y * 3].Height) * scale.Y;
|
||||||
|
|
||||||
spriteBatch.Draw(uiSprite.Sprite.Texture,
|
spriteBatch.Draw(uiSprite.Sprite.Texture,
|
||||||
new Rectangle((int)pos.X, (int)pos.Y, width, height),
|
new Rectangle((int)pos.X, (int)pos.Y, (int)width, (int)height),
|
||||||
uiSprite.Slices[x + y * 3],
|
uiSprite.Slices[x + y * 3],
|
||||||
currColor * (currColor.A / 255.0f));
|
currColor * (currColor.A / 255.0f));
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,20 @@ namespace Barotrauma
|
|||||||
get { return box.Rect; }
|
get { return box.Rect; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ScalableFont Font
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.Font;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Font = value;
|
||||||
|
if (text != null) text.Font = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
|
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
|
||||||
: this(rect, label, alignment, GUI.Font, parent)
|
: this(rect, label, alignment, GUI.Font, parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ namespace Barotrauma.Items.Components
|
|||||||
private List<RadarBlip> radarBlips;
|
private List<RadarBlip> radarBlips;
|
||||||
private float prevPingRadius;
|
private float prevPingRadius;
|
||||||
|
|
||||||
|
float prevPassivePingRadius;
|
||||||
|
|
||||||
|
private Vector2 center;
|
||||||
|
private float displayRadius;
|
||||||
|
private float displayScale;
|
||||||
|
|
||||||
[HasDefaultValue(10000.0f, false)]
|
[HasDefaultValue(10000.0f, false)]
|
||||||
public float Range
|
public float Range
|
||||||
{
|
{
|
||||||
@@ -36,6 +42,20 @@ namespace Barotrauma.Items.Components
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsActive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.IsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.IsActive = value;
|
||||||
|
if (isActiveTickBox != null) isActiveTickBox.Selected = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Radar(Item item, XElement element)
|
public Radar(Item item, XElement element)
|
||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
@@ -54,7 +74,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isActiveTickBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Sonar", Alignment.TopLeft, GuiFrame);
|
isActiveTickBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Active Sonar", Alignment.TopLeft, GuiFrame);
|
||||||
isActiveTickBox.OnSelected = (GUITickBox box) =>
|
isActiveTickBox.OnSelected = (GUITickBox box) =>
|
||||||
{
|
{
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
@@ -72,6 +92,8 @@ namespace Barotrauma.Items.Components
|
|||||||
};
|
};
|
||||||
|
|
||||||
GuiFrame.CanBeFocused = false;
|
GuiFrame.CanBeFocused = false;
|
||||||
|
|
||||||
|
IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
@@ -80,22 +102,15 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
base.Update(deltaTime, cam);
|
base.Update(deltaTime, cam);
|
||||||
|
|
||||||
for (int i = radarBlips.Count - 1; i >= 0; i-- )
|
|
||||||
{
|
|
||||||
radarBlips[i].FadeTimer -= deltaTime*0.5f;
|
|
||||||
if (radarBlips[i].FadeTimer <= 0.0f) radarBlips.RemoveAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (voltage >= minVoltage || powerConsumption <= 0.0f)
|
if (voltage >= minVoltage || powerConsumption <= 0.0f)
|
||||||
{
|
{
|
||||||
pingState = pingState + deltaTime * 0.5f;
|
pingState = pingState + deltaTime * 0.5f;
|
||||||
if (pingState > 1.0f)
|
if (pingState > 1.0f)
|
||||||
{
|
{
|
||||||
|
if (item.CurrentHull != null) item.CurrentHull.AiTarget.SoundRange = Math.Max(Range * pingState, item.CurrentHull.AiTarget.SoundRange);
|
||||||
item.Use(deltaTime);
|
item.Use(deltaTime);
|
||||||
pingState = 0.0f;
|
pingState = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.CurrentHull != null) item.CurrentHull.AiTarget.SoundRange = Math.Max(Range * pingState, item.CurrentHull.AiTarget.SoundRange);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -118,56 +133,60 @@ namespace Barotrauma.Items.Components
|
|||||||
public override void UpdateHUD(Character character)
|
public override void UpdateHUD(Character character)
|
||||||
{
|
{
|
||||||
GuiFrame.Update((float)Timing.Step);
|
GuiFrame.Update((float)Timing.Step);
|
||||||
|
|
||||||
|
for (int i = radarBlips.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
radarBlips[i].FadeTimer -= (float)Timing.Step * 0.5f;
|
||||||
|
if (radarBlips[i].FadeTimer <= 0.0f) radarBlips.RemoveAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
float radius = (GuiFrame.Rect.Height / 2 - 30);
|
||||||
|
|
||||||
|
if (IsActive)
|
||||||
|
{
|
||||||
|
float pingRadius = displayRadius * pingState;
|
||||||
|
Ping(item.WorldPosition, pingRadius, prevPingRadius, displayScale, range, 2.0f);
|
||||||
|
prevPingRadius = pingRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
float passivePingRadius = (float)Math.Sin(GameMain.Instance.TotalElapsedTime*10);
|
||||||
|
if (passivePingRadius > 0.0f)
|
||||||
|
{
|
||||||
|
foreach (AITarget t in AITarget.List)
|
||||||
|
{
|
||||||
|
if (t.SoundRange <= 0.0f) continue;
|
||||||
|
|
||||||
|
if (Vector2.Distance(t.WorldPosition, item.WorldPosition) < t.SoundRange)
|
||||||
|
{
|
||||||
|
Ping(t.WorldPosition, t.SoundRange * passivePingRadius * 0.2f, t.SoundRange * prevPassivePingRadius * 0.2f, displayScale, t.SoundRange, 0.5f);
|
||||||
|
|
||||||
|
radarBlips.Add(new RadarBlip(t.WorldPosition, 1.0f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prevPassivePingRadius = passivePingRadius;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||||
{
|
{
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
if (voltage < minVoltage && powerConsumption > 0.0f) return;
|
|
||||||
|
|
||||||
int radius = GuiFrame.Rect.Height / 2 - 30;
|
int radius = GuiFrame.Rect.Height / 2 - 30;
|
||||||
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
|
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
|
||||||
{
|
{
|
||||||
Vector2 center = new Vector2(rect.X + rect.Width*0.5f, rect.Center.Y);
|
center = new Vector2(rect.X + rect.Width * 0.5f, rect.Center.Y);
|
||||||
|
displayRadius = rect.Width / 2.0f;
|
||||||
|
displayScale = displayRadius / range;
|
||||||
|
|
||||||
if (!IsActive) return;
|
if (IsActive)
|
||||||
|
{
|
||||||
float pingRadius = (rect.Width / 2.0f) * pingState;
|
|
||||||
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f - pingState), 0.0f, (rect.Width / pingCircle.size.X) * pingState);
|
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f - pingState), 0.0f, (rect.Width / pingCircle.size.X) * pingState);
|
||||||
|
|
||||||
float radius = rect.Width / 2.0f;
|
|
||||||
|
|
||||||
float displayScale = radius / range;
|
|
||||||
|
|
||||||
foreach (Submarine submarine in Submarine.Loaded)
|
|
||||||
{
|
|
||||||
if (item.Submarine == submarine && !DetectSubmarineWalls) continue;
|
|
||||||
if (item.Submarine != null && item.Submarine.DockedTo.Contains(submarine)) continue;
|
|
||||||
if (submarine.HullVertices == null) continue;
|
|
||||||
|
|
||||||
for (int i = 0; i < submarine.HullVertices.Count; i++)
|
|
||||||
{
|
|
||||||
Vector2 start = ConvertUnits.ToDisplayUnits(submarine.HullVertices[i]);
|
|
||||||
Vector2 end = ConvertUnits.ToDisplayUnits(submarine.HullVertices[(i + 1) % submarine.HullVertices.Count]);
|
|
||||||
|
|
||||||
if (item.Submarine == submarine)
|
|
||||||
{
|
|
||||||
start += Rand.Vector(500.0f);
|
|
||||||
end += Rand.Vector(500.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateBlipsForLine(
|
|
||||||
start + submarine.WorldPosition,
|
|
||||||
end + submarine.WorldPosition,
|
|
||||||
radius, displayScale, 200.0f, 2.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (item.Submarine != null && !DetectSubmarineWalls)
|
if (item.Submarine != null && !DetectSubmarineWalls)
|
||||||
{
|
{
|
||||||
float simScale = displayScale * Physics.DisplayToSimRation;
|
float simScale = displayScale * Physics.DisplayToSimRation;
|
||||||
@@ -190,93 +209,18 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Level.Loaded != null && (item.CurrentHull == null || !DetectSubmarineWalls))
|
|
||||||
{
|
|
||||||
if (Level.Loaded.Size.Y - item.WorldPosition.Y < range)
|
|
||||||
{
|
|
||||||
CreateBlipsForLine(
|
|
||||||
new Vector2(item.WorldPosition.X - range, Level.Loaded.Size.Y),
|
|
||||||
new Vector2(item.WorldPosition.X + range, Level.Loaded.Size.Y),
|
|
||||||
radius, displayScale, 500.0f, 10.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<VoronoiCell> cells = Level.Loaded.GetCells(item.WorldPosition, 7);
|
|
||||||
foreach (VoronoiCell cell in cells)
|
|
||||||
{
|
|
||||||
foreach (GraphEdge edge in cell.edges)
|
|
||||||
{
|
|
||||||
if (!edge.isSolid) continue;
|
|
||||||
float cellDot = Vector2.Dot(cell.Center - item.WorldPosition, (edge.Center + cell.Translation) - cell.Center);
|
|
||||||
if (cellDot > 0) continue;
|
|
||||||
|
|
||||||
float facingDot = Vector2.Dot(
|
|
||||||
Vector2.Normalize(edge.point1 - edge.point2),
|
|
||||||
Vector2.Normalize(cell.Center - item.WorldPosition));
|
|
||||||
|
|
||||||
CreateBlipsForLine(edge.point1 + cell.Translation, edge.point2 + cell.Translation, radius, displayScale, 350.0f, 3.0f * (Math.Abs(facingDot) + 1.0f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (RuinGeneration.Ruin ruin in Level.Loaded.Ruins)
|
|
||||||
{
|
|
||||||
if (!MathUtils.CircleIntersectsRectangle(item.WorldPosition, range, ruin.Area)) continue;
|
|
||||||
|
|
||||||
foreach (var ruinShape in ruin.RuinShapes)
|
|
||||||
{
|
|
||||||
foreach (RuinGeneration.Line wall in ruinShape.Walls)
|
|
||||||
{
|
|
||||||
|
|
||||||
float cellDot = Vector2.Dot(
|
|
||||||
Vector2.Normalize(ruinShape.Center - item.WorldPosition),
|
|
||||||
Vector2.Normalize((wall.A+wall.B)/2.0f - ruinShape.Center));
|
|
||||||
if (cellDot > 0) continue;
|
|
||||||
|
|
||||||
CreateBlipsForLine(wall.A, wall.B, radius, displayScale, 100.0f, 1000.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
|
||||||
{
|
|
||||||
if (c.AnimController.CurrentHull != null) continue;
|
|
||||||
if (DetectSubmarineWalls && c.AnimController.CurrentHull == null && item.CurrentHull != null) continue;
|
|
||||||
|
|
||||||
foreach (Limb limb in c.AnimController.Limbs)
|
|
||||||
{
|
|
||||||
float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
|
|
||||||
|
|
||||||
if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
|
|
||||||
|
|
||||||
if (pointDist > prevPingRadius && pointDist < pingRadius)
|
|
||||||
{
|
|
||||||
for (int i = 0; i<=limb.Mass/100.0f; i++)
|
|
||||||
{
|
|
||||||
var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f);
|
|
||||||
radarBlips.Add(blip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (RadarBlip radarBlip in radarBlips)
|
foreach (RadarBlip radarBlip in radarBlips)
|
||||||
{
|
{
|
||||||
DrawBlip(spriteBatch, radarBlip, center, Color.Green * radarBlip.FadeTimer, radius);
|
DrawBlip(spriteBatch, radarBlip, center, radarBlip.FadeTimer / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
prevPingRadius = pingRadius;
|
|
||||||
|
|
||||||
if (screenOverlay != null)
|
if (screenOverlay != null)
|
||||||
{
|
{
|
||||||
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width / screenOverlay.size.X);
|
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width / screenOverlay.size.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
//prevPingRadius = pingRadius;
|
|
||||||
|
|
||||||
if (GameMain.GameSession == null) return;
|
if (GameMain.GameSession == null) return;
|
||||||
|
|
||||||
|
|
||||||
DrawMarker(spriteBatch,
|
DrawMarker(spriteBatch,
|
||||||
GameMain.GameSession.StartLocation.Name,
|
GameMain.GameSession.StartLocation.Name,
|
||||||
(Level.Loaded.StartPosition - item.WorldPosition), displayScale, center, (rect.Width * 0.5f));
|
(Level.Loaded.StartPosition - item.WorldPosition), displayScale, center, (rect.Width * 0.5f));
|
||||||
@@ -316,7 +260,7 @@ namespace Barotrauma.Items.Components
|
|||||||
foreach (WayPoint wp in steering.SteeringPath.Nodes)
|
foreach (WayPoint wp in steering.SteeringPath.Nodes)
|
||||||
{
|
{
|
||||||
Vector2 pos = (wp.Position - item.WorldPosition) * displayScale;
|
Vector2 pos = (wp.Position - item.WorldPosition) * displayScale;
|
||||||
if (pos.Length() > radius) continue;
|
if (pos.Length() > displayRadius) continue;
|
||||||
|
|
||||||
pos.Y = -pos.Y;
|
pos.Y = -pos.Y;
|
||||||
pos += center;
|
pos += center;
|
||||||
@@ -332,14 +276,119 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateBlipsForLine(Vector2 point1, Vector2 point2, float radius, float displayScale, float lineStep, float zStep)
|
private void Ping(Vector2 pingSource, float pingRadius, float prevPingRadius, float displayScale, float range, float pingStrength = 1.0f)
|
||||||
{
|
{
|
||||||
float pingRadius = radius * pingState;
|
foreach (Submarine submarine in Submarine.Loaded)
|
||||||
|
{
|
||||||
|
if (item.Submarine == submarine && !DetectSubmarineWalls) continue;
|
||||||
|
if (item.Submarine != null && item.Submarine.DockedTo.Contains(submarine)) continue;
|
||||||
|
if (submarine.HullVertices == null) continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < submarine.HullVertices.Count; i++)
|
||||||
|
{
|
||||||
|
Vector2 start = ConvertUnits.ToDisplayUnits(submarine.HullVertices[i]);
|
||||||
|
Vector2 end = ConvertUnits.ToDisplayUnits(submarine.HullVertices[(i + 1) % submarine.HullVertices.Count]);
|
||||||
|
|
||||||
|
if (item.Submarine == submarine)
|
||||||
|
{
|
||||||
|
start += Rand.Vector(500.0f);
|
||||||
|
end += Rand.Vector(500.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateBlipsForLine(
|
||||||
|
start + submarine.WorldPosition,
|
||||||
|
end + submarine.WorldPosition,
|
||||||
|
pingRadius, prevPingRadius,
|
||||||
|
200.0f, 2.0f, range, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Level.Loaded != null && (item.CurrentHull == null || !DetectSubmarineWalls))
|
||||||
|
{
|
||||||
|
if (Level.Loaded.Size.Y - pingSource.Y < range)
|
||||||
|
{
|
||||||
|
CreateBlipsForLine(
|
||||||
|
new Vector2(pingSource.X - range, Level.Loaded.Size.Y),
|
||||||
|
new Vector2(pingSource.X + range, Level.Loaded.Size.Y),
|
||||||
|
pingRadius, prevPingRadius,
|
||||||
|
250.0f, 150.0f, range, pingStrength);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<VoronoiCell> cells = Level.Loaded.GetCells(pingSource, 7);
|
||||||
|
foreach (VoronoiCell cell in cells)
|
||||||
|
{
|
||||||
|
foreach (GraphEdge edge in cell.edges)
|
||||||
|
{
|
||||||
|
if (!edge.isSolid) continue;
|
||||||
|
float cellDot = Vector2.Dot(cell.Center - pingSource, (edge.Center + cell.Translation) - cell.Center);
|
||||||
|
if (cellDot > 0) continue;
|
||||||
|
|
||||||
|
float facingDot = Vector2.Dot(
|
||||||
|
Vector2.Normalize(edge.point1 - edge.point2),
|
||||||
|
Vector2.Normalize(cell.Center - pingSource));
|
||||||
|
|
||||||
|
CreateBlipsForLine(
|
||||||
|
edge.point1 + cell.Translation,
|
||||||
|
edge.point2 + cell.Translation,
|
||||||
|
pingRadius, prevPingRadius,
|
||||||
|
350.0f, 3.0f * (Math.Abs(facingDot) + 1.0f), range, pingStrength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (RuinGeneration.Ruin ruin in Level.Loaded.Ruins)
|
||||||
|
{
|
||||||
|
if (!MathUtils.CircleIntersectsRectangle(pingSource, range, ruin.Area)) continue;
|
||||||
|
|
||||||
|
foreach (var ruinShape in ruin.RuinShapes)
|
||||||
|
{
|
||||||
|
foreach (RuinGeneration.Line wall in ruinShape.Walls)
|
||||||
|
{
|
||||||
|
float cellDot = Vector2.Dot(
|
||||||
|
Vector2.Normalize(ruinShape.Center - pingSource),
|
||||||
|
Vector2.Normalize((wall.A + wall.B) / 2.0f - ruinShape.Center));
|
||||||
|
if (cellDot > 0) continue;
|
||||||
|
|
||||||
|
CreateBlipsForLine(
|
||||||
|
wall.A, wall.B,
|
||||||
|
pingRadius, prevPingRadius,
|
||||||
|
100.0f, 1000.0f, range, pingStrength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Character c in Character.CharacterList)
|
||||||
|
{
|
||||||
|
if (c.AnimController.CurrentHull != null || !c.Enabled) continue;
|
||||||
|
if (DetectSubmarineWalls && c.AnimController.CurrentHull == null && item.CurrentHull != null) continue;
|
||||||
|
|
||||||
|
foreach (Limb limb in c.AnimController.Limbs)
|
||||||
|
{
|
||||||
|
float pointDist = (limb.WorldPosition - pingSource).Length() * displayScale;
|
||||||
|
|
||||||
|
if (limb.SimPosition == Vector2.Zero || pointDist > displayRadius) continue;
|
||||||
|
|
||||||
|
if (pointDist > prevPingRadius && pointDist < pingRadius)
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= limb.Mass / 100.0f; i++)
|
||||||
|
{
|
||||||
|
var blip = new RadarBlip(limb.WorldPosition + Rand.Vector(limb.Mass / 10.0f), MathHelper.Clamp(limb.Mass, 0.1f, pingStrength));
|
||||||
|
radarBlips.Add(blip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateBlipsForLine(Vector2 point1, Vector2 point2, float pingRadius, float prevPingRadius,
|
||||||
|
float lineStep, float zStep, float range, float pingStrength)
|
||||||
|
{
|
||||||
float length = (point1 - point2).Length();
|
float length = (point1 - point2).Length();
|
||||||
|
|
||||||
Vector2 lineDir = (point2 - point1) / length;
|
Vector2 lineDir = (point2 - point1) / length;
|
||||||
|
|
||||||
|
range *= displayScale;
|
||||||
|
|
||||||
for (float x = 0; x < length; x += lineStep*Rand.Range(0.8f,1.2f))
|
for (float x = 0; x < length; x += lineStep*Rand.Range(0.8f,1.2f))
|
||||||
{
|
{
|
||||||
Vector2 point = point1 + lineDir * x;
|
Vector2 point = point1 + lineDir * x;
|
||||||
@@ -347,44 +396,62 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
|
float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
|
||||||
|
|
||||||
if (pointDist > radius) continue;
|
if (pointDist > displayRadius) continue;
|
||||||
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
|
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
|
||||||
|
|
||||||
|
float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
|
||||||
//float step = 3.0f * (Math.Abs(facingDot) + 1.0f);
|
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
|
||||||
float alpha = Rand.Range(1.5f, 2.0f);
|
|
||||||
for (float z = 0; z < radius - pointDist; z += zStep)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
var blip = new RadarBlip(
|
var blip = new RadarBlip(
|
||||||
point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
|
point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
|
||||||
alpha);
|
alpha * (1.0f - pointDist/range));
|
||||||
|
|
||||||
radarBlips.Add(blip);
|
radarBlips.Add(blip);
|
||||||
zStep += 0.5f;
|
zStep += 0.5f;
|
||||||
alpha -= (z == 0) ? 0.5f : 0.1f;
|
alpha -= (z == 0) ? 0.5f : 0.1f;
|
||||||
|
if (alpha < 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius)
|
private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, float strength)
|
||||||
{
|
{
|
||||||
float displayScale = radius / range;
|
strength = MathHelper.Clamp(strength, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
Color[] colors = new Color[] {
|
||||||
|
Color.TransparentBlack,
|
||||||
|
new Color(0, 50, 160),
|
||||||
|
new Color(0, 133, 166),
|
||||||
|
new Color(2, 159, 30),
|
||||||
|
new Color(255, 255, 255) };
|
||||||
|
|
||||||
|
float scaledT = strength * (colors.Length - 1);
|
||||||
|
Color color = Color.Lerp(colors[(int)scaledT], colors[(int)scaledT], (scaledT - (int)scaledT));
|
||||||
|
|
||||||
Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
|
Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
|
||||||
pos.Y = -pos.Y;
|
pos.Y = -pos.Y;
|
||||||
|
|
||||||
if (pos.Length() > radius)
|
if (pos.Length() > displayRadius)
|
||||||
{
|
{
|
||||||
blip.FadeTimer = 0.0f;
|
blip.FadeTimer = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.X = MathUtils.Round(pos.X, 4);
|
/*pos.X = MathUtils.Round(pos.X, 4);
|
||||||
pos.Y = MathUtils.Round(pos.Y, 2);
|
pos.Y = MathUtils.Round(pos.Y, 2);*/
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, center + pos, new Vector2(4, 2), color, true);
|
|
||||||
|
float posDist = pos.Length();
|
||||||
|
Vector2 dir = pos / posDist;
|
||||||
|
float distFactor = (posDist / displayRadius);
|
||||||
|
|
||||||
|
Vector2 normal = new Vector2(dir.Y, -dir.X) * (strength + 1.0f) * distFactor * 5.0f;
|
||||||
|
|
||||||
|
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * (1.0f - distFactor), 0, 2);
|
||||||
|
|
||||||
|
pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-1.0f, 1.0f) * normal;
|
||||||
|
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * 0.2f, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius)
|
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius)
|
||||||
@@ -470,7 +537,7 @@ namespace Barotrauma.Items.Components
|
|||||||
public RadarBlip(Vector2 pos, float fadeTimer)
|
public RadarBlip(Vector2 pos, float fadeTimer)
|
||||||
{
|
{
|
||||||
Position = pos;
|
Position = pos;
|
||||||
FadeTimer = fadeTimer;
|
FadeTimer = Math.Max(fadeTimer, 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,21 +294,13 @@ namespace Barotrauma.Items.Components
|
|||||||
CoolingRate += (MathHelper.Clamp(target - load, -5.0f, 5.0f) - 1.0f) * deltaTime;
|
CoolingRate += (MathHelper.Clamp(target - load, -5.0f, 5.0f) - 1.0f) * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fission rate can't be lowered below a certain amount if the core is too hot
|
|
||||||
//FissionRate = Math.Max(fissionRate, heat / 200.0f);
|
|
||||||
|
|
||||||
//the power generated by the reactor is equal to the temperature
|
//the power generated by the reactor is equal to the temperature
|
||||||
currPowerConsumption = -temperature*powerPerTemp;
|
currPowerConsumption = -temperature*powerPerTemp;
|
||||||
|
|
||||||
//foreach (Item i in item.ContainedItems)
|
|
||||||
//{
|
|
||||||
// i.Condition = 5.0f;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (item.CurrentHull != null)
|
if (item.CurrentHull != null)
|
||||||
{
|
{
|
||||||
//the sound can be heard from 20 000 display units away when everything running at 100%
|
//the sound can be heard from 20 000 display units away when running at full power
|
||||||
item.CurrentHull.SoundRange = Math.Max((coolingRate + fissionRate) * 100, item.CurrentHull.AiTarget.SoundRange);
|
item.CurrentHull.SoundRange = Math.Max(temperature * 2, item.CurrentHull.AiTarget.SoundRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateGraph(deltaTime);
|
UpdateGraph(deltaTime);
|
||||||
|
|||||||
@@ -1046,9 +1046,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private GUIComponent CreateEditingHUD(bool inGame = false)
|
private GUIComponent CreateEditingHUD(bool inGame = false)
|
||||||
{
|
{
|
||||||
int width = 450;
|
|
||||||
int x = GameMain.GraphicsWidth/2-width/2, y = 10;
|
|
||||||
|
|
||||||
List<ObjectProperty> editableProperties = inGame ? GetProperties<InGameEditable>() : GetProperties<Editable>();
|
List<ObjectProperty> editableProperties = inGame ? GetProperties<InGameEditable>() : GetProperties<Editable>();
|
||||||
|
|
||||||
int requiredItemCount = 0;
|
int requiredItemCount = 0;
|
||||||
@@ -1060,29 +1057,38 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, 70 + (editableProperties.Count() + requiredItemCount) * 30), "");
|
int width = 450;
|
||||||
|
int height = 80 + requiredItemCount * 20;
|
||||||
|
int x = GameMain.GraphicsWidth / 2 - width / 2, y = 10;
|
||||||
|
foreach (var objectProperty in editableProperties)
|
||||||
|
{
|
||||||
|
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
||||||
|
if (editable != null) height += (int)(Math.Ceiling(editable.MaxLength / 40.0f) * 18.0f) + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
editingHUD = new GUIFrame(new Rectangle(x, y, width, height), "");
|
||||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||||
editingHUD.UserData = this;
|
editingHUD.UserData = this;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, "",
|
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, "",
|
||||||
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
|
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
|
||||||
|
|
||||||
y += 20;
|
y += 25;
|
||||||
|
|
||||||
if (!inGame)
|
if (!inGame)
|
||||||
{
|
{
|
||||||
if (prefab.IsLinkable)
|
if (prefab.IsLinkable)
|
||||||
{
|
{
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Hold space to link to another item",
|
new GUITextBlock(new Rectangle(0, 5, 0, 20), "Hold space to link to another item",
|
||||||
"", Alignment.TopRight, Alignment.TopRight, editingHUD).Font = GUI.SmallFont;
|
"", Alignment.TopRight, Alignment.TopRight, editingHUD).Font = GUI.SmallFont;
|
||||||
y += 25;
|
|
||||||
}
|
}
|
||||||
foreach (ItemComponent ic in components)
|
foreach (ItemComponent ic in components)
|
||||||
{
|
{
|
||||||
foreach (RelatedItem relatedItem in ic.requiredItems)
|
foreach (RelatedItem relatedItem in ic.requiredItems)
|
||||||
{
|
{
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", "", editingHUD);
|
new GUITextBlock(new Rectangle(0, y, 100, 15), ic.Name + ": " + relatedItem.Type.ToString() + " required", "", Alignment.TopLeft, Alignment.CenterLeft, editingHUD, false, GUI.SmallFont);
|
||||||
GUITextBox namesBox = new GUITextBox(new Rectangle(-10, y, 160, 20), Alignment.Right, "", editingHUD);
|
GUITextBox namesBox = new GUITextBox(new Rectangle(-10, y, 160, 15), Alignment.Right, "", editingHUD);
|
||||||
|
namesBox.Font = GUI.SmallFont;
|
||||||
|
|
||||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(relatedItem);
|
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(relatedItem);
|
||||||
PropertyDescriptor property = properties.Find("JoinedNames", false);
|
PropertyDescriptor property = properties.Find("JoinedNames", false);
|
||||||
@@ -1092,24 +1098,25 @@ namespace Barotrauma
|
|||||||
namesBox.OnEnterPressed = EnterProperty;
|
namesBox.OnEnterPressed = EnterProperty;
|
||||||
namesBox.OnTextChanged = PropertyChanged;
|
namesBox.OnTextChanged = PropertyChanged;
|
||||||
|
|
||||||
y += 30;
|
y += 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (requiredItemCount > 0) y += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var objectProperty in editableProperties)
|
foreach (var objectProperty in editableProperties)
|
||||||
{
|
{
|
||||||
int height = 20;
|
int boxHeight = 18;
|
||||||
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
||||||
if (editable != null) height = (int)(Math.Ceiling(editable.MaxLength / 20.0f) * 20.0f);
|
if (editable != null) boxHeight = (int)(Math.Ceiling(editable.MaxLength / 40.0f) * 18.0f);
|
||||||
|
|
||||||
object value = objectProperty.GetValue();
|
object value = objectProperty.GetValue();
|
||||||
|
|
||||||
if (value is bool)
|
if (value is bool)
|
||||||
{
|
{
|
||||||
GUITickBox propertyTickBox = new GUITickBox(new Rectangle(10, y, 20, 20), objectProperty.Name,
|
GUITickBox propertyTickBox = new GUITickBox(new Rectangle(10, y, 18, 18), objectProperty.Name,
|
||||||
Alignment.Left, editingHUD);
|
Alignment.Left, editingHUD);
|
||||||
|
propertyTickBox.Font = GUI.SmallFont;
|
||||||
|
|
||||||
propertyTickBox.Selected = (bool)value;
|
propertyTickBox.Selected = (bool)value;
|
||||||
|
|
||||||
@@ -1118,11 +1125,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 100, 18), objectProperty.Name, "", Alignment.TopLeft, Alignment.Left, editingHUD, false, GUI.SmallFont);
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), objectProperty.Name, Color.Transparent, Color.White, Alignment.Left, "", editingHUD);
|
GUITextBox propertyBox = new GUITextBox(new Rectangle(180, y, 250, boxHeight), "", editingHUD);
|
||||||
|
propertyBox.Font = GUI.SmallFont;
|
||||||
GUITextBox propertyBox = new GUITextBox(new Rectangle(180, y, 250, height), "", editingHUD);
|
if (boxHeight > 18) propertyBox.Wrap = true;
|
||||||
if (height > 20) propertyBox.Wrap = true;
|
|
||||||
|
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
@@ -1142,12 +1149,11 @@ namespace Barotrauma
|
|||||||
propertyBox.OnTextChanged = PropertyChanged;
|
propertyBox.OnTextChanged = PropertyChanged;
|
||||||
|
|
||||||
}
|
}
|
||||||
y = y + height + 10;
|
y = y + boxHeight + 5;
|
||||||
|
|
||||||
}
|
}
|
||||||
return editingHUD;
|
return editingHUD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Camera cam, Character character)
|
public virtual void DrawHUD(SpriteBatch spriteBatch, Camera cam, Character character)
|
||||||
{
|
{
|
||||||
if (condition <= 0.0f)
|
if (condition <= 0.0f)
|
||||||
|
|||||||
@@ -270,7 +270,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//mission type ------------------------------------------------------------------
|
//mission type ------------------------------------------------------------------
|
||||||
|
|
||||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, 0, 300, 20), "Mission type:", "", Alignment.BottomLeft, Alignment.TopLeft, infoFrame);
|
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, -10, 300, 20), "Mission type:", "", Alignment.BottomLeft, Alignment.CenterLeft, infoFrame);
|
||||||
|
missionTypeBlock.Padding = Vector4.Zero;
|
||||||
missionTypeBlock.UserData = 0;
|
missionTypeBlock.UserData = 0;
|
||||||
|
|
||||||
missionTypeButtons = new GUIButton[2];
|
missionTypeButtons = new GUIButton[2];
|
||||||
@@ -278,7 +279,7 @@ namespace Barotrauma
|
|||||||
missionTypeButtons[0] = new GUIButton(new Rectangle(100, 0, 20, 20), "<", Alignment.BottomLeft, "", missionTypeBlock);
|
missionTypeButtons[0] = new GUIButton(new Rectangle(100, 0, 20, 20), "<", Alignment.BottomLeft, "", missionTypeBlock);
|
||||||
missionTypeButtons[0].UserData = -1;
|
missionTypeButtons[0].UserData = -1;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(120, 0, 80, 20), "Random", "", Alignment.BottomLeft, Alignment.TopCenter, missionTypeBlock).UserData = 0;
|
new GUITextBlock(new Rectangle(120, 0, 80, 20), "Random", "", Alignment.BottomLeft, Alignment.Center, missionTypeBlock).UserData = 0;
|
||||||
|
|
||||||
missionTypeButtons[1] = new GUIButton(new Rectangle(200, 0, 20, 20), ">", Alignment.BottomLeft, "", missionTypeBlock);
|
missionTypeButtons[1] = new GUIButton(new Rectangle(200, 0, 20, 20), ">", Alignment.BottomLeft, "", missionTypeBlock);
|
||||||
missionTypeButtons[1].UserData = 1;
|
missionTypeButtons[1].UserData = 1;
|
||||||
@@ -352,6 +353,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Select()
|
public override void Select()
|
||||||
{
|
{
|
||||||
|
if (GameMain.NetworkMember == null) return;
|
||||||
|
|
||||||
GameMain.LightManager.LosEnabled = false;
|
GameMain.LightManager.LosEnabled = false;
|
||||||
|
|
||||||
textBox.Select();
|
textBox.Select();
|
||||||
|
|||||||
Reference in New Issue
Block a user