Unstable 0.16.1.0
This commit is contained in:
@@ -18,8 +18,8 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
public readonly BallastFloraBehavior? ParentBallastFlora;
|
||||
public int ID = -1;
|
||||
|
||||
public ushort ClaimedItem;
|
||||
public bool HasClaimedItem;
|
||||
public Item ClaimedItem;
|
||||
public int ClaimedItemId = -1;
|
||||
|
||||
public float MaxHealth = 100f;
|
||||
public float Health = 100f;
|
||||
@@ -271,10 +271,29 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
{
|
||||
ClaimTarget(item, Branches.FirstOrDefault(b => b.ID == branchid), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMsg = $"Error in BallastFloraBehavior.OnMapLoaded: could not find the item claimed by the ballast flora.";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("BallastFloraBehavior.OnMapLoaded:ClaimedItemNotFound", GameAnalyticsManager.ErrorSeverity.Warning, errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (BallastFloraBranch branch in Branches)
|
||||
{
|
||||
if (branch.ClaimedItemId > -1)
|
||||
{
|
||||
if (Entity.FindEntityByID((ushort)branch.ClaimedItemId) is Item item)
|
||||
{
|
||||
branch.ClaimedItem = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMsg = $"Error in BallastFloraBehavior.OnMapLoaded: could not find the item claimed by a branch.";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("BallastFloraBehavior.OnMapLoaded:BranchClaimedItemNotFound", GameAnalyticsManager.ErrorSeverity.Warning, errorMsg);
|
||||
}
|
||||
}
|
||||
UpdateConnections(branch);
|
||||
CreateBody(branch);
|
||||
}
|
||||
@@ -335,9 +354,9 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
new XAttribute("sides", (int)branch.Sides),
|
||||
new XAttribute("blockedsides", (int)branch.BlockedSides));
|
||||
|
||||
if (branch.HasClaimedItem)
|
||||
if (branch.ClaimedItem != null)
|
||||
{
|
||||
be.Add(new XAttribute("claimed", (int)branch.ClaimedItem));
|
||||
be.Add(new XAttribute("claimed", (int)(branch.ClaimedItem?.ID ?? -1)));
|
||||
}
|
||||
|
||||
saveElement.Add(be);
|
||||
@@ -345,6 +364,13 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
foreach (Item target in ClaimedTargets)
|
||||
{
|
||||
if (target.Infector == null)
|
||||
{
|
||||
string errorMsg = $"Error in BallastFloraBehavior.Save: claimed target \"{target.Prefab.Identifier}\" had no infector set.";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("BallastFloraBehavior.Save:InfectorNull", GameAnalyticsManager.ErrorSeverity.Warning, errorMsg);
|
||||
continue;
|
||||
}
|
||||
XElement te = new XElement("ClaimedTarget", new XAttribute("id", target.ID), new XAttribute("branchId", target.Infector.ID));
|
||||
saveElement.Add(te);
|
||||
}
|
||||
@@ -352,7 +378,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
element.Add(saveElement);
|
||||
}
|
||||
|
||||
public void LoadSave(XElement element)
|
||||
public void LoadSave(XElement element, IdRemap idRemap)
|
||||
{
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
Offset = element.GetAttributeVector2("offset", Vector2.Zero);
|
||||
@@ -361,21 +387,20 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "branch":
|
||||
LoadBranch(subElement);
|
||||
LoadBranch(subElement, idRemap);
|
||||
break;
|
||||
|
||||
case "claimedtarget":
|
||||
int id = subElement.GetAttributeInt("id", -1);
|
||||
int branchId = subElement.GetAttributeInt("branchId", -1);
|
||||
if (id > 0)
|
||||
{
|
||||
tempClaimedTargets.Add(Tuple.Create((UInt16)id, branchId));
|
||||
tempClaimedTargets.Add(Tuple.Create(idRemap.GetOffsetId(id), branchId));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadBranch(XElement branchElement)
|
||||
void LoadBranch(XElement branchElement, IdRemap idRemap)
|
||||
{
|
||||
Vector2 pos = branchElement.GetAttributeVector2("pos", Vector2.Zero);
|
||||
bool isRoot = branchElement.GetAttributeBool("isroot", false);
|
||||
@@ -400,8 +425,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
if (claimedId > -1)
|
||||
{
|
||||
newBranch.HasClaimedItem = true;
|
||||
newBranch.ClaimedItem = (ushort) claimedId;
|
||||
newBranch.ClaimedItemId = idRemap.GetOffsetId((ushort)claimedId);
|
||||
}
|
||||
|
||||
Branches.Add(newBranch);
|
||||
@@ -767,8 +791,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
if (branch != null)
|
||||
{
|
||||
branch.ClaimedItem = target.ID;
|
||||
branch.HasClaimedItem = true;
|
||||
branch.ClaimedItem = target;
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
@@ -977,7 +1000,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
if (isClient) { return; }
|
||||
|
||||
if (branch.HasClaimedItem)
|
||||
if (branch.ClaimedItem != null)
|
||||
{
|
||||
RemoveClaim(branch.ClaimedItem);
|
||||
}
|
||||
@@ -995,41 +1018,34 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
#endif
|
||||
}
|
||||
|
||||
public void RemoveClaim(ushort id)
|
||||
public void RemoveClaim(Item item)
|
||||
{
|
||||
ClaimedTargets.ForEachMod(item =>
|
||||
if (!IgnoredTargets.ContainsKey(item))
|
||||
{
|
||||
if (item.ID == id)
|
||||
IgnoredTargets.Add(item, 10);
|
||||
}
|
||||
|
||||
ClaimedTargets.Remove(item);
|
||||
item.Infector = null;
|
||||
|
||||
ClaimedJunctionBoxes.ForEachMod(jb =>
|
||||
{
|
||||
if (jb.Item == item)
|
||||
{
|
||||
if (!IgnoredTargets.ContainsKey(item))
|
||||
{
|
||||
IgnoredTargets.Add(item, 10);
|
||||
}
|
||||
|
||||
ClaimedTargets.Remove(item);
|
||||
item.Infector = null;
|
||||
|
||||
ClaimedJunctionBoxes.ForEachMod(jb =>
|
||||
{
|
||||
if (jb.Item == item)
|
||||
{
|
||||
ClaimedJunctionBoxes.Remove(jb);
|
||||
}
|
||||
});
|
||||
|
||||
ClaimedBatteries.ForEachMod(bat =>
|
||||
{
|
||||
if (bat.Item == item)
|
||||
{
|
||||
ClaimedBatteries.Remove(bat);
|
||||
}
|
||||
});
|
||||
|
||||
#if SERVER
|
||||
SendNetworkMessage(this, NetworkHeader.Infect, item.ID, false);
|
||||
#endif
|
||||
ClaimedJunctionBoxes.Remove(jb);
|
||||
}
|
||||
});
|
||||
|
||||
ClaimedBatteries.ForEachMod(bat =>
|
||||
{
|
||||
if (bat.Item == item)
|
||||
{
|
||||
ClaimedBatteries.Remove(bat);
|
||||
}
|
||||
});
|
||||
#if SERVER
|
||||
SendNetworkMessage(this, NetworkHeader.Infect, item.ID, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
|
||||
@@ -1540,7 +1540,7 @@ namespace Barotrauma
|
||||
if (prefab != null)
|
||||
{
|
||||
hull.BallastFlora = new BallastFloraBehavior(hull, prefab, Vector2.Zero);
|
||||
hull.BallastFlora.LoadSave(subElement);
|
||||
hull.BallastFlora.LoadSave(subElement, idRemap);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,8 @@ namespace Barotrauma
|
||||
foreach (var cell in Cells)
|
||||
{
|
||||
cell.CellType = CellType.Removed;
|
||||
cell.OnDestroyed?.Invoke();
|
||||
cell.OnDestroyed = null;
|
||||
}
|
||||
GameMain.World.Remove(Body);
|
||||
Dispose();
|
||||
|
||||
@@ -25,7 +25,17 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public const int MaxSubmarineWidth = 16000;
|
||||
|
||||
public static Level Loaded { get; private set; }
|
||||
private static Level loaded;
|
||||
public static Level Loaded
|
||||
{
|
||||
get { return loaded; }
|
||||
private set
|
||||
{
|
||||
if (loaded == value) { return; }
|
||||
loaded = value;
|
||||
GameAnalyticsManager.SetCurrentLevel(loaded?.LevelData);
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum PositionType
|
||||
@@ -578,8 +588,8 @@ namespace Barotrauma
|
||||
{
|
||||
for (int y = siteInterval.Y / 2; y < borders.Height - siteInterval.Y / 2; y += siteInterval.Y)
|
||||
{
|
||||
int siteX = x + Rand.Range(-siteVariance.X, siteVariance.X, Rand.RandSync.Server);
|
||||
int siteY = y + Rand.Range(-siteVariance.Y, siteVariance.Y, Rand.RandSync.Server);
|
||||
int siteX = x + Rand.Range(-siteVariance.X, siteVariance.X + 1, Rand.RandSync.Server);
|
||||
int siteY = y + Rand.Range(-siteVariance.Y, siteVariance.Y + 1, Rand.RandSync.Server);
|
||||
|
||||
bool closeToTunnel = false;
|
||||
bool closeToCave = false;
|
||||
@@ -1776,12 +1786,12 @@ namespace Barotrauma
|
||||
new Point(0, BottomPos)
|
||||
};
|
||||
|
||||
int mountainCount = Rand.Range(GenerationParams.MountainCountMin, GenerationParams.MountainCountMax, Rand.RandSync.Server);
|
||||
int mountainCount = Rand.Range(GenerationParams.MountainCountMin, GenerationParams.MountainCountMax + 1, Rand.RandSync.Server);
|
||||
for (int i = 0; i < mountainCount; i++)
|
||||
{
|
||||
bottomPositions.Add(
|
||||
new Point(Size.X / (mountainCount + 1) * (i + 1),
|
||||
BottomPos + Rand.Range(GenerationParams.MountainHeightMin, GenerationParams.MountainHeightMax, Rand.RandSync.Server)));
|
||||
BottomPos + Rand.Range(GenerationParams.MountainHeightMin, GenerationParams.MountainHeightMax + 1, Rand.RandSync.Server)));
|
||||
}
|
||||
bottomPositions.Add(new Point(Size.X, BottomPos));
|
||||
|
||||
@@ -1794,7 +1804,7 @@ namespace Barotrauma
|
||||
bottomPositions.Insert(i + 1,
|
||||
new Point(
|
||||
(bottomPositions[i].X + bottomPositions[i + 1].X) / 2,
|
||||
(bottomPositions[i].Y + bottomPositions[i + 1].Y) / 2 + Rand.Range(0, GenerationParams.SeaFloorVariance, Rand.RandSync.Server)));
|
||||
(bottomPositions[i].Y + bottomPositions[i + 1].Y) / 2 + Rand.Range(0, GenerationParams.SeaFloorVariance + 1, Rand.RandSync.Server)));
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -1881,7 +1891,7 @@ namespace Barotrauma
|
||||
Tunnels.Add(tunnel);
|
||||
caveBranches.Add(tunnel);
|
||||
|
||||
int branches = Rand.Range(caveParams.MinBranchCount, caveParams.MaxBranchCount, Rand.RandSync.Server);
|
||||
int branches = Rand.Range(caveParams.MinBranchCount, caveParams.MaxBranchCount + 1, Rand.RandSync.Server);
|
||||
for (int j = 0; j < branches; j++)
|
||||
{
|
||||
Tunnel parentBranch = caveBranches.GetRandom(Rand.RandSync.Server);
|
||||
@@ -2441,7 +2451,7 @@ namespace Barotrauma
|
||||
}, randSync: Rand.RandSync.Server);
|
||||
|
||||
if (location.Cell == null || location.Edge == null) { break; }
|
||||
int clusterSize = Rand.Range(GenerationParams.ResourceClusterSizeRange.X, GenerationParams.ResourceClusterSizeRange.Y, Rand.RandSync.Server);
|
||||
int clusterSize = Rand.Range(GenerationParams.ResourceClusterSizeRange.X, GenerationParams.ResourceClusterSizeRange.Y + 1, Rand.RandSync.Server);
|
||||
PlaceResources(itemPrefab, clusterSize, location, out var abyssResources);
|
||||
var abyssClusterLocation = new ClusterLocation(location.Cell, location.Edge, initializeResourceList: true);
|
||||
abyssClusterLocation.Resources.AddRange(abyssResources);
|
||||
@@ -3310,13 +3320,6 @@ namespace Barotrauma
|
||||
return pathCells;
|
||||
}
|
||||
|
||||
public string GetWreckIDTag(string originalTag, Submarine wreck)
|
||||
{
|
||||
string shortSeed = ToolBox.StringToInt(LevelData.Seed + wreck?.Info.Name).ToString();
|
||||
if (shortSeed.Length > 6) { shortSeed = shortSeed.Substring(0, 6); }
|
||||
return originalTag + "_" + shortSeed;
|
||||
}
|
||||
|
||||
public bool IsCloseToStart(Vector2 position, float minDist) => IsCloseToStart(position.ToPoint(), minDist);
|
||||
public bool IsCloseToEnd(Vector2 position, float minDist) => IsCloseToEnd(position.ToPoint(), minDist);
|
||||
|
||||
@@ -4058,7 +4061,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (Submarine wreck in Wrecks)
|
||||
{
|
||||
int corpseCount = Rand.Range(Loaded.GenerationParams.MinCorpseCount, Loaded.GenerationParams.MaxCorpseCount);
|
||||
int corpseCount = Rand.Range(Loaded.GenerationParams.MinCorpseCount, Loaded.GenerationParams.MaxCorpseCount + 1);
|
||||
var allSpawnPoints = WayPoint.WayPointList.FindAll(wp => wp.Submarine == wreck && wp.CurrentHull != null);
|
||||
var pathPoints = allSpawnPoints.FindAll(wp => wp.SpawnType == SpawnType.Path);
|
||||
pathPoints.Shuffle(Rand.RandSync.Unsynced);
|
||||
@@ -4115,6 +4118,7 @@ namespace Barotrauma
|
||||
corpse.EnableDespawn = false;
|
||||
selectedPrefab.GiveItems(corpse, wreck);
|
||||
corpse.Kill(CauseOfDeathType.Unknown, causeOfDeathAffliction: null, log: false);
|
||||
corpse.GiveIdCardTags(sp);
|
||||
spawnCounter++;
|
||||
|
||||
static CorpsePrefab GetCorpsePrefab(Func<CorpsePrefab, bool> predicate)
|
||||
|
||||
+1
-1
@@ -304,7 +304,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (LevelObjectPrefab.ChildObject child in prefab.ChildObjects)
|
||||
{
|
||||
int childCount = Rand.Range(child.MinCount, child.MaxCount, Rand.RandSync.Server);
|
||||
int childCount = Rand.Range(child.MinCount, child.MaxCount + 1, Rand.RandSync.Server);
|
||||
for (int j = 0; j < childCount; j++)
|
||||
{
|
||||
var matchingPrefabs = LevelObjectPrefab.List.Where(p => child.AllowedNames.Contains(p.Name));
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Are there any active contacts between the physics body and the target entity
|
||||
/// </summary>
|
||||
public static bool CheckContactsForEntity(PhysicsBody triggerBody, Entity separatingEntity)
|
||||
public static bool CheckContactsForEntity(PhysicsBody triggerBody, Entity targetEntity)
|
||||
{
|
||||
foreach (Fixture fixture in triggerBody.FarseerBody.FixtureList)
|
||||
{
|
||||
@@ -447,10 +447,11 @@ namespace Barotrauma
|
||||
contactEdge.Contact.Enabled &&
|
||||
contactEdge.Contact.IsTouching)
|
||||
{
|
||||
if (contactEdge.Contact.FixtureA != fixture && contactEdge.Contact.FixtureB != fixture)
|
||||
{
|
||||
if (GetEntity(contactEdge.Contact.FixtureB) == separatingEntity || GetEntity(contactEdge.Contact.FixtureA) == separatingEntity) { return true; }
|
||||
}
|
||||
if ((contactEdge.Contact.FixtureA.Body == triggerBody.FarseerBody && GetEntity(contactEdge.Contact.FixtureB) == targetEntity) ||
|
||||
(contactEdge.Contact.FixtureB.Body == triggerBody.FarseerBody && GetEntity(contactEdge.Contact.FixtureA) == targetEntity))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
contactEdge = contactEdge.Next;
|
||||
}
|
||||
@@ -560,6 +561,8 @@ namespace Barotrauma
|
||||
|
||||
foreach (Entity triggerer in triggerers)
|
||||
{
|
||||
if (triggerer.Removed) { continue; }
|
||||
|
||||
ApplyStatusEffects(statusEffects, worldPosition, triggerer, deltaTime, targets);
|
||||
|
||||
if (triggerer is IDamageable damageable)
|
||||
@@ -691,6 +694,8 @@ namespace Barotrauma
|
||||
|
||||
private void ApplyForce(PhysicsBody body)
|
||||
{
|
||||
if (body == null) { return; }
|
||||
|
||||
float distFactor = 1.0f;
|
||||
if (ForceFalloff)
|
||||
{
|
||||
|
||||
@@ -352,6 +352,7 @@ namespace Barotrauma
|
||||
if (hull.Submarine != sub) { continue; }
|
||||
hull.WaterVolume = 0.0f;
|
||||
hull.OxygenPercentage = 100.0f;
|
||||
hull.BallastFlora?.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -782,7 +782,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (priceInfo.MaxAvailableAmount > priceInfo.MinAvailableAmount)
|
||||
{
|
||||
quantity = Rand.Range(priceInfo.MinAvailableAmount, priceInfo.MaxAvailableAmount);
|
||||
quantity = Rand.Range(priceInfo.MinAvailableAmount, priceInfo.MaxAvailableAmount + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1010,7 +1010,7 @@ namespace Barotrauma
|
||||
|
||||
private void GenerateRandomPriceModifier()
|
||||
{
|
||||
StorePriceModifier = Rand.Range(-StorePriceModifierRange, StorePriceModifierRange);
|
||||
StorePriceModifier = Rand.Range(-StorePriceModifierRange, StorePriceModifierRange + 1);
|
||||
}
|
||||
|
||||
private void CreateStoreSpecials()
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Barotrauma
|
||||
System.Diagnostics.Debug.Assert(!Locations.Contains(null));
|
||||
for (int i = 0; i < Locations.Count; i++)
|
||||
{
|
||||
Locations[i].Reputation ??= new Reputation(campaign.CampaignMetadata, $"location.{i}", -100, 100, Rand.Range(-10, 10, Rand.RandSync.Server));
|
||||
Locations[i].Reputation ??= new Reputation(campaign.CampaignMetadata, Locations[i], $"location.{i}", -100, 100, Rand.Range(-10, 11, Rand.RandSync.Server));
|
||||
}
|
||||
|
||||
List<XElement> connectionElements = new List<XElement>();
|
||||
@@ -214,7 +214,7 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < Locations.Count; i++)
|
||||
{
|
||||
Locations[i].Reputation ??= new Reputation(campaign.CampaignMetadata, $"location.{i}", -100, 100, Rand.Range(-10, 10, Rand.RandSync.Server));
|
||||
Locations[i].Reputation ??= new Reputation(campaign.CampaignMetadata, Locations[i], $"location.{i}", -100, 100, Rand.Range(-10, 11, Rand.RandSync.Server));
|
||||
}
|
||||
|
||||
foreach (Location location in Locations)
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Barotrauma
|
||||
|
||||
private float? maxHealth;
|
||||
|
||||
[Serialize(100.0f, true), Editable]
|
||||
[Serialize(100.0f, true), Editable(MinValueFloat = 0)]
|
||||
public float MaxHealth
|
||||
{
|
||||
get => maxHealth ?? Prefab.Health;
|
||||
@@ -898,8 +898,8 @@ namespace Barotrauma
|
||||
{
|
||||
var worldRect = section.WorldRect;
|
||||
Vector2 particlePos = new Vector2(
|
||||
Rand.Range(worldRect.X, worldRect.Right),
|
||||
Rand.Range(worldRect.Y - worldRect.Height, worldRect.Y));
|
||||
Rand.Range(worldRect.X, worldRect.Right + 1),
|
||||
Rand.Range(worldRect.Y - worldRect.Height, worldRect.Y + 1));
|
||||
|
||||
var particle = GameMain.ParticleManager.CreateParticle("shrapnel", particlePos, Rand.Vector(Rand.Range(1.0f, 50.0f)), collisionIgnoreTimer: 1f);
|
||||
if (particle == null) break;
|
||||
|
||||
Reference in New Issue
Block a user