(17fdbc9de) New path is also needed if the old becomes unreachable. Ignore the new path if it's unreachable.
This commit is contained in:
@@ -331,11 +331,8 @@ namespace Barotrauma
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
Vector2 pos = rect.Location.ToVector2() + textPos + TextOffset;
|
||||
if (RoundToNearestPixel)
|
||||
{
|
||||
pos.X = (int)pos.X;
|
||||
pos.Y = (int)pos.Y;
|
||||
}
|
||||
pos.X = (int)pos.X;
|
||||
pos.Y = (int)pos.Y;
|
||||
|
||||
Font.DrawString(spriteBatch,
|
||||
Wrap ? wrappedText : text,
|
||||
|
||||
@@ -1350,7 +1350,7 @@ namespace Barotrauma
|
||||
bool hasFires = Character.Controlled.CurrentHull.FireSources.Count > 0;
|
||||
ToggleReportButton("reportfire", hasFires);
|
||||
|
||||
bool hasLeaks = Character.Controlled.CurrentHull.Submarine != null && Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f);
|
||||
bool hasLeaks = Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f);
|
||||
ToggleReportButton("reportbreach", hasLeaks);
|
||||
|
||||
bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(Character.Controlled, c));
|
||||
|
||||
@@ -105,8 +105,7 @@ namespace Barotrauma.Items.Components
|
||||
textBlock = new GUITextBlock(new RectTransform(item.Rect.Size), "",
|
||||
textColor: textColor, font: GUI.UnscaledSmallFont, textAlignment: Alignment.Center, wrap: true, style: null)
|
||||
{
|
||||
TextDepth = item.SpriteDepth - 0.00001f,
|
||||
RoundToNearestPixel = false,
|
||||
TextDepth = item.SpriteDepth - 0.0001f,
|
||||
TextScale = TextScale
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2408,10 +2408,7 @@ namespace Barotrauma.Networking
|
||||
if (senderCharacter != null &&
|
||||
client.Character != null && !client.Character.IsDead)
|
||||
{
|
||||
if (senderCharacter != client.Character)
|
||||
{
|
||||
modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character);
|
||||
}
|
||||
modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character);
|
||||
|
||||
//too far to hear the msg -> don't send
|
||||
if (string.IsNullOrWhiteSpace(modifiedMessage)) continue;
|
||||
@@ -2460,16 +2457,13 @@ namespace Barotrauma.Networking
|
||||
if (message.Sender != null &&
|
||||
client.Character != null && !client.Character.IsDead)
|
||||
{
|
||||
if (message.Sender != client.Character)
|
||||
{
|
||||
modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character);
|
||||
}
|
||||
modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character);
|
||||
|
||||
//too far to hear the msg -> don't send
|
||||
if (string.IsNullOrWhiteSpace(modifiedMessage)) continue;
|
||||
}
|
||||
|
||||
SendDirectChatMessage(new OrderChatMessage(message.Order, message.OrderOption, message.TargetEntity, message.TargetCharacter, message.Sender), client);
|
||||
SendDirectChatMessage(message, client);
|
||||
}
|
||||
|
||||
string myReceivedMessage = message.Text;
|
||||
|
||||
@@ -85,12 +85,18 @@ namespace Barotrauma
|
||||
|
||||
if (Character.Submarine != null || SelectedAiTarget?.Entity?.Submarine != null)
|
||||
{
|
||||
if (steeringManager != insideSteering) insideSteering.Reset();
|
||||
if (steeringManager != insideSteering)
|
||||
{
|
||||
insideSteering.Reset();
|
||||
}
|
||||
steeringManager = insideSteering;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (steeringManager != outsideSteering) outsideSteering.Reset();
|
||||
if (steeringManager != outsideSteering)
|
||||
{
|
||||
outsideSteering.Reset();
|
||||
}
|
||||
steeringManager = outsideSteering;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,9 +144,9 @@ namespace Barotrauma
|
||||
|
||||
protected override Vector2 DoSteeringSeek(Vector2 target, float weight)
|
||||
{
|
||||
bool isDifferentTarget = Vector2.DistanceSquared(target, currentTarget) > 1;
|
||||
bool needsNewPath = currentPath != null && currentPath.Unreachable || Vector2.DistanceSquared(target, currentTarget) > 1;
|
||||
//find a new path if one hasn't been found yet or the target is different from the current target
|
||||
if (currentPath == null || isDifferentTarget || findPathTimer < -1.0f)
|
||||
if (currentPath == null || needsNewPath || findPathTimer < -1.0f)
|
||||
{
|
||||
IsPathDirty = true;
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
var newPath = pathFinder.FindPath(pos, target, "(Character: " + character.Name + ")");
|
||||
if (currentPath == null || isDifferentTarget || newPath.Cost < currentPath.Cost)
|
||||
if (currentPath == null || needsNewPath || !newPath.Unreachable && newPath.Cost < currentPath.Cost)
|
||||
{
|
||||
currentPath = newPath;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ namespace Barotrauma
|
||||
// It's possible that we could reach another buttons.
|
||||
// If this becomes an issue, we could go through them here and check if any of them are reachable
|
||||
// (would have to cache a collection of buttons instead of a single reference in the CanAccess filter method above)
|
||||
currentPath.Unreachable = true;
|
||||
//currentPath.Unreachable = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Barotrauma
|
||||
// Take the sub position into account in the sim pos
|
||||
if (character.Submarine == null && Target.Submarine != null)
|
||||
{
|
||||
currTargetSimPos += Target.Submarine.SimPosition;
|
||||
//currTargetSimPos += Target.Submarine.SimPosition;
|
||||
}
|
||||
else if (character.Submarine != null && Target.Submarine == null)
|
||||
{
|
||||
|
||||
@@ -165,8 +165,8 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 nodePos = node.Position;
|
||||
|
||||
float xDiff = System.Math.Abs(start.X - nodePos.X);
|
||||
float yDiff = System.Math.Abs(start.Y - nodePos.Y);
|
||||
float xDiff = Math.Abs(start.X - nodePos.X);
|
||||
float yDiff = Math.Abs(start.Y - nodePos.Y);
|
||||
|
||||
if (yDiff > 1.0f && node.Waypoint.Ladders == null && node.Waypoint.Stairs == null)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ namespace Barotrauma
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
if (body.UserData is Submarine) continue;
|
||||
//if (body.UserData is Submarine) continue;
|
||||
if (body.UserData is Structure && !((Structure)body.UserData).IsPlatform) continue;
|
||||
if (body.UserData is Item && body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
|
||||
}
|
||||
@@ -216,8 +216,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 nodePos = node.Position;
|
||||
|
||||
// TODO: use squared distance
|
||||
float dist = Vector2.Distance(end, nodePos);
|
||||
float dist = Vector2.DistanceSquared(end, nodePos);
|
||||
if (insideSubmarine)
|
||||
{
|
||||
//much higher cost to waypoints that are outside
|
||||
@@ -235,7 +234,7 @@ namespace Barotrauma
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
if (body.UserData is Submarine) continue;
|
||||
//if (body.UserData is Submarine) continue;
|
||||
if (body.UserData is Structure && !((Structure)body.UserData).IsPlatform) continue;
|
||||
if (body.UserData is Item && body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
|
||||
|
||||
|
||||
@@ -424,79 +424,6 @@ namespace Barotrauma
|
||||
{
|
||||
Language = doc.Root.GetAttributeString("language", "English");
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckBindings(bool useDefaults)
|
||||
{
|
||||
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
|
||||
{
|
||||
var binding = keyMapping[(int)inputType];
|
||||
if (binding == null)
|
||||
{
|
||||
switch (inputType)
|
||||
{
|
||||
case InputType.Deselect:
|
||||
if (useDefaults)
|
||||
{
|
||||
binding = new KeyOrMouse(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy support
|
||||
var selectKey = keyMapping[(int)InputType.Select];
|
||||
if (selectKey != null && selectKey.Key != Keys.None)
|
||||
{
|
||||
binding = new KeyOrMouse(selectKey.Key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InputType.Shoot:
|
||||
if (useDefaults)
|
||||
{
|
||||
binding = new KeyOrMouse(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Legacy support
|
||||
var useKey = keyMapping[(int)InputType.Use];
|
||||
if (useKey != null && useKey.MouseButton.HasValue)
|
||||
{
|
||||
binding = new KeyOrMouse(useKey.MouseButton.Value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (binding == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
|
||||
binding = new KeyOrMouse(Keys.D1);
|
||||
}
|
||||
keyMapping[(int)inputType] = binding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Load DefaultConfig
|
||||
private void LoadDefaultConfig(bool setLanguage = true)
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(savePath);
|
||||
|
||||
if (setLanguage || string.IsNullOrEmpty(Language))
|
||||
{
|
||||
Language = doc.Root.GetAttributeString("language", "English");
|
||||
}
|
||||
|
||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
||||
|
||||
AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true);
|
||||
WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false);
|
||||
|
||||
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
|
||||
SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false);
|
||||
|
||||
QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", "");
|
||||
|
||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
||||
|
||||
@@ -959,6 +886,55 @@ namespace Barotrauma
|
||||
|
||||
selectedContentPackagePaths = new HashSet<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "keymapping":
|
||||
LoadKeyBinds(subElement);
|
||||
break;
|
||||
case "gameplay":
|
||||
jobPreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
string jobIdentifier = ele.GetAttributeString("identifier", "");
|
||||
if (string.IsNullOrEmpty(jobIdentifier)) continue;
|
||||
jobPreferences.Add(jobIdentifier);
|
||||
}
|
||||
break;
|
||||
case "player":
|
||||
defaultPlayerName = subElement.GetAttributeString("name", defaultPlayerName);
|
||||
CharacterHeadIndex = subElement.GetAttributeInt("headindex", CharacterHeadIndex);
|
||||
if (Enum.TryParse(subElement.GetAttributeString("gender", "none"), true, out Gender g))
|
||||
{
|
||||
CharacterGender = g;
|
||||
}
|
||||
if (Enum.TryParse(subElement.GetAttributeString("race", "white"), true, out Race r))
|
||||
{
|
||||
CharacterRace = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterRace = Race.White;
|
||||
}
|
||||
CharacterHairIndex = subElement.GetAttributeInt("hairindex", CharacterHairIndex);
|
||||
CharacterBeardIndex = subElement.GetAttributeInt("beardindex", CharacterBeardIndex);
|
||||
CharacterMoustacheIndex = subElement.GetAttributeInt("moustacheindex", CharacterMoustacheIndex);
|
||||
CharacterFaceAttachmentIndex = subElement.GetAttributeInt("faceattachmentindex", CharacterFaceAttachmentIndex);
|
||||
break;
|
||||
case "tutorials":
|
||||
foreach (XElement tutorialElement in subElement.Elements())
|
||||
{
|
||||
CompletedTutorialNames.Add(tutorialElement.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UnsavedSettings = false;
|
||||
|
||||
selectedContentPackagePaths = new HashSet<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
gSettings = new XElement("graphicssettings");
|
||||
|
||||
Reference in New Issue
Block a user