2f107db...5202af9
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Barotrauma
|
||||
partial class Location
|
||||
{
|
||||
public List<LocationConnection> Connections;
|
||||
|
||||
|
||||
private string baseName;
|
||||
private int nameFormatIndex;
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class LocationConnection
|
||||
{
|
||||
private Location[] locations;
|
||||
private Level level;
|
||||
|
||||
public Biome Biome;
|
||||
|
||||
public float Difficulty;
|
||||
@@ -17,24 +13,17 @@ namespace Barotrauma
|
||||
|
||||
public bool Passed;
|
||||
|
||||
public Level Level
|
||||
{
|
||||
get { return level; }
|
||||
set { level = value; }
|
||||
}
|
||||
public Level Level { get; set; }
|
||||
|
||||
public Vector2 CenterPos
|
||||
{
|
||||
get
|
||||
{
|
||||
return (locations[0].MapPosition + locations[1].MapPosition) / 2.0f;
|
||||
return (Locations[0].MapPosition + Locations[1].MapPosition) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public Location[] Locations
|
||||
{
|
||||
get { return locations; }
|
||||
}
|
||||
public Location[] Locations { get; private set; }
|
||||
|
||||
public float Length
|
||||
{
|
||||
@@ -44,20 +33,20 @@ namespace Barotrauma
|
||||
|
||||
public LocationConnection(Location location1, Location location2)
|
||||
{
|
||||
locations = new Location[] { location1, location2 };
|
||||
Locations = new Location[] { location1, location2 };
|
||||
|
||||
Length = Vector2.Distance(location1.MapPosition, location2.MapPosition);
|
||||
}
|
||||
|
||||
public Location OtherLocation(Location location)
|
||||
{
|
||||
if (locations[0] == location)
|
||||
if (Locations[0] == location)
|
||||
{
|
||||
return locations[1];
|
||||
return Locations[1];
|
||||
}
|
||||
else if (locations[1] == location)
|
||||
else if (Locations[1] == location)
|
||||
{
|
||||
return locations[0];
|
||||
return Locations[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,10 +26,9 @@ namespace Barotrauma
|
||||
|
||||
public Dictionary<int, float> CommonnessPerZone = new Dictionary<int, float>();
|
||||
|
||||
public readonly string Identifier;
|
||||
public readonly string Name;
|
||||
|
||||
public readonly string DisplayName;
|
||||
|
||||
public readonly List<LocationTypeChange> CanChangeTo = new List<LocationTypeChange>();
|
||||
|
||||
public List<string> NameFormats
|
||||
@@ -55,14 +54,9 @@ namespace Barotrauma
|
||||
|
||||
private LocationType(XElement element)
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
DisplayName = element.GetAttributeString("name", "Name");
|
||||
|
||||
nameFormats = new List<string>();
|
||||
foreach (XAttribute nameFormat in element.Element("nameformats").Attributes())
|
||||
{
|
||||
nameFormats.Add(nameFormat.Value);
|
||||
}
|
||||
Identifier = element.Name.ToString();
|
||||
Name = TextManager.Get("LocationName." + Identifier);
|
||||
nameFormats = TextManager.GetAll("LocationNameFormat." + Identifier);
|
||||
|
||||
string nameFile = element.GetAttributeString("namefile", "Content/Map/locationNames.txt");
|
||||
try
|
||||
@@ -71,7 +65,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read name file for location type \""+Name+"\"!", e);
|
||||
DebugConsole.ThrowError("Failed to read name file for location type \""+Identifier+"\"!", e);
|
||||
names = new List<string>() { "Name file not found" };
|
||||
}
|
||||
|
||||
@@ -83,14 +77,14 @@ namespace Barotrauma
|
||||
!int.TryParse(splitCommonnessPerZone[0].Trim(), out int zoneIndex) ||
|
||||
!float.TryParse(splitCommonnessPerZone[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out float zoneCommonness))
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read commonness values for location type \"" + Name + "\" - commonness should be given in the format \"zone0index: zone0commonness, zone1index: zone1commonness\"");
|
||||
DebugConsole.ThrowError("Failed to read commonness values for location type \"" + Identifier + "\" - commonness should be given in the format \"zone0index: zone0commonness, zone1index: zone1commonness\"");
|
||||
break;
|
||||
}
|
||||
CommonnessPerZone[zoneIndex] = zoneCommonness;
|
||||
}
|
||||
|
||||
hireableJobs = new List<Tuple<JobPrefab, float>>();
|
||||
foreach (XElement subElement in element.Elements())
|
||||
string nameFile = element.GetAttributeString("namefile", "Content/Map/locationNames.txt");
|
||||
try
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -99,7 +93,7 @@ namespace Barotrauma
|
||||
JobPrefab jobPrefab = null;
|
||||
if (jobIdentifier == "")
|
||||
{
|
||||
DebugConsole.ThrowError("Error in location type \""+ Name + "\" - hireable jobs should be configured using identifiers instead of names.");
|
||||
DebugConsole.ThrowError("Error in location type \""+ Identifier + "\" - hireable jobs should be configured using identifiers instead of names.");
|
||||
jobIdentifier = subElement.GetAttributeString("name", "");
|
||||
jobPrefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == jobIdentifier.ToLowerInvariant());
|
||||
}
|
||||
@@ -109,7 +103,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (jobPrefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in in location type " + Name + " - could not find a job with the identifier \"" + jobIdentifier + "\".");
|
||||
DebugConsole.ThrowError("Error in in location type " + Identifier + " - could not find a job with the identifier \"" + jobIdentifier + "\".");
|
||||
continue;
|
||||
}
|
||||
float jobCommonness = subElement.GetAttributeFloat("commonness", 1.0f);
|
||||
@@ -122,7 +116,7 @@ namespace Barotrauma
|
||||
SpriteColor = subElement.GetAttributeColor("color", Color.White);
|
||||
break;
|
||||
case "changeto":
|
||||
CanChangeTo.Add(new LocationTypeChange(subElement));
|
||||
CanChangeTo.Add(new LocationTypeChange(Identifier, subElement));
|
||||
break;
|
||||
case "portrait":
|
||||
var portrait = new Sprite(subElement);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Barotrauma
|
||||
{
|
||||
class LocationTypeChange
|
||||
{
|
||||
public readonly string ChangeTo;
|
||||
public readonly string ChangeToType;
|
||||
public readonly float Probability;
|
||||
public readonly int RequiredDuration;
|
||||
|
||||
@@ -18,22 +18,16 @@ namespace Barotrauma
|
||||
//the change can only happen if there's at least one of the given types of locations next to this one
|
||||
public readonly List<string> RequiredAdjacentLocations;
|
||||
|
||||
public LocationTypeChange(XElement element)
|
||||
public LocationTypeChange(string currentType, XElement element)
|
||||
{
|
||||
ChangeTo = element.GetAttributeString("type", "");
|
||||
ChangeToType = element.GetAttributeString("type", "");
|
||||
Probability = element.GetAttributeFloat("probability", 1.0f);
|
||||
RequiredDuration = element.GetAttributeInt("requiredduration", 0);
|
||||
|
||||
DisallowedAdjacentLocations = element.GetAttributeStringArray("disallowedadjacentlocations", new string[0]).ToList();
|
||||
RequiredAdjacentLocations = element.GetAttributeStringArray("requiredadjacentlocations", new string[0]).ToList();
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() == "message")
|
||||
{
|
||||
Messages.Add(subElement.GetAttributeString("text", ""));
|
||||
}
|
||||
}
|
||||
Messages = TextManager.GetAll("LocationChange." + currentType + ".ChangeTo." + ChangeToType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
||||
Vector2 center = new Vector2(size, size) / 2;
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
if (location.Type.Name != "City") continue;
|
||||
if (location.Type.Identifier != "City") continue;
|
||||
float dist = Vector2.DistanceSquared(center, location.MapPosition);
|
||||
if (dist > largestDist)
|
||||
{
|
||||
@@ -430,13 +430,6 @@ namespace Barotrauma
|
||||
}
|
||||
CurrentLocation.SelectedMissionIndex = missionIndex;
|
||||
|
||||
//the destination must be the same as the destination of the mission
|
||||
if (CurrentLocation.SelectedMission != null &&
|
||||
CurrentLocation.SelectedMission.Locations[1] != SelectedLocation)
|
||||
{
|
||||
SelectLocation(CurrentLocation.SelectedMission.Locations[1]);
|
||||
}
|
||||
|
||||
SelectedLocation = location;
|
||||
SelectedConnection = connections.Find(c => c.Locations.Contains(CurrentLocation) && c.Locations.Contains(SelectedLocation));
|
||||
OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
|
||||
@@ -494,7 +487,7 @@ namespace Barotrauma
|
||||
bool disallowedFound = false;
|
||||
foreach (string disallowedLocationName in typeChange.DisallowedAdjacentLocations)
|
||||
{
|
||||
if (location.Connections.Any(c => c.OtherLocation(location).Type.Name.ToLowerInvariant() == disallowedLocationName.ToLowerInvariant()))
|
||||
if (location.Connections.Any(c => c.OtherLocation(location).Type.Identifier.ToLowerInvariant() == disallowedLocationName.ToLowerInvariant()))
|
||||
{
|
||||
disallowedFound = true;
|
||||
break;
|
||||
@@ -506,7 +499,7 @@ namespace Barotrauma
|
||||
bool requiredFound = false;
|
||||
foreach (string requiredLocationName in typeChange.RequiredAdjacentLocations)
|
||||
{
|
||||
if (location.Connections.Any(c => c.OtherLocation(location).Type.Name.ToLowerInvariant() == requiredLocationName.ToLowerInvariant()))
|
||||
if (location.Connections.Any(c => c.OtherLocation(location).Type.Identifier.ToLowerInvariant() == requiredLocationName.ToLowerInvariant()))
|
||||
{
|
||||
requiredFound = true;
|
||||
break;
|
||||
@@ -530,7 +523,7 @@ namespace Barotrauma
|
||||
if (selectedTypeChange != null)
|
||||
{
|
||||
string prevName = location.Name;
|
||||
location.ChangeType(LocationType.List.Find(lt => lt.Name.ToLowerInvariant() == selectedTypeChange.ChangeTo.ToLowerInvariant()));
|
||||
location.ChangeType(LocationType.List.Find(lt => lt.Identifier.ToLowerInvariant() == selectedTypeChange.ChangeToType.ToLowerInvariant()));
|
||||
ChangeLocationType(location, prevName, selectedTypeChange);
|
||||
location.TypeChangeTimer = -1;
|
||||
break;
|
||||
@@ -584,7 +577,7 @@ namespace Barotrauma
|
||||
string prevLocationName = location.Name;
|
||||
LocationType prevLocationType = location.Type;
|
||||
location.Discovered = true;
|
||||
location.ChangeType(LocationType.List.Find(lt => lt.Name.ToLowerInvariant() == locationType.ToLowerInvariant()));
|
||||
location.ChangeType(LocationType.List.Find(lt => lt.Identifier.ToLowerInvariant() == locationType.ToLowerInvariant()));
|
||||
location.TypeChangeTimer = typeChangeTimer;
|
||||
location.MissionsCompleted = missionsCompleted;
|
||||
if (showNotifications && prevLocationType != location.Type)
|
||||
@@ -592,7 +585,7 @@ namespace Barotrauma
|
||||
ChangeLocationType(
|
||||
location,
|
||||
prevLocationName,
|
||||
prevLocationType.CanChangeTo.Find(c => c.ChangeTo.ToLowerInvariant() == location.Type.Name.ToLowerInvariant()));
|
||||
prevLocationType.CanChangeTo.Find(c => c.ChangeToType.ToLowerInvariant() == location.Type.Identifier.ToLowerInvariant()));
|
||||
}
|
||||
break;
|
||||
case "connection":
|
||||
@@ -617,7 +610,7 @@ namespace Barotrauma
|
||||
if (!location.Discovered) continue;
|
||||
|
||||
var locationElement = new XElement("location", new XAttribute("i", i));
|
||||
locationElement.Add(new XAttribute("type", location.Type.Name));
|
||||
locationElement.Add(new XAttribute("type", location.Type.Identifier));
|
||||
if (location.TypeChangeTimer > 0)
|
||||
{
|
||||
locationElement.Add(new XAttribute("changetimer", location.TypeChangeTimer));
|
||||
|
||||
Reference in New Issue
Block a user