Unstable 0.1400.1.0

This commit is contained in:
Markus Isberg
2021-05-20 16:12:54 +03:00
parent 92f0264af2
commit 5bc850cddb
181 changed files with 2475 additions and 1588 deletions
@@ -181,27 +181,50 @@ namespace Barotrauma
}
}
public Mission SelectedMission
private readonly List<Mission> selectedMissions = new List<Mission>();
public IEnumerable<Mission> SelectedMissions
{
get;
set;
get { return selectedMissions; }
}
public int SelectedMissionIndex
public void SelectMission(Mission mission)
{
get
if (!SelectedMissions.Contains(mission) && mission != null)
{
if (SelectedMission == null) { return -1; }
return availableMissions.IndexOf(SelectedMission);
selectedMissions.Add(mission);
}
set
}
public void DeselectMission(Mission mission)
{
selectedMissions.Remove(mission);
}
public List<int> GetSelectedMissionIndices()
{
List<int> selectedMissionIndices = new List<int>();
foreach (Mission mission in SelectedMissions)
{
if (value < 0 || value >= AvailableMissions.Count())
if (availableMissions.Contains(mission))
{
SelectedMission = null;
return;
selectedMissionIndices.Add(availableMissions.IndexOf(mission));
}
SelectedMission = availableMissions[value];
}
return selectedMissionIndices;
}
public void SetSelectedMissionIndices(IEnumerable<int> missionIndices)
{
selectedMissions.Clear();
foreach (int missionIndex in missionIndices)
{
if (missionIndex < 0 || missionIndex >= availableMissions.Count)
{
DebugConsole.ThrowError($"Failed to select a mission in location \"{Name}\". Mission index out of bounds ({missionIndex}, available missions: {availableMissions.Count})");
break;
}
selectedMissions.Add(availableMissions[missionIndex]);
}
}
@@ -415,6 +438,12 @@ namespace Barotrauma
{
if (newType == Type) { return; }
if (newType == null)
{
DebugConsole.ThrowError($"Failed to change the type of the location \"{Name}\" to null.\n" + Environment.StackTrace.CleanupStackTrace());
return;
}
DebugConsole.Log("Location " + baseName + " changed it's type from " + Type + " to " + newType);
Type = newType;
@@ -573,6 +602,7 @@ namespace Barotrauma
public void InstantiateLoadedMissions(Map map)
{
availableMissions.Clear();
selectedMissions.Clear();
if (loadedMissions != null && loadedMissions.Any())
{
foreach (LoadedMission loadedMission in loadedMissions)
@@ -588,7 +618,7 @@ namespace Barotrauma
}
var mission = loadedMission.MissionPrefab.Instantiate(new Location[] { this, destination }, Submarine.MainSub);
availableMissions.Add(mission);
if (loadedMission.SelectedMission) { SelectedMission = mission; }
if (loadedMission.SelectedMission) { selectedMissions.Add(mission); }
}
loadedMissions = null;
}
@@ -612,7 +642,7 @@ namespace Barotrauma
public void ClearMissions()
{
availableMissions.Clear();
SelectedMissionIndex = -1;
selectedMissions.Clear();
}
public bool HasOutpost()
@@ -1180,7 +1210,7 @@ namespace Barotrauma
missionsElement.Add(new XElement("mission",
new XAttribute("prefabid", mission.Prefab.Identifier),
new XAttribute("destinationindex", i),
new XAttribute("selected", mission == SelectedMission)));
new XAttribute("selected", selectedMissions.Contains(mission))));
}
locationElement.Add(missionsElement);
}
@@ -24,7 +24,7 @@ namespace Barotrauma
/// From -> To
/// </summary>
public Action<Location, Location> OnLocationChanged;
public Action<LocationConnection, Mission> OnMissionSelected;
public Action<LocationConnection, IEnumerable<Mission>> OnMissionsSelected;
public Location EndLocation { get; private set; }
@@ -44,9 +44,9 @@ namespace Barotrauma
get { return Locations.IndexOf(SelectedLocation); }
}
public int SelectedMissionIndex
public IEnumerable<int> GetSelectedMissionIndices()
{
get { return SelectedConnection == null ? -1 : CurrentLocation.SelectedMissionIndex; }
return SelectedConnection == null ? Enumerable.Empty<int>() : CurrentLocation.GetSelectedMissionIndices();
}
public LocationConnection SelectedConnection { get; private set; }
@@ -388,8 +388,14 @@ namespace Barotrauma
}
}
LocationConnection[] connectionsBetweenZones = new LocationConnection[generationParams.DifficultyZones];
foreach (var connection in Connections)
List<LocationConnection>[] connectionsBetweenZones = new List<LocationConnection>[generationParams.DifficultyZones];
for (int i = 0; i < generationParams.DifficultyZones; i++)
{
connectionsBetweenZones[i] = new List<LocationConnection>();
}
var shuffledConnections = Connections.ToList();
shuffledConnections.Shuffle(Rand.RandSync.Server);
foreach (var connection in shuffledConnections)
{
int zone1 = GetZoneIndex(connection.Locations[0].MapPosition.X);
int zone2 = GetZoneIndex(connection.Locations[1].MapPosition.X);
@@ -401,17 +407,25 @@ namespace Barotrauma
zone1 = temp;
}
if (connectionsBetweenZones[zone1] == null)
if (generationParams.GateCount[zone1] == 0) { continue; }
if (!connectionsBetweenZones[zone1].Any())
{
connectionsBetweenZones[zone1] = connection;
connectionsBetweenZones[zone1].Add(connection);
}
else
else if (generationParams.GateCount[zone1] == 1)
{
if (Math.Abs(connection.CenterPos.Y - Height / 2) < Math.Abs(connectionsBetweenZones[zone1].CenterPos.Y - Height / 2))
//if there's only one connection, place it at the center of the map
if (Math.Abs(connection.CenterPos.Y - Height / 2) < Math.Abs(connectionsBetweenZones[zone1].First().CenterPos.Y - Height / 2))
{
connectionsBetweenZones[zone1] = connection;
connectionsBetweenZones[zone1].Clear();
connectionsBetweenZones[zone1].Add(connection);
}
}
else if (connectionsBetweenZones[zone1].Count() < generationParams.GateCount[zone1])
{
connectionsBetweenZones[zone1].Add(connection);
}
}
for (int i = Connections.Count - 1; i >= 0; i--)
@@ -421,7 +435,9 @@ namespace Barotrauma
if (zone1 == zone2) { continue; }
if (zone1 == generationParams.DifficultyZones || zone2 == generationParams.DifficultyZones) { continue; }
if (!connectionsBetweenZones.Contains(Connections[i]))
if (generationParams.GateCount[Math.Min(zone1, zone2)] == 0) { continue; }
if (!connectionsBetweenZones[Math.Min(zone1, zone2)].Contains(Connections[i]))
{
Connections.RemoveAt(i);
}
@@ -756,7 +772,7 @@ namespace Barotrauma
OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
}
public void SelectMission(int missionIndex)
public void SelectMission(IEnumerable<int> missionIndices)
{
if (CurrentLocation == null)
{
@@ -765,23 +781,24 @@ namespace Barotrauma
GameAnalyticsManager.AddErrorEventOnce("Map.SelectMission:CurrentLocationNotSet", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
return;
}
CurrentLocation.SelectedMissionIndex = missionIndex;
if (CurrentLocation.SelectedMission == null) { return; }
CurrentLocation.SetSelectedMissionIndices(missionIndices);
if (CurrentLocation.SelectedMission.Locations[0] != CurrentLocation ||
CurrentLocation.SelectedMission.Locations[1] != CurrentLocation)
foreach (Mission selectedMission in CurrentLocation.SelectedMissions.ToList())
{
if (SelectedConnection == null) { return; }
//the destination must be the same as the destination of the mission
if (CurrentLocation.SelectedMission != null &&
CurrentLocation.SelectedMission.Locations[1] != SelectedLocation)
if (selectedMission.Locations[0] != CurrentLocation ||
selectedMission.Locations[1] != CurrentLocation)
{
CurrentLocation.SelectedMissionIndex = -1;
if (SelectedConnection == null) { return; }
//the destination must be the same as the destination of the mission
if (selectedMission.Locations[1] != SelectedLocation)
{
CurrentLocation.DeselectMission(selectedMission);
}
}
}
OnMissionSelected?.Invoke(SelectedConnection, CurrentLocation.SelectedMission);
OnMissionsSelected?.Invoke(SelectedConnection, CurrentLocation.SelectedMissions);
}
public void SelectRandomLocation(bool preferUndiscovered)
@@ -977,6 +994,12 @@ namespace Barotrauma
string prevName = location.Name;
var newType = LocationType.List.Find(lt => lt.Identifier.Equals(change.ChangeToType, StringComparison.OrdinalIgnoreCase));
if (newType == null)
{
DebugConsole.ThrowError($"Failed to change the type of the location \"{location.Name}\". Location type \"{change.ChangeToType}\" not found.");
return;
}
if (newType.OutpostTeam != location.Type.OutpostTeam ||
newType.HasOutpost != location.Type.HasOutpost)
{
@@ -67,6 +67,8 @@ namespace Barotrauma
[Serialize(0.1f, true, description: "ConnectionDisplacementMultiplier for the UI indicator lines between locations."), Editable(0.0f, 10.0f, DecimalCount = 2)]
public float ConnectionIndicatorDisplacementMultiplier { get; set; }
public int[] GateCount { get; private set; }
#if CLIENT
[Serialize(0.75f, true), Editable(DecimalCount = 2)]
@@ -201,6 +203,16 @@ namespace Barotrauma
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
GateCount = element.GetAttributeIntArray("gatecount", null) ?? element.GetAttributeIntArray("GateCount", null);
if (GateCount == null)
{
GateCount = new int[DifficultyZones];
for (int i = 0; i < DifficultyZones; i++)
{
GateCount[i] = 1;
}
}
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())