Unstable 0.1500.0.0

This commit is contained in:
Markus Isberg
2021-08-26 21:08:21 +09:00
parent 265a2e7ab3
commit 501e02c026
245 changed files with 9775 additions and 2034 deletions
@@ -13,10 +13,8 @@ namespace Barotrauma
{
partial class Explosion
{
private static readonly List<Triplet<Explosion, Vector2, float>> prevExplosions = new List<Triplet<Explosion, Vector2, float>>();
public readonly Attack Attack;
private readonly float force;
private readonly float cameraShake, cameraShakeRange;
@@ -36,6 +34,8 @@ namespace Barotrauma
private readonly string decal;
private readonly float decalSize;
private readonly float itemRepairStrength;
public float EmpStrength { get; set; }
public float BallastFloraDamage { get; set; }
@@ -63,22 +63,24 @@ namespace Barotrauma
force = element.GetAttributeFloat("force", 0.0f);
sparks = element.GetAttributeBool("sparks", true);
shockwave = element.GetAttributeBool("shockwave", true);
flames = element.GetAttributeBool("flames", true);
underwaterBubble = element.GetAttributeBool("underwaterbubble", true);
smoke = element.GetAttributeBool("smoke", true);
bool showEffects = element.GetAttributeBool("showeffects", true);
playTinnitus = element.GetAttributeBool("playtinnitus", true);
sparks = element.GetAttributeBool("sparks", showEffects);
shockwave = element.GetAttributeBool("shockwave", showEffects);
flames = element.GetAttributeBool("flames", showEffects);
underwaterBubble = element.GetAttributeBool("underwaterbubble", showEffects);
smoke = element.GetAttributeBool("smoke", showEffects);
applyFireEffects = element.GetAttributeBool("applyfireeffects", flames);
playTinnitus = element.GetAttributeBool("playtinnitus", showEffects);
applyFireEffects = element.GetAttributeBool("applyfireeffects", flames && showEffects);
ignoreFireEffectsForTags = element.GetAttributeStringArray("ignorefireeffectsfortags", new string[0], convertToLowerInvariant: true);
ignoreCover = element.GetAttributeBool("ignorecover", false);
onlyInside = element.GetAttributeBool("onlyinside", false);
onlyOutside = element.GetAttributeBool("onlyoutside", false);
flash = element.GetAttributeBool("flash", true);
flash = element.GetAttributeBool("flash", showEffects);
flashDuration = element.GetAttributeFloat("flashduration", 0.05f);
if (element.Attribute("flashrange") != null) { flashRange = element.GetAttributeFloat("flashrange", 100.0f); }
flashColor = element.GetAttributeColor("flashcolor", Color.LightYellow);
@@ -86,15 +88,18 @@ namespace Barotrauma
EmpStrength = element.GetAttributeFloat("empstrength", 0.0f);
BallastFloraDamage = element.GetAttributeFloat("ballastfloradamage", 0.0f);
decal = element.GetAttributeString("decal", "");
itemRepairStrength = element.GetAttributeFloat("itemrepairstrength", 0.0f);
decal = element.GetAttributeString("decal", "");
decalSize = element.GetAttributeFloat(1.0f, "decalSize", "decalsize");
cameraShake = element.GetAttributeFloat("camerashake", Attack.Range * 0.1f);
cameraShakeRange = element.GetAttributeFloat("camerashakerange", Attack.Range);
cameraShake = element.GetAttributeFloat("camerashake", showEffects ? Attack.Range * 0.1f : 0f);
cameraShakeRange = element.GetAttributeFloat("camerashakerange", showEffects ? Attack.Range : 0f);
screenColorRange = element.GetAttributeFloat("screencolorrange", Attack.Range * 0.1f);
screenColorRange = element.GetAttributeFloat("screencolorrange", showEffects ? Attack.Range * 0.1f : 0f);
screenColor = element.GetAttributeColor("screencolor", Color.Transparent);
screenColorDuration = element.GetAttributeFloat("screencolorduration", 0.1f);
}
public void DisableParticles()
@@ -107,19 +112,8 @@ namespace Barotrauma
underwaterBubble = false;
}
public List<Triplet<Explosion, Vector2, float>> GetRecentExplosions(float maxSecondsAgo)
{
return prevExplosions.FindAll(e => e.Third >= Timing.TotalTime - maxSecondsAgo);
}
public void Explode(Vector2 worldPosition, Entity damageSource, Character attacker = null)
{
prevExplosions.Add(new Triplet<Explosion, Vector2, float>(this, worldPosition, (float)Timing.TotalTime));
if (prevExplosions.Count > 100)
{
prevExplosions.RemoveAt(0);
}
Hull hull = Hull.FindHull(worldPosition);
ExplodeProjSpecific(worldPosition, hull);
@@ -180,6 +174,23 @@ namespace Barotrauma
}
}
if (itemRepairStrength > 0.0f)
{
float displayRangeSqr = displayRange * displayRange;
foreach (Item item in Item.ItemList)
{
float distSqr = Vector2.DistanceSquared(item.WorldPosition, worldPosition);
if (distSqr > displayRangeSqr) continue;
float distFactor = 1.0f - (float)Math.Sqrt(distSqr) / displayRange;
//repair repairable items
if (item.Repairables.Any())
{
item.Condition += itemRepairStrength * distFactor;
}
}
}
if (MathUtils.NearlyEqual(force, 0.0f) && MathUtils.NearlyEqual(Attack.Stun, 0.0f) && MathUtils.NearlyEqual(Attack.GetTotalDamage(false), 0.0f))
{
return;
@@ -14,8 +14,8 @@ namespace Barotrauma
partial class BackgroundSection
{
public Rectangle Rect;
public int Index;
public int RowIndex;
public ushort Index;
public ushort RowIndex;
private Vector4 colorVector4;
private Color color;
@@ -39,7 +39,7 @@ namespace Barotrauma
}
}
public BackgroundSection(Rectangle rect, int index, int rowIndex)
public BackgroundSection(Rectangle rect, ushort index, ushort rowIndex)
{
Rect = rect;
Index = index;
@@ -53,7 +53,7 @@ namespace Barotrauma
Color = DirtColor = Color.Lerp(new Color(10, 10, 10, 100), new Color(54, 57, 28, 200), Noise.X);
}
public BackgroundSection(Rectangle rect, int index, float colorStrength, Color color, int rowIndex)
public BackgroundSection(Rectangle rect, ushort index, float colorStrength, Color color, ushort rowIndex)
{
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
@@ -674,6 +674,9 @@ namespace Barotrauma
Gap.UpdateHulls();
}
BackgroundSections?.Clear();
submergedSections?.Clear();
List<FireSource> fireSourcesToRemove = new List<FireSource>(FireSources);
foreach (FireSource fireSource in fireSourcesToRemove)
{
@@ -1260,9 +1263,9 @@ namespace Barotrauma
{
for (int x = 0; x < xBackgroundMax; x++)
{
int index = BackgroundSections.Count;
ushort index = (ushort)BackgroundSections.Count;
int sector = (int)Math.Floor(index / (float)sectorWidth - xSectors * y) + y / sectorHeight * (int)Math.Ceiling(xSectors);
BackgroundSections.Add(new BackgroundSection(new Rectangle(x * sectionWidth, y * -sectionHeight, sectionWidth, sectionHeight), index, y));
BackgroundSections.Add(new BackgroundSection(new Rectangle(x * sectionWidth, y * -sectionHeight, sectionWidth, sectionHeight), index, (ushort)y));
}
}
@@ -325,7 +325,6 @@ namespace Barotrauma
get { return LevelData.Seed; }
}
public static float? ForcedDifficulty;
public float Difficulty
{
@@ -3020,13 +3019,6 @@ namespace Barotrauma
}
}
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);
@@ -3891,12 +3883,39 @@ namespace Barotrauma
LevelObjectManager = null;
}
AbyssIslands?.Clear();
AbyssResources?.Clear();
Caves?.Clear();
Tunnels?.Clear();
PathPoints?.Clear();
PositionsOfInterest?.Clear();
wreckPositions?.Clear();
Wrecks?.Clear();
BeaconStation = null;
beaconSonar = null;
StartOutpost = null;
EndOutpost = null;
blockedRects?.Clear();
EntitiesBeforeGenerate?.Clear();
EqualityCheckValues?.Clear();
if (Ruins != null)
{
Ruins.Clear();
Ruins = null;
}
bottomPositions?.Clear();
BottomBarrier = null;
TopBarrier = null;
SeaFloor = null;
distanceField = null;
if (ExtraWalls != null)
{
foreach (LevelWall w in ExtraWalls) { w.Dispose(); }
@@ -3908,7 +3927,9 @@ namespace Barotrauma
UnsyncedExtraWalls = null;
}
tempCells?.Clear();
cells = null;
cellGrid = null;
if (bodies != null)
{
@@ -3916,6 +3937,9 @@ namespace Barotrauma
bodies = null;
}
StartLocation = null;
EndLocation = null;
Loaded = null;
}
@@ -264,7 +264,7 @@ namespace Barotrauma
var tagsArray = element.GetAttributeStringArray("tags", new string[0]);
foreach (string tag in tagsArray)
{
tags.Add(tag.ToLower());
tags.Add(tag.ToLowerInvariant());
}
if (triggeredBy.HasFlag(TriggererType.OtherTrigger))
@@ -272,7 +272,7 @@ namespace Barotrauma
var otherTagsArray = element.GetAttributeStringArray("allowedothertriggertags", new string[0]);
foreach (string tag in otherTagsArray)
{
allowedOtherTriggerTags.Add(tag.ToLower());
allowedOtherTriggerTags.Add(tag.ToLowerInvariant());
}
}
@@ -149,7 +149,7 @@ namespace Barotrauma
public XElement Save()
{
XElement element = new XElement(nameof(Radiation));
SerializableProperty.SerializeProperties(this, element);
SerializableProperty.SerializeProperties(this, element, saveIfDefault: true);
return element;
}
}
@@ -48,8 +48,7 @@ namespace Barotrauma
}
}
//observable collection because some entities may need to be notified when the collection is modified
public readonly ObservableCollection<MapEntity> linkedTo = new ObservableCollection<MapEntity>();
public readonly List<MapEntity> linkedTo = new List<MapEntity>();
protected bool flippedX, flippedY;
public bool FlippedX { get { return flippedX; } }
@@ -515,7 +514,11 @@ namespace Barotrauma
}
#endif
if (aiTarget != null) aiTarget.Remove();
if (aiTarget != null)
{
aiTarget.Remove();
aiTarget = null;
}
if (linkedTo != null)
{
@@ -47,7 +47,7 @@ namespace Barotrauma
const float LeakThreshold = 0.1f;
#if CLIENT
private SpriteEffects SpriteEffects = SpriteEffects.None;
public SpriteEffects SpriteEffects = SpriteEffects.None;
#endif
//dimensions of the wall sections' physics bodies (only used for debug rendering)
@@ -955,6 +955,15 @@ namespace Barotrauma
SoundPlayer.PlayDamageSound(attack.StructureSoundType, damageAmount, worldPosition, tags: Tags);
}
#endif
if (Submarine != null && damageAmount > 0)
{
foreach (Character character in Character.CharacterList)
{
character.CheckTalents(AbilityEffectType.AfterSubmarineAttacked, Submarine);
}
}
return new AttackResult(damageAmount, null);
}
@@ -249,6 +249,17 @@ namespace Barotrauma
get { return subBody?.HullVertices; }
}
private int? submarineSpecificIDTag;
public int SubmarineSpecificIDTag
{
get
{
submarineSpecificIDTag ??= ToolBox.StringToInt((Level.Loaded?.Seed ?? "") + Info.Name);
return submarineSpecificIDTag.Value;
}
}
public bool AtDamageDepth
{
get
@@ -329,48 +340,6 @@ namespace Barotrauma
DockedTo.ForEach(s => s.ShowSonarMarker = false);
PhysicsBody.FarseerBody.BodyType = BodyType.Static;
TeamID = CharacterTeamType.None;
string defaultTag = Level.Loaded.GetWreckIDTag("wreck_id", this);
ReplaceIDCardTagRequirements("wreck_id", defaultTag);
foreach (Item item in Item.ItemList)
{
if (item.Submarine != this) { continue; }
if (item.prefab.Identifier == "idcardwreck" || item.prefab.Identifier == "idcard")
{
foreach (string tag in item.GetTags().ToList())
{
if (tag == "smallitem") { continue; }
string newTag = Level.Loaded.GetWreckIDTag(tag, this);
item.ReplaceTag(tag, newTag);
ReplaceIDCardTagRequirements(tag, newTag);
}
}
}
void ReplaceIDCardTagRequirements(string oldTag, string newTag)
{
foreach (Item item in Item.ItemList)
{
if (item.Submarine != this) { continue; }
foreach (ItemComponent ic in item.Components)
{
ReplaceIDCardTagRequirement(ic, RelatedItem.RelationType.Picked, oldTag, newTag);
ReplaceIDCardTagRequirement(ic, RelatedItem.RelationType.Equipped, oldTag, newTag);
}
}
}
static void ReplaceIDCardTagRequirement(ItemComponent ic, RelatedItem.RelationType relationType, string oldTag, string newTag)
{
if (!ic.requiredItems.ContainsKey(relationType)) { return; }
foreach (RelatedItem requiredItem in ic.requiredItems[relationType])
{
int index = Array.IndexOf(requiredItem.Identifiers, oldTag);
if (index == -1) { continue; }
requiredItem.Identifiers[index] = newTag;
}
}
}
public WreckAI WreckAI { get; private set; }
@@ -1718,7 +1687,10 @@ namespace Barotrauma
PhysicsBody.RemoveAll();
GameMain.World.Clear();
GameMain.World?.Clear();
GameMain.World = null;
GC.Collect();
Unloading = false;
}
@@ -1730,6 +1702,9 @@ namespace Barotrauma
subBody?.Remove();
subBody = null;
outdoorNodes?.Clear();
outdoorNodes = null;
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
{
GameMain.GameSession.Campaign.UpgradeManager.OnUpgradesChanged -= ResetCrushDepth;
@@ -1743,8 +1718,8 @@ namespace Barotrauma
visibleEntities = null;
if (MainSub == this) MainSub = null;
if (MainSubs[1] == this) MainSubs[1] = null;
if (MainSub == this) { MainSub = null; }
if (MainSubs[1] == this) { MainSubs[1] = null; }
ConnectedDockingPorts?.Clear();
@@ -569,8 +569,7 @@ namespace Barotrauma
}
var gaps = newHull?.ConnectedGaps ?? Gap.GapList.Where(g => g.Submarine == submarine);
targetPos = character.WorldPosition;
Gap adjacentGap = Gap.FindAdjacent(gaps, targetPos, 500.0f);
Gap adjacentGap = Gap.FindAdjacent(gaps, ConvertUnits.ToDisplayUnits(points[0]), 200.0f);
if (adjacentGap == null) { return true; }
if (newHull != null)
@@ -54,6 +54,8 @@ namespace Barotrauma
set { spawnType = value; }
}
public Action<WayPoint> OnLinksChanged { get; set; }
public override string Name
{
get
@@ -761,9 +763,16 @@ namespace Barotrauma
public void ConnectTo(WayPoint wayPoint2)
{
System.Diagnostics.Debug.Assert(this != wayPoint2);
if (!linkedTo.Contains(wayPoint2)) { linkedTo.Add(wayPoint2); }
if (!wayPoint2.linkedTo.Contains(this)) { wayPoint2.linkedTo.Add(this); }
if (!linkedTo.Contains(wayPoint2))
{
OnLinksChanged?.Invoke(this);
linkedTo.Add(wayPoint2);
}
if (!wayPoint2.linkedTo.Contains(this))
{
wayPoint2.OnLinksChanged?.Invoke(wayPoint2);
wayPoint2.linkedTo.Add(this);
}
}
public static WayPoint GetRandom(SpawnType spawnType = SpawnType.Human, JobPrefab assignedJob = null, Submarine sub = null, Ruin ruin = null, bool useSyncedRand = false)
@@ -986,14 +995,18 @@ namespace Barotrauma
public override void ShallowRemove()
{
base.ShallowRemove();
WayPointList.Remove(this);
}
public override void Remove()
{
base.Remove();
CurrentHull = null;
ConnectedGap = null;
Tunnel = null;
Stairs = null;
Ladders = null;
OnLinksChanged = null;
WayPointList.Remove(this);
}