(3dc4135ce) v0.9.5.1
This commit is contained in:
@@ -110,9 +110,17 @@ namespace Barotrauma
|
||||
get { return aiTarget; }
|
||||
}
|
||||
|
||||
public double SpawnTime
|
||||
{
|
||||
get { return spawnTime; }
|
||||
}
|
||||
|
||||
private readonly double spawnTime;
|
||||
|
||||
public Entity(Submarine submarine)
|
||||
{
|
||||
this.Submarine = submarine;
|
||||
spawnTime = Timing.TotalTime;
|
||||
|
||||
//give a unique ID
|
||||
id = this is EntitySpawner ?
|
||||
|
||||
@@ -124,39 +124,55 @@ namespace Barotrauma
|
||||
if (powerContainer != null)
|
||||
{
|
||||
powerContainer.Charge -= powerContainer.Capacity * empStrength * distFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (force == 0.0f && attack.Stun == 0.0f && attack.GetTotalDamage(false) == 0.0f) return;
|
||||
if (MathUtils.NearlyEqual(force, 0.0f) && MathUtils.NearlyEqual(attack.Stun, 0.0f) && MathUtils.NearlyEqual(attack.GetTotalDamage(false), 0.0f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DamageCharacters(worldPosition, attack, force, damageSource, attacker);
|
||||
|
||||
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
|
||||
{
|
||||
if (flames)
|
||||
{
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue;
|
||||
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) { continue; }
|
||||
|
||||
//don't apply OnFire effects if the item is inside a fireproof container
|
||||
//(or if it's inside a container that's inside a fireproof container, etc)
|
||||
Item container = item.Container;
|
||||
bool fireProof = false;
|
||||
while (container != null)
|
||||
{
|
||||
if (container.FireProof) return;
|
||||
if (container.FireProof) { fireProof = true; break; }
|
||||
container = container.Container;
|
||||
}
|
||||
|
||||
if (Vector2.Distance(item.WorldPosition, worldPosition) > attack.Range * 0.1f) continue;
|
||||
if (fireProof || Vector2.Distance(item.WorldPosition, worldPosition) > attack.Range * 0.5f) { continue; }
|
||||
|
||||
item.ApplyStatusEffects(ActionType.OnFire, 1.0f);
|
||||
|
||||
if (item.Condition <= 0.0f && GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnFire });
|
||||
}
|
||||
|
||||
if (item.Prefab.DamagedByExplosions && !item.Indestructible)
|
||||
{
|
||||
float limbRadius = item.body == null ? 0.0f : item.body.GetMaxExtent();
|
||||
float dist = Vector2.Distance(item.WorldPosition, worldPosition);
|
||||
dist = Math.Max(0.0f, dist - ConvertUnits.ToDisplayUnits(limbRadius));
|
||||
|
||||
if (dist > attack.Range) { continue; }
|
||||
|
||||
float distFactor = 1.0f - dist / attack.Range;
|
||||
float damageAmount = attack.GetItemDamage(1.0f);
|
||||
item.Condition -= damageAmount * distFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +213,7 @@ namespace Barotrauma
|
||||
//calculate distance from the "outer surface" of the physics body
|
||||
//doesn't take the rotation of the limb into account, but should be accurate enough for this purpose
|
||||
float limbRadius = Math.Max(Math.Max(limb.body.width * 0.5f, limb.body.height * 0.5f), limb.body.radius);
|
||||
dist = Math.Max(0.0f, dist - FarseerPhysics.ConvertUnits.ToDisplayUnits(limbRadius));
|
||||
dist = Math.Max(0.0f, dist - ConvertUnits.ToDisplayUnits(limbRadius));
|
||||
|
||||
if (dist > attack.Range) { continue; }
|
||||
|
||||
@@ -240,7 +256,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (limb.WorldPosition != worldPosition && force > 0.0f)
|
||||
if (limb.WorldPosition != worldPosition && !MathUtils.NearlyEqual(force, 0.0f))
|
||||
{
|
||||
Vector2 limbDiff = Vector2.Normalize(limb.WorldPosition - worldPosition);
|
||||
if (!MathUtils.IsValid(limbDiff)) limbDiff = Rand.Vector(1.0f);
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace Barotrauma
|
||||
set { open = MathHelper.Clamp(value, 0.0f, 1.0f); }
|
||||
}
|
||||
|
||||
public float Size => IsHorizontal ? Rect.Height : Rect.Width;
|
||||
|
||||
public Door ConnectedDoor;
|
||||
|
||||
public Structure ConnectedWall;
|
||||
|
||||
@@ -228,13 +228,16 @@ namespace Barotrauma
|
||||
|
||||
surface = rect.Y - rect.Height;
|
||||
|
||||
aiTarget = new AITarget(this)
|
||||
if (submarine != null)
|
||||
{
|
||||
MinSightRange = 2000,
|
||||
MaxSightRange = 5000,
|
||||
MaxSoundRange = 5000,
|
||||
SoundRange = 0
|
||||
};
|
||||
aiTarget = new AITarget(this)
|
||||
{
|
||||
MinSightRange = 2000,
|
||||
MaxSightRange = 5000,
|
||||
MaxSoundRange = 5000,
|
||||
SoundRange = 0
|
||||
};
|
||||
}
|
||||
|
||||
hullList.Add(this);
|
||||
|
||||
@@ -430,8 +433,11 @@ namespace Barotrauma
|
||||
|
||||
FireSource.UpdateAll(FireSources, deltaTime);
|
||||
|
||||
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
|
||||
aiTarget.SoundRange -= deltaTime * 1000.0f;
|
||||
if (aiTarget != null)
|
||||
{
|
||||
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
|
||||
aiTarget.SoundRange -= deltaTime * 1000.0f;
|
||||
}
|
||||
|
||||
if (!update)
|
||||
{
|
||||
@@ -594,16 +600,17 @@ namespace Barotrauma
|
||||
{
|
||||
adjacentHulls.Clear();
|
||||
int startStep = 0;
|
||||
return GetAdjacentHulls(includingThis, adjacentHulls, ref startStep, searchDepth);
|
||||
searchDepth = searchDepth ?? 100;
|
||||
return GetAdjacentHulls(includingThis, adjacentHulls, ref startStep, searchDepth.Value);
|
||||
}
|
||||
|
||||
private HashSet<Hull> GetAdjacentHulls(bool includingThis, HashSet<Hull> connectedHulls, ref int step, int? searchDepth)
|
||||
private HashSet<Hull> GetAdjacentHulls(bool includingThis, HashSet<Hull> connectedHulls, ref int step, int searchDepth)
|
||||
{
|
||||
if (includingThis)
|
||||
{
|
||||
connectedHulls.Add(this);
|
||||
}
|
||||
if (step > searchDepth.Value)
|
||||
if (step > searchDepth)
|
||||
{
|
||||
return connectedHulls;
|
||||
}
|
||||
@@ -642,7 +649,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (Gap g in ConnectedGaps)
|
||||
{
|
||||
if (g.ConnectedDoor != null)
|
||||
if (g.ConnectedDoor != null && !g.ConnectedDoor.IsBroken)
|
||||
{
|
||||
//gap blocked if the door is not open or the predicted state is not open
|
||||
if (!g.ConnectedDoor.IsOpen || (g.ConnectedDoor.PredictedState.HasValue && !g.ConnectedDoor.PredictedState.Value))
|
||||
@@ -660,7 +667,7 @@ namespace Barotrauma
|
||||
if (g.linkedTo[i] is Hull hull && !connectedHulls.Contains(hull))
|
||||
{
|
||||
float dist = hull.GetApproximateHullDistance(g.Position, endPos, connectedHulls, target, distance + Vector2.Distance(startPos, g.Position), maxDistance);
|
||||
if (dist < float.MaxValue) return dist;
|
||||
if (dist < float.MaxValue) { return dist; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,24 @@ namespace Barotrauma.RuinGeneration
|
||||
this.rect = rect;
|
||||
}
|
||||
|
||||
public void Split(float minDivRatio, float verticalProbability = 0.5f, int minWidth = 200)
|
||||
public void Split(float minDivRatio, float verticalProbability = 0.5f, int minWidth = 200, int minHeight = 200)
|
||||
{
|
||||
subRooms = new BTRoom[2];
|
||||
bool verticalSplit = Rand.Range(0.0f, rect.Height / (float)rect.Width, Rand.RandSync.Server) < verticalProbability;
|
||||
if (rect.Width * minDivRatio < minWidth && rect.Height * minDivRatio < minHeight)
|
||||
{
|
||||
minDivRatio = 0.5f;
|
||||
}
|
||||
else if (rect.Width * minDivRatio < minWidth)
|
||||
{
|
||||
verticalSplit = false;
|
||||
}
|
||||
else if (rect.Height * minDivRatio < minHeight)
|
||||
{
|
||||
verticalSplit = true;
|
||||
}
|
||||
|
||||
if (Rand.Range(0.0f, rect.Height / (float)rect.Width, Rand.RandSync.Server) < verticalProbability &&
|
||||
rect.Width * minDivRatio >= minWidth)
|
||||
subRooms = new BTRoom[2];
|
||||
if (verticalSplit)
|
||||
{
|
||||
SplitVertical(minDivRatio);
|
||||
}
|
||||
|
||||
@@ -69,12 +69,18 @@ namespace Barotrauma.RuinGeneration
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(400, false, description: "The splitting algorithm attempts to keep the dimensions the split areas larger than this. For example, if the width of the split areas would be smaller than this after a vertical split, the algorithm will do a horizontal split."), Editable]
|
||||
[Serialize(400, false, description: "The splitting algorithm attempts to keep the width of the split areas larger than this. If the width of the split areas would be smaller than this after a vertical split, the algorithm would do a horizontal split."), Editable]
|
||||
public int MinSplitWidth
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
[Serialize(400, false, description: "The splitting algorithm attempts to keep the height of the split areas larger than this. If the height of the split areas would be smaller than this after a vertical split, the algorithm would do a horizontal split."), Editable]
|
||||
public int MinSplitHeight
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("0.5,0.9", false, description: "The minimum and maximum width of a room relative to the areas created by the split algorithm."), Editable]
|
||||
public Vector2 RoomWidthRange
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
rooms.ForEach(l => l.Split(0.3f, verticalProbability, generationParams.MinSplitWidth));
|
||||
rooms.ForEach(l => l.Split(0.3f, verticalProbability, generationParams.MinSplitWidth, generationParams.MinSplitHeight));
|
||||
rooms = baseRoom.GetLeaves();
|
||||
}
|
||||
|
||||
@@ -559,6 +559,11 @@ namespace Barotrauma.RuinGeneration
|
||||
foreach (MapEntity e in entities)
|
||||
{
|
||||
e.Move(doorOffset);
|
||||
Door doorComponent = (e as Item)?.GetComponent<Door>();
|
||||
if (doorComponent != null && !entities.Contains(doorComponent.LinkedGap))
|
||||
{
|
||||
doorComponent.LinkedGap.Move(doorOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Barotrauma
|
||||
LocationConnection connection = Connections[(MissionsCompleted + i) % Connections.Count];
|
||||
Location destination = connection.OtherLocation(this);
|
||||
|
||||
var mission = Mission.LoadRandom(new Location[] { this, destination }, rand, true, MissionType.Random, true);
|
||||
var mission = Mission.LoadRandom(new Location[] { this, destination }, rand, true, MissionType.All, true);
|
||||
if (mission == null) { continue; }
|
||||
if (availableMissions.Any(m => m.Prefab == mission.Prefab)) { continue; }
|
||||
if (GameSettings.VerboseLogging && mission != null)
|
||||
@@ -65,7 +65,11 @@ namespace Barotrauma
|
||||
|
||||
public int SelectedMissionIndex
|
||||
{
|
||||
get { return availableMissions.IndexOf(SelectedMission); }
|
||||
get
|
||||
{
|
||||
if (SelectedMission == null) { return -1; }
|
||||
return availableMissions.IndexOf(SelectedMission);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value >= AvailableMissions.Count())
|
||||
|
||||
@@ -73,15 +73,7 @@ namespace Barotrauma
|
||||
return !DrawBelowWater;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool DrawDamageEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual bool Linkable
|
||||
{
|
||||
get { return false; }
|
||||
@@ -344,6 +336,7 @@ namespace Barotrauma
|
||||
structure.Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
|
||||
//update gaps in random order, because otherwise in rooms with multiple gaps
|
||||
//the water/air will always tend to flow through the first gap in the list,
|
||||
//which may lead to weird behavior like water draining down only through
|
||||
@@ -353,6 +346,7 @@ namespace Barotrauma
|
||||
gap.Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
Powered.UpdatePower(deltaTime);
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
item.Update(deltaTime, cam);
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace Barotrauma
|
||||
|
||||
public static string GetShortHash(string fullHash)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fullHash)) { return ""; }
|
||||
return fullHash.Length < 7 ? fullHash : fullHash.Substring(0, 7);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override bool DrawDamageEffect
|
||||
public bool DrawDamageEffect
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -206,6 +206,14 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private Rectangle defaultRect;
|
||||
/// <summary>
|
||||
/// Unscaled rect
|
||||
/// </summary>
|
||||
public Rectangle DefaultRect
|
||||
{
|
||||
get { return defaultRect; }
|
||||
set { defaultRect = value; }
|
||||
}
|
||||
|
||||
public override Rectangle Rect
|
||||
{
|
||||
|
||||
@@ -83,6 +83,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public JobPrefab AssignedJob
|
||||
{
|
||||
get { return assignedJob; }
|
||||
}
|
||||
|
||||
public WayPoint(Vector2 position, SpawnType spawnType, Submarine submarine, Gap gap = null)
|
||||
: this(new Rectangle((int)position.X - 3, (int)position.Y + 3, 6, 6), submarine)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user