Faction Test 100.13.0.0

This commit is contained in:
Markus Isberg
2023-01-11 15:36:23 +02:00
parent 1650735468
commit caa5a2f762
145 changed files with 2100 additions and 1111 deletions
@@ -457,12 +457,14 @@ namespace Barotrauma
private struct LoadedMission
{
public MissionPrefab MissionPrefab { get; }
public int OriginLocationIndex { get; }
public int DestinationIndex { get; }
public bool SelectedMission { get; }
public LoadedMission(MissionPrefab prefab, int destinationIndex, bool selectedMission)
public LoadedMission(MissionPrefab prefab, int originLocationIndex, int destinationIndex, bool selectedMission)
{
MissionPrefab = prefab;
OriginLocationIndex = originLocationIndex;
DestinationIndex = destinationIndex;
SelectedMission = selectedMission;
}
@@ -663,9 +665,10 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(id)) { continue; }
var prefab = MissionPrefab.Prefabs.Find(p => p.Identifier == id);
if (prefab == null) { continue; }
var origin = childElement.GetAttributeInt("origin", -1);
var destination = childElement.GetAttributeInt("destinationindex", -1);
var selected = childElement.GetAttributeBool("selected", false);
loadedMissions.Add(new LoadedMission(prefab, destination, selected));
loadedMissions.Add(new LoadedMission(prefab, origin, destination, selected));
}
}
}
@@ -926,6 +929,10 @@ namespace Barotrauma
destination = Connections.First().OtherLocation(this);
}
var mission = loadedMission.MissionPrefab.Instantiate(new Location[] { this, destination }, Submarine.MainSub);
if (loadedMission.OriginLocationIndex >= 0 && loadedMission.OriginLocationIndex < map.Locations.Count)
{
mission.OriginLocation = map.Locations[loadedMission.OriginLocationIndex];
}
availableMissions.Add(mission);
if (loadedMission.SelectedMission) { selectedMissions.Add(mission); }
}
@@ -1520,10 +1527,12 @@ namespace Barotrauma
foreach (Mission mission in missions)
{
var location = mission.Locations.All(l => l == this) ? this : mission.Locations.FirstOrDefault(l => l != this);
var i = map.Locations.IndexOf(location);
var destinationIndex = map.Locations.IndexOf(location);
var originIndex = map.Locations.IndexOf(mission.OriginLocation);
missionsElement.Add(new XElement("mission",
new XAttribute("prefabid", mission.Prefab.Identifier),
new XAttribute("destinationindex", i),
new XAttribute("destinationindex", destinationIndex),
new XAttribute("origin", originIndex),
new XAttribute("selected", selectedMissions.Contains(mission))));
}
locationElement.Add(missionsElement);
@@ -167,7 +167,7 @@ namespace Barotrauma
}
int startLocationindex = element.GetAttributeInt("startlocation", -1);
if (startLocationindex > 0 && startLocationindex < Locations.Count)
if (startLocationindex >= 0 && startLocationindex < Locations.Count)
{
StartLocation = Locations[startLocationindex];
}
@@ -188,10 +188,9 @@ namespace Barotrauma
{
//backwards compatibility
int endLocationIndex = element.GetAttributeInt("endlocation", -1);
if (endLocationIndex > 0 && endLocationIndex < Locations.Count)
if (endLocationIndex >= 0 && endLocationIndex < Locations.Count)
{
endLocations.Add(Locations[endLocationIndex]);
Locations[endLocationIndex].LevelData.ReassignGenerationParams(Seed);
}
else
{
@@ -203,7 +202,7 @@ namespace Barotrauma
int[] endLocationindices = element.GetAttributeIntArray("endlocations", Array.Empty<int>());
foreach (int endLocationIndex in endLocationindices)
{
if (endLocationIndex > 0 && endLocationIndex < Locations.Count)
if (endLocationIndex >= 0 && endLocationIndex < Locations.Count)
{
endLocations.Add(Locations[endLocationIndex]);
}
@@ -245,7 +244,7 @@ namespace Barotrauma
{
Biome = endLocations.First().Biome
};
newEndLocation.LevelData = new LevelData(newEndLocation, difficulty: 100.0f);
newEndLocation.LevelData = new LevelData(newEndLocation, this, difficulty: 100.0f);
Locations.Add(newEndLocation);
endLocations.Add(newEndLocation);
}
@@ -339,7 +338,7 @@ namespace Barotrauma
{
if (StartLocation != null)
{
StartLocation.LevelData = new LevelData(StartLocation, 0);
StartLocation.LevelData = new LevelData(StartLocation, this, 0);
}
//ensure all paths from the starting location have 0 difficulty to make the 1st campaign round very easy
@@ -701,7 +700,7 @@ namespace Barotrauma
foreach (Location location in Locations)
{
location.LevelData = new LevelData(location, CalculateDifficulty(location.MapPosition.X, location.Biome));
location.LevelData = new LevelData(location, this, CalculateDifficulty(location.MapPosition.X, location.Biome));
if (location.Type.HasOutpost && campaign != null && location.Type.OutpostTeam == CharacterTeamType.FriendlyNPC)
{
location.Faction ??= campaign.GetRandomFaction(Rand.RandSync.ServerAndClient);
@@ -902,6 +901,7 @@ namespace Barotrauma
{
for (int i = 0; i < endLocations.Count; i++)
{
endLocations[i].LevelData.ReassignGenerationParams(Seed);
var outpostParams = OutpostGenerationParams.OutpostParams.FirstOrDefault(p => p.ForceToEndLocationIndex == i);
if (outpostParams != null)
{