Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
This commit is contained in:
@@ -308,6 +308,8 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
private BallastFloraBranch? root;
|
||||
private readonly List<Body> bodies = new List<Body>();
|
||||
|
||||
private bool isDead;
|
||||
|
||||
public readonly BallastFloraStateMachine StateMachine;
|
||||
|
||||
public int GrowthWarps;
|
||||
@@ -403,13 +405,14 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
new XAttribute("health", branch.Health.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("maxhealth", branch.MaxHealth.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("sides", (int)branch.Sides),
|
||||
new XAttribute("blockedsides", (int)branch.BlockedSides));
|
||||
new XAttribute("blockedsides", (int)branch.BlockedSides),
|
||||
new XAttribute("tile", (int)branch.Type));
|
||||
|
||||
if (branch.ClaimedItem != null)
|
||||
{
|
||||
be.Add(new XAttribute("claimed", (int)(branch.ClaimedItem?.ID ?? -1)));
|
||||
}
|
||||
if (branch.ParentBranch != null)
|
||||
if (branch.ParentBranch != null && !branch.ParentBranch.Removed)
|
||||
{
|
||||
be.Add(new XAttribute("parentbranch", (int)(branch.ParentBranch?.ID ?? -1)));
|
||||
}
|
||||
@@ -495,14 +498,15 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
int blockedSides = getInt("blockedsides");
|
||||
int claimedId = branchElement.GetAttributeInt("claimed", -1);
|
||||
int parentBranchId = branchElement.GetAttributeInt("parentbranch", -1);
|
||||
VineTileType type = (VineTileType)branchElement.GetAttributeInt("tile", 0);
|
||||
|
||||
BallastFloraBranch newBranch = new BallastFloraBranch(this, null, pos, VineTileType.CrossJunction, FoliageConfig.Deserialize(flowerConfig), FoliageConfig.Deserialize(leafconfig))
|
||||
BallastFloraBranch newBranch = new BallastFloraBranch(this, null, pos, type, FoliageConfig.Deserialize(flowerConfig), FoliageConfig.Deserialize(leafconfig))
|
||||
{
|
||||
ID = id,
|
||||
Health = health,
|
||||
MaxHealth = maxhealth,
|
||||
Sides = (TileSide) sides,
|
||||
BlockedSides = (TileSide) blockedSides,
|
||||
Sides = (TileSide)sides,
|
||||
BlockedSides = (TileSide)blockedSides,
|
||||
IsRoot = isRoot,
|
||||
IsRootGrowth = isRootGrowth
|
||||
};
|
||||
@@ -683,7 +687,6 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
if (branch.ClaimedItem != null)
|
||||
{
|
||||
RemoveClaim(branch.ClaimedItem);
|
||||
branch.ClaimedItem = null;
|
||||
}
|
||||
|
||||
branch.RemoveTimer -= deltaTime;
|
||||
@@ -1196,6 +1199,14 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
ClaimedTargets.Remove(item);
|
||||
item.Infector = null;
|
||||
|
||||
foreach (var branch in Branches)
|
||||
{
|
||||
if (branch.ClaimedItem == item)
|
||||
{
|
||||
branch.ClaimedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
ClaimedJunctionBoxes.ForEachMod(jb =>
|
||||
{
|
||||
if (jb.Item == item)
|
||||
@@ -1221,15 +1232,21 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
isDead = true;
|
||||
|
||||
foreach (var branch in Branches)
|
||||
{
|
||||
branch.DisconnectedFromRoot = true;
|
||||
}
|
||||
|
||||
foreach (Item target in ClaimedTargets)
|
||||
foreach (Item target in ClaimedTargets.ToList())
|
||||
{
|
||||
RemoveClaim(target);
|
||||
target.Infector = null;
|
||||
}
|
||||
Debug.Assert(ClaimedTargets.Count == 0);
|
||||
Debug.Assert(ClaimedJunctionBoxes.Count == 0);
|
||||
Debug.Assert(ClaimedBatteries.Count == 0);
|
||||
|
||||
StateMachine?.State?.Exit();
|
||||
#if SERVER
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Barotrauma
|
||||
startPath = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { startExitPosition, startPosition },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
minWidth, parentTunnel: mainPath);
|
||||
Tunnels.Add(startPath);
|
||||
}
|
||||
else
|
||||
@@ -561,7 +561,7 @@ namespace Barotrauma
|
||||
endPath = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { endPosition, endExitPosition },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
minWidth, parentTunnel: mainPath);
|
||||
Tunnels.Add(endPath);
|
||||
}
|
||||
else
|
||||
@@ -576,14 +576,14 @@ namespace Barotrauma
|
||||
endHole = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { startPosition, startExitPosition, new Point(0, Size.Y) },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
minWidth, parentTunnel: mainPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
endHole = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { endPosition, endExitPosition, Size },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
minWidth, parentTunnel: mainPath);
|
||||
}
|
||||
Tunnels.Add(endHole);
|
||||
}
|
||||
@@ -601,7 +601,7 @@ namespace Barotrauma
|
||||
abyssTunnel = new Tunnel(
|
||||
TunnelType.SidePath,
|
||||
new List<Point>() { lowestPoint, new Point(lowestPoint.X, 0) },
|
||||
minWidth / 2, parentTunnel: mainPath);
|
||||
minWidth, parentTunnel: mainPath);
|
||||
Tunnels.Add(abyssTunnel);
|
||||
}
|
||||
|
||||
@@ -4266,6 +4266,7 @@ namespace Barotrauma
|
||||
corpse.TeamID = CharacterTeamType.None;
|
||||
corpse.EnableDespawn = false;
|
||||
selectedPrefab.GiveItems(corpse, wreck);
|
||||
corpse.Kill(CauseOfDeathType.Unknown, causeOfDeathAffliction: null, log: false);
|
||||
corpse.CharacterHealth.ApplyAffliction(corpse.AnimController.MainLimb, AfflictionPrefab.OxygenLow.Instantiate(200));
|
||||
bool applyBurns = Rand.Value() < 0.1f;
|
||||
bool applyDamage = Rand.Value() < 0.3f;
|
||||
@@ -4294,7 +4295,7 @@ namespace Barotrauma
|
||||
return strength;
|
||||
}
|
||||
}
|
||||
corpse.Kill(CauseOfDeathType.Unknown, causeOfDeathAffliction: null, log: false);
|
||||
corpse.CharacterHealth.ForceUpdateVisuals();
|
||||
corpse.GiveIdCardTags(sp);
|
||||
|
||||
bool isServerOrSingleplayer = GameMain.IsSingleplayer || GameMain.NetworkMember is { IsServer: true };
|
||||
|
||||
@@ -182,8 +182,8 @@ namespace Barotrauma
|
||||
float scale = element.GetAttributeFloat("scale", prefab.Scale);
|
||||
|
||||
var rect = element.GetAttributeVector4("rect", Vector4.Zero);
|
||||
rect.Z *= scale / prefab.Scale;
|
||||
rect.W *= scale / prefab.Scale;
|
||||
if (!prefab.ResizeHorizontal) { rect.Z *= scale / prefab.Scale; }
|
||||
if (!prefab.ResizeVertical) { rect.W *= scale / prefab.Scale; }
|
||||
|
||||
points.Add(new Vector2(rect.X, rect.Y));
|
||||
points.Add(new Vector2(rect.X + rect.Z, rect.Y));
|
||||
@@ -203,7 +203,7 @@ namespace Barotrauma
|
||||
if (Screen.Selected == GameMain.SubEditorScreen)
|
||||
{
|
||||
linkedSub = CreateDummy(submarine, element, pos, id);
|
||||
linkedSub.saveElement = element;
|
||||
linkedSub.saveElement = new XElement(element);
|
||||
linkedSub.purchasedLostShuttles = false;
|
||||
}
|
||||
else
|
||||
@@ -212,8 +212,10 @@ namespace Barotrauma
|
||||
LevelData levelData = GameMain.GameSession?.Campaign?.NextLevel ?? GameMain.GameSession?.LevelData;
|
||||
linkedSub = new LinkedSubmarine(submarine, id)
|
||||
{
|
||||
purchasedLostShuttles = GameMain.GameSession?.GameMode is CampaignMode campaign && campaign.PurchasedLostShuttles,
|
||||
saveElement = element
|
||||
purchasedLostShuttles =
|
||||
(GameMain.GameSession?.GameMode is CampaignMode campaign && campaign.PurchasedLostShuttles) ||
|
||||
element.GetAttributeBool("purchasedlostshuttle", false),
|
||||
saveElement = new XElement(element)
|
||||
};
|
||||
|
||||
bool levelMatches = string.IsNullOrWhiteSpace(levelSeed) || levelData == null || levelData.Seed == levelSeed;
|
||||
@@ -282,6 +284,8 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
saveElement.Attribute("purchasedlostshuttle")?.Remove();
|
||||
|
||||
IdRemap parentRemap = new IdRemap(Submarine.Info.SubmarineElement, Submarine.IdOffset);
|
||||
sub = Submarine.Load(info, false, parentRemap);
|
||||
sub.Info.SubmarineClass = Submarine.Info.SubmarineClass;
|
||||
@@ -442,14 +446,22 @@ namespace Barotrauma
|
||||
saveElement.Attribute("previewimage").Remove();
|
||||
}
|
||||
|
||||
if (saveElement.Attribute("pos") != null) { saveElement.Attribute("pos").Remove(); }
|
||||
saveElement.Add(new XAttribute("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||
|
||||
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||
if (linkedPort != null)
|
||||
if (GameMain.GameSession?.GameMode is CampaignMode campaign && campaign.PurchasedLostShuttles)
|
||||
{
|
||||
saveElement.Attribute("linkedto")?.Remove();
|
||||
saveElement.Add(new XAttribute("linkedto", linkedPort.ID));
|
||||
saveElement.SetAttributeValue("purchasedlostshuttle", true);
|
||||
}
|
||||
|
||||
saveElement.SetAttributeValue("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition));
|
||||
|
||||
if (linkedTo.Any() || linkedToID.Any())
|
||||
{
|
||||
var linkedPort =
|
||||
linkedTo.FirstOrDefault(lt => (lt is Item item) && item.GetComponent<DockingPort>() != null) ??
|
||||
FindEntityByID(linkedToID.First()) as MapEntity;
|
||||
if (linkedPort != null)
|
||||
{
|
||||
saveElement.SetAttributeValue("linkedto", linkedPort.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -458,10 +470,8 @@ namespace Barotrauma
|
||||
sub.SaveToXElement(saveElement);
|
||||
}
|
||||
|
||||
saveElement.Attribute("originallinkedto")?.Remove();
|
||||
saveElement.Add(new XAttribute("originallinkedto", originalLinkedPort != null ? originalLinkedPort.Item.ID : originalLinkedToID));
|
||||
saveElement.Attribute("originalmyport")?.Remove();
|
||||
saveElement.Add(new XAttribute("originalmyport", originalMyPortID));
|
||||
saveElement.SetAttributeValue("originallinkedto", originalLinkedPort != null ? originalLinkedPort.Item.ID : originalLinkedToID);
|
||||
saveElement.SetAttributeValue("originalmyport", originalMyPortID);
|
||||
|
||||
if (sub != null)
|
||||
{
|
||||
|
||||
@@ -113,15 +113,23 @@ namespace Barotrauma
|
||||
string teamStr = element.GetAttributeString("outpostteam", "FriendlyNPC");
|
||||
Enum.TryParse(teamStr, out OutpostTeam);
|
||||
|
||||
ContentPath nameFile = element.GetAttributeContentPath("namefile") ?? ContentPath.FromRaw(null, "Content/Map/locationNames.txt");
|
||||
try
|
||||
string[] rawNamePaths = element.GetAttributeStringArray("namefile", new string[] { "Content/Map/locationNames.txt" });
|
||||
names = new List<string>();
|
||||
foreach (string rawPath in rawNamePaths)
|
||||
{
|
||||
names = File.ReadAllLines(nameFile.Value).ToList();
|
||||
try
|
||||
{
|
||||
var path = ContentPath.FromRaw(element.ContentPackage, rawPath.Trim());
|
||||
names.AddRange(File.ReadAllLines(path.Value).ToList());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to read name file \"rawPath\" for location type \"{Identifier}\"!", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
if (!names.Any())
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read name file for location type \"" + Identifier + "\"!", e);
|
||||
names = new List<string>() { "Name file not found" };
|
||||
names.Add("ERROR: No names found");
|
||||
}
|
||||
|
||||
string[] commonnessPerZoneStrs = element.GetAttributeStringArray("commonnessperzone", Array.Empty<string>());
|
||||
|
||||
@@ -20,11 +20,24 @@ namespace Barotrauma
|
||||
public int Height { get; private set; }
|
||||
|
||||
public Action<Location, LocationConnection> OnLocationSelected;
|
||||
public Action<LocationConnection, IEnumerable<Mission>> OnMissionsSelected;
|
||||
|
||||
public readonly struct LocationChangeInfo
|
||||
{
|
||||
public readonly Location PrevLocation;
|
||||
public readonly Location NewLocation;
|
||||
|
||||
public LocationChangeInfo(Location prevLocation, Location newLocation)
|
||||
{
|
||||
PrevLocation = prevLocation;
|
||||
NewLocation = newLocation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From -> To
|
||||
/// </summary>
|
||||
public Action<Location, Location> OnLocationChanged;
|
||||
public Action<LocationConnection, IEnumerable<Mission>> OnMissionsSelected;
|
||||
public readonly NamedEvent<LocationChangeInfo> OnLocationChanged = new NamedEvent<LocationChangeInfo>();
|
||||
|
||||
public Location EndLocation { get; private set; }
|
||||
|
||||
@@ -766,7 +779,7 @@ namespace Barotrauma
|
||||
SelectedLocation = null;
|
||||
|
||||
CurrentLocation.CreateStores();
|
||||
OnLocationChanged?.Invoke(prevLocation, CurrentLocation);
|
||||
OnLocationChanged?.Invoke(new LocationChangeInfo(prevLocation, CurrentLocation));
|
||||
|
||||
if (GameMain.GameSession is { Campaign: { CampaignMetadata: { } metadata } })
|
||||
{
|
||||
@@ -803,7 +816,7 @@ namespace Barotrauma
|
||||
{
|
||||
connection.Passed = true;
|
||||
}
|
||||
OnLocationChanged?.Invoke(prevLocation, CurrentLocation);
|
||||
OnLocationChanged?.Invoke(new LocationChangeInfo(prevLocation, CurrentLocation));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -542,6 +542,7 @@ namespace Barotrauma
|
||||
mapEntityList.Remove(this);
|
||||
|
||||
#if CLIENT
|
||||
Submarine.ForceRemoveFromVisibleEntities(this);
|
||||
if (SelectedList.Contains(this))
|
||||
{
|
||||
SelectedList = SelectedList.Where(e => e != this).ToHashSet();
|
||||
|
||||
@@ -52,7 +52,9 @@ namespace Barotrauma
|
||||
get { return MainSubs[0]; }
|
||||
set { MainSubs[0] = value; }
|
||||
}
|
||||
private static List<Submarine> loaded = new List<Submarine>();
|
||||
private static readonly List<Submarine> loaded = new List<Submarine>();
|
||||
|
||||
private readonly Identifier upgradeEventIdentifier;
|
||||
|
||||
private static List<MapEntity> visibleEntities;
|
||||
public static IEnumerable<MapEntity> VisibleEntities
|
||||
@@ -1301,6 +1303,7 @@ namespace Barotrauma
|
||||
|
||||
public Submarine(SubmarineInfo info, bool showWarningMessages = true, Func<Submarine, List<MapEntity>> loadEntities = null, IdRemap linkedRemap = null) : base(null, Entity.NullEntityID)
|
||||
{
|
||||
upgradeEventIdentifier = new Identifier($"Submarine{ID}");
|
||||
Loading = true;
|
||||
GameMain.World.Enabled = false;
|
||||
try
|
||||
@@ -1462,10 +1465,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
|
||||
{
|
||||
GameMain.GameSession.Campaign.UpgradeManager.OnUpgradesChanged += ResetCrushDepth;
|
||||
}
|
||||
GameMain.GameSession?.Campaign?.UpgradeManager?.OnUpgradesChanged.Register(upgradeEventIdentifier, _ => ResetCrushDepth());
|
||||
|
||||
#if CLIENT
|
||||
GameMain.LightManager.OnMapLoaded();
|
||||
@@ -1527,6 +1527,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckFuel()
|
||||
{
|
||||
float fuel = GetItems(true).Where(i => i.HasTag("reactorfuel")).Sum(i => i.Condition);
|
||||
Info.LowFuel = fuel < 200;
|
||||
return !Info.LowFuel;
|
||||
}
|
||||
|
||||
public void SaveToXElement(XElement element)
|
||||
{
|
||||
element.Add(new XAttribute("name", Info.Name));
|
||||
@@ -1534,7 +1541,10 @@ namespace Barotrauma
|
||||
element.Add(new XAttribute("checkval", Rand.Int(int.MaxValue)));
|
||||
element.Add(new XAttribute("price", Info.Price));
|
||||
element.Add(new XAttribute("initialsuppliesspawned", Info.InitialSuppliesSpawned));
|
||||
element.Add(new XAttribute("noitems", Info.NoItems));
|
||||
element.Add(new XAttribute("lowfuel", !CheckFuel()));
|
||||
element.Add(new XAttribute("type", Info.Type.ToString()));
|
||||
element.Add(new XAttribute("ismanuallyoutfitted", Info.IsManuallyOutfitted));
|
||||
if (Info.IsPlayer && !Info.HasTag(SubmarineTag.Shuttle))
|
||||
{
|
||||
element.Add(new XAttribute("class", Info.SubmarineClass.ToString()));
|
||||
@@ -1623,7 +1633,6 @@ namespace Barotrauma
|
||||
|
||||
e.Save(element);
|
||||
}
|
||||
|
||||
Info.CheckSubsLeftBehind(element);
|
||||
}
|
||||
|
||||
@@ -1727,10 +1736,7 @@ namespace Barotrauma
|
||||
outdoorNodes?.Clear();
|
||||
outdoorNodes = null;
|
||||
|
||||
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
|
||||
{
|
||||
GameMain.GameSession.Campaign.UpgradeManager.OnUpgradesChanged -= ResetCrushDepth;
|
||||
}
|
||||
GameMain.GameSession?.Campaign?.UpgradeManager?.OnUpgradesChanged?.TryDeregister(upgradeEventIdentifier);
|
||||
|
||||
if (entityGrid != null)
|
||||
{
|
||||
|
||||
@@ -598,7 +598,12 @@ namespace Barotrauma
|
||||
if (newHull != null)
|
||||
{
|
||||
CoroutineManager.Invoke(() =>
|
||||
character.AnimController.FindHull(newHull.WorldPosition, setSubmarine: true));
|
||||
{
|
||||
if (character != null && !character.Removed)
|
||||
{
|
||||
character.AnimController.FindHull(newHull.WorldPosition, setSubmarine: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -86,6 +86,21 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
public bool NoItems
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note: Refreshed for loaded submarines when they are saved, when they are loaded, and on round end. If you need to refresh it, please use Submarine.CheckFuel() method!
|
||||
/// </summary>
|
||||
public bool LowFuel
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Version GameVersion
|
||||
{
|
||||
get;
|
||||
@@ -94,6 +109,8 @@ namespace Barotrauma
|
||||
|
||||
public SubmarineType Type { get; set; }
|
||||
|
||||
public bool IsManuallyOutfitted { get; set; }
|
||||
|
||||
public SubmarineClass SubmarineClass;
|
||||
|
||||
public OutpostModuleInfo OutpostModuleInfo { get; set; }
|
||||
@@ -272,6 +289,8 @@ namespace Barotrauma
|
||||
Description = original.Description;
|
||||
Price = original.Price;
|
||||
InitialSuppliesSpawned = original.InitialSuppliesSpawned;
|
||||
NoItems = original.NoItems;
|
||||
LowFuel = original.LowFuel;
|
||||
GameVersion = original.GameVersion;
|
||||
Type = original.Type;
|
||||
SubmarineClass = original.SubmarineClass;
|
||||
@@ -286,6 +305,7 @@ namespace Barotrauma
|
||||
RecommendedCrewExperience = original.RecommendedCrewExperience;
|
||||
RecommendedCrewSizeMin = original.RecommendedCrewSizeMin;
|
||||
RecommendedCrewSizeMax = original.RecommendedCrewSizeMax;
|
||||
IsManuallyOutfitted = original.IsManuallyOutfitted;
|
||||
Tags = original.Tags;
|
||||
if (original.OutpostModuleInfo != null)
|
||||
{
|
||||
@@ -335,6 +355,9 @@ namespace Barotrauma
|
||||
Price = SubmarineElement.GetAttributeInt("price", 1000);
|
||||
|
||||
InitialSuppliesSpawned = SubmarineElement.GetAttributeBool("initialsuppliesspawned", false);
|
||||
NoItems = SubmarineElement.GetAttributeBool("noitems", false);
|
||||
LowFuel = SubmarineElement.GetAttributeBool("lowfuel", false);
|
||||
IsManuallyOutfitted = SubmarineElement.GetAttributeBool("ismanuallyoutfitted", false);
|
||||
|
||||
GameVersion = new Version(SubmarineElement.GetAttributeString("gameversion", "0.0.0.0"));
|
||||
if (Enum.TryParse(SubmarineElement.GetAttributeString("tags", ""), out SubmarineTag tags))
|
||||
|
||||
Reference in New Issue
Block a user