Merge branch 'master' into moRags
This commit is contained in:
@@ -74,6 +74,15 @@ namespace Barotrauma
|
||||
{
|
||||
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;
|
||||
while (container != null)
|
||||
{
|
||||
if (container.FireProof) return;
|
||||
container = container.Container;
|
||||
}
|
||||
|
||||
if (Vector2.Distance(item.WorldPosition, worldPosition) > attack.Range * 0.1f) continue;
|
||||
|
||||
item.ApplyStatusEffects(ActionType.OnFire, 1.0f);
|
||||
|
||||
@@ -217,7 +217,15 @@ namespace Barotrauma
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue;
|
||||
if (item.ParentInventory != null && item.ParentInventory.Owner is Character) return;
|
||||
|
||||
//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;
|
||||
while (container != null)
|
||||
{
|
||||
if (container.FireProof) return;
|
||||
container = container.Container;
|
||||
}
|
||||
|
||||
float range = (float)Math.Sqrt(size.X) * 10.0f;
|
||||
if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue;
|
||||
|
||||
@@ -163,8 +163,11 @@ namespace Barotrauma
|
||||
searchPos[1] = new Vector2(rect.Center.X, rect.Y - rect.Height);
|
||||
}
|
||||
|
||||
hulls[0] = Hull.FindHullOld(searchPos[0], null, false);
|
||||
hulls[1] = Hull.FindHullOld(searchPos[1], null, false);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
hulls[i] = Hull.FindHullOld(searchPos[i], null, false);
|
||||
if (hulls[i] == null) hulls[i] = Hull.FindHullOld(searchPos[i], null, false, true);
|
||||
}
|
||||
|
||||
if (hulls[0] == null && hulls[1] == null) return;
|
||||
|
||||
|
||||
@@ -558,23 +558,23 @@ namespace Barotrauma
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//returns the water block which contains the point (or null if it isn't inside any)
|
||||
public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true)
|
||||
public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false)
|
||||
{
|
||||
return FindHullOld(position, hullList, guess, useWorldCoordinates);
|
||||
return FindHullOld(position, hullList, guess, useWorldCoordinates, inclusive);
|
||||
}
|
||||
|
||||
public static Hull FindHullOld(Vector2 position, List<Hull> hulls, Hull guess = null, bool useWorldCoordinates = true)
|
||||
public static Hull FindHullOld(Vector2 position, List<Hull> hulls, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false)
|
||||
{
|
||||
if (guess != null && hulls.Contains(guess))
|
||||
{
|
||||
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess;
|
||||
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position, inclusive)) return guess;
|
||||
}
|
||||
|
||||
foreach (Hull hull in hulls)
|
||||
{
|
||||
if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position)) return hull;
|
||||
if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position, inclusive)) return hull;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -817,7 +817,7 @@ namespace Barotrauma
|
||||
//50% chance of placing the ruins at a cave
|
||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.5f)
|
||||
{
|
||||
TryGetInterestingPosition(true, PositionType.Cave, false, out ruinPos);
|
||||
TryGetInterestingPosition(true, PositionType.Cave, 0.0f, out ruinPos);
|
||||
}
|
||||
|
||||
ruinPos.Y = Math.Min(ruinPos.Y, borders.Y + borders.Height - ruinSize.Y / 2);
|
||||
@@ -894,7 +894,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float offsetFromWall = 10.0f)
|
||||
public Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float minDistFromSubs, float offsetFromWall = 10.0f)
|
||||
{
|
||||
if (!positionsOfInterest.Any()) return Size*0.5f;
|
||||
|
||||
@@ -906,7 +906,7 @@ namespace Barotrauma
|
||||
do
|
||||
{
|
||||
Vector2 startPos;
|
||||
Level.Loaded.TryGetInterestingPosition(true, spawnPosType, true, out startPos);
|
||||
Loaded.TryGetInterestingPosition(true, spawnPosType, minDistFromSubs, out startPos);
|
||||
|
||||
startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, Rand.RandSync.Server), Rand.RandSync.Server);
|
||||
|
||||
@@ -935,7 +935,7 @@ namespace Barotrauma
|
||||
|
||||
|
||||
|
||||
public bool TryGetInterestingPosition(bool useSyncedRand, PositionType positionType, bool avoidSubs, out Vector2 position)
|
||||
public bool TryGetInterestingPosition(bool useSyncedRand, PositionType positionType, float minDistFromSubs, out Vector2 position)
|
||||
{
|
||||
if (!positionsOfInterest.Any())
|
||||
{
|
||||
@@ -945,17 +945,20 @@ namespace Barotrauma
|
||||
|
||||
var matchingPositions = positionsOfInterest.FindAll(p => positionType.HasFlag(p.PositionType));
|
||||
|
||||
if (avoidSubs)
|
||||
if (minDistFromSubs > 0.0f)
|
||||
{
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
float minDist = Math.Max(sub.Borders.Width, sub.Borders.Height);
|
||||
matchingPositions.RemoveAll(p => Vector2.Distance(p.Position, sub.WorldPosition) < minDist);
|
||||
matchingPositions.RemoveAll(p => Vector2.DistanceSquared(p.Position, sub.WorldPosition) < minDistFromSubs * minDistFromSubs);
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchingPositions.Any())
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + "\n" + Environment.StackTrace);
|
||||
#endif
|
||||
|
||||
position = positionsOfInterest[Rand.Int(positionsOfInterest.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -506,15 +506,15 @@ namespace Barotrauma
|
||||
|
||||
float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f;
|
||||
|
||||
if (impact < 10.0f) return true;
|
||||
|
||||
#if CLIENT
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact,
|
||||
new Vector2(
|
||||
sections[section].rect.X + sections[section].rect.Width / 2,
|
||||
sections[section].rect.Y - sections[section].rect.Height / 2));
|
||||
sections[section].rect.X + sections[section].rect.Width / 2,
|
||||
sections[section].rect.Y - sections[section].rect.Height / 2), tags: Tags);
|
||||
#endif
|
||||
|
||||
if (impact < 10.0f) return true;
|
||||
|
||||
AddDamage(section, impact);
|
||||
}
|
||||
}
|
||||
@@ -661,10 +661,10 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
|
||||
|
||||
if (playSound && !SectionBodyDisabled(i))
|
||||
if (playSound)// && !SectionBodyDisabled(i))
|
||||
{
|
||||
DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash;
|
||||
SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition);
|
||||
SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition, tags: Tags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -491,10 +491,18 @@ namespace Barotrauma
|
||||
return new Rectangle((int)pos.X, (int)pos.Y, (int)size.X, (int)size.Y);
|
||||
}
|
||||
|
||||
public static bool RectContains(Rectangle rect, Vector2 pos)
|
||||
public static bool RectContains(Rectangle rect, Vector2 pos, bool inclusive = false)
|
||||
{
|
||||
return (pos.X > rect.X && pos.X < rect.X + rect.Width
|
||||
&& pos.Y < rect.Y && pos.Y > rect.Y - rect.Height);
|
||||
if (inclusive)
|
||||
{
|
||||
return (pos.X >= rect.X && pos.X <= rect.X + rect.Width
|
||||
&& pos.Y <= rect.Y && pos.Y >= rect.Y - rect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (pos.X > rect.X && pos.X < rect.X + rect.Width
|
||||
&& pos.Y < rect.Y && pos.Y > rect.Y - rect.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RectsOverlap(Rectangle rect1, Rectangle rect2, bool inclusive=true)
|
||||
@@ -1258,7 +1266,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
subBody.MemPos.Insert(index, new PosInfo(newTargetPosition, sendingTime));
|
||||
subBody.MemPos.Insert(index, new PosInfo(newTargetPosition, 0.0f, sendingTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Barotrauma
|
||||
protected SpawnType spawnType;
|
||||
|
||||
//characters spawning at the waypoint will be given an ID card with these tags
|
||||
private string idCardDesc;
|
||||
private string[] idCardTags;
|
||||
|
||||
//only characters with this job will be spawned at the waypoint
|
||||
@@ -57,6 +58,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public string IdCardDesc
|
||||
{
|
||||
get { return idCardDesc; }
|
||||
private set { idCardDesc = value; }
|
||||
}
|
||||
public string[] IdCardTags
|
||||
{
|
||||
get { return idCardTags; }
|
||||
@@ -113,6 +119,7 @@ namespace Barotrauma
|
||||
public override MapEntity Clone()
|
||||
{
|
||||
var clone = new WayPoint(rect, Submarine);
|
||||
clone.idCardDesc = idCardDesc;
|
||||
clone.idCardTags = idCardTags;
|
||||
clone.spawnType = spawnType;
|
||||
clone.assignedJob = assignedJob;
|
||||
@@ -570,6 +577,11 @@ namespace Barotrauma
|
||||
|
||||
Enum.TryParse<SpawnType>(element.GetAttributeString("spawn", "Path"), out w.spawnType);
|
||||
|
||||
string idCardDescString = element.GetAttributeString("idcarddesc", "");
|
||||
if (!string.IsNullOrWhiteSpace(idCardDescString))
|
||||
{
|
||||
w.IdCardDesc = idCardDescString;
|
||||
}
|
||||
string idCardTagString = element.GetAttributeString("idcardtags", "");
|
||||
if (!string.IsNullOrWhiteSpace(idCardTagString))
|
||||
{
|
||||
@@ -604,6 +616,7 @@ namespace Barotrauma
|
||||
new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)),
|
||||
new XAttribute("spawn", spawnType));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(idCardDesc)) element.Add(new XAttribute("idcarddesc", idCardDesc));
|
||||
if (idCardTags.Length > 0)
|
||||
{
|
||||
element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags)));
|
||||
|
||||
Reference in New Issue
Block a user