Release v0.15.12.0
This commit is contained in:
@@ -8,8 +8,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Abilities;
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Barotrauma.Lights;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -47,7 +49,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)
|
||||
@@ -96,7 +98,7 @@ namespace Barotrauma
|
||||
{
|
||||
get { return Prefab.Body; }
|
||||
}
|
||||
|
||||
|
||||
public List<Body> Bodies { get; private set; }
|
||||
|
||||
public bool CastShadow
|
||||
@@ -112,7 +114,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private float? maxHealth;
|
||||
|
||||
|
||||
[Serialize(100.0f, true)]
|
||||
public float MaxHealth
|
||||
{
|
||||
@@ -167,7 +169,7 @@ namespace Barotrauma
|
||||
{
|
||||
get { return prefab.Tags; }
|
||||
}
|
||||
|
||||
|
||||
protected Color spriteColor;
|
||||
[Editable, Serialize("1.0,1.0,1.0,1.0", true)]
|
||||
public Color SpriteColor
|
||||
@@ -175,7 +177,7 @@ namespace Barotrauma
|
||||
get { return spriteColor; }
|
||||
set { spriteColor = value; }
|
||||
}
|
||||
|
||||
|
||||
[Editable, Serialize(false, true)]
|
||||
public bool UseDropShadow
|
||||
{
|
||||
@@ -203,8 +205,8 @@ namespace Barotrauma
|
||||
|
||||
if (!ResizeHorizontal || !ResizeVertical)
|
||||
{
|
||||
int newWidth = ResizeHorizontal ? rect.Width : (int)(defaultRect.Width * relativeScale);
|
||||
int newHeight = ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale);
|
||||
int newWidth = Math.Max(ResizeHorizontal ? rect.Width : (int)(defaultRect.Width * relativeScale), 1);
|
||||
int newHeight = Math.Max(ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale), 1);
|
||||
Rect = new Rectangle(rect.X, rect.Y, newWidth, newHeight);
|
||||
if (StairDirection != Direction.None)
|
||||
{
|
||||
@@ -215,6 +217,13 @@ namespace Barotrauma
|
||||
UpdateSections();
|
||||
}
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
foreach (LightSource light in Lights)
|
||||
{
|
||||
light.SpriteScale = scale * textureScale;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +239,13 @@ namespace Barotrauma
|
||||
textureScale = new Vector2(
|
||||
MathHelper.Clamp(value.X, 0.01f, 10),
|
||||
MathHelper.Clamp(value.Y, 0.01f, 10));
|
||||
|
||||
#if CLIENT
|
||||
foreach (LightSource light in Lights)
|
||||
{
|
||||
light.LightTextureScale = textureScale * scale;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +254,13 @@ namespace Barotrauma
|
||||
public Vector2 TextureOffset
|
||||
{
|
||||
get { return textureOffset; }
|
||||
set { textureOffset = value; }
|
||||
set
|
||||
{
|
||||
textureOffset = value;
|
||||
#if CLIENT
|
||||
SetLightTextureOffset();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -281,10 +303,10 @@ namespace Barotrauma
|
||||
secRect.X += value.X; secRect.Y += value.Y;
|
||||
sec.rect = secRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float BodyWidth
|
||||
{
|
||||
get { return Prefab.BodyWidth > 0.0f ? Prefab.BodyWidth * scale : rect.Width; }
|
||||
@@ -363,6 +385,12 @@ namespace Barotrauma
|
||||
|
||||
#if CLIENT
|
||||
convexHulls?.ForEach(x => x.Move(amount));
|
||||
|
||||
foreach (LightSource light in Lights)
|
||||
{
|
||||
light.LightTextureTargetSize = rect.Size.ToVector2();
|
||||
light.Position = rect.Location.ToVector2();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -374,7 +402,7 @@ namespace Barotrauma
|
||||
defaultRect = rectangle;
|
||||
|
||||
maxHealth = sp.Health;
|
||||
|
||||
|
||||
rect = rectangle;
|
||||
TextureScale = sp.TextureScale;
|
||||
|
||||
@@ -426,25 +454,60 @@ namespace Barotrauma
|
||||
if (StairDirection != Direction.None)
|
||||
{
|
||||
CreateStairBodies();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SerializableProperties = element != null ? SerializableProperty.DeserializeProperties(this, element) : SerializableProperty.GetProperties(this);
|
||||
|
||||
// Only add ai targets automatically to submarine/outpost walls
|
||||
#if CLIENT
|
||||
foreach (XElement subElement in sp.ConfigElement.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("light", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Vector2 pos = rect.Location.ToVector2();
|
||||
pos.Y += rect.Height;
|
||||
LightSource light = new LightSource(subElement)
|
||||
{
|
||||
ParentSub = Submarine,
|
||||
Position = rect.Location.ToVector2(),
|
||||
CastShadows = false,
|
||||
IsBackground = false,
|
||||
Color = subElement.GetAttributeColor("lightcolor", Color.White),
|
||||
SpriteScale = Vector2.One,
|
||||
Range = 0,
|
||||
LightTextureTargetSize = rect.Size.ToVector2(),
|
||||
LightTextureScale = textureScale * scale,
|
||||
LightSourceParams =
|
||||
{
|
||||
Flicker = subElement.GetAttributeFloat("flicker", 0f),
|
||||
FlickerSpeed = subElement.GetAttributeFloat("flickerspeed", 0f),
|
||||
PulseAmount = subElement.GetAttributeFloat("pulseamount", 0f),
|
||||
PulseFrequency = subElement.GetAttributeFloat("pulsefrequency", 0f),
|
||||
BlinkFrequency = subElement.GetAttributeFloat("blinkfrequency", 0f)
|
||||
}
|
||||
};
|
||||
|
||||
Lights.Add(light);
|
||||
|
||||
SetLightTextureOffset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only add ai targets automatically to submarine/outpost walls
|
||||
if (aiTarget == null && HasBody && Tags.Contains("wall") && submarine != null && !submarine.Info.IsWreck && !NoAITarget)
|
||||
{
|
||||
aiTarget = new AITarget(this)
|
||||
{
|
||||
MinSightRange = 2000,
|
||||
MaxSightRange = 5000,
|
||||
MinSightRange = 1000,
|
||||
MaxSightRange = 4000,
|
||||
MaxSoundRange = 0
|
||||
};
|
||||
}
|
||||
|
||||
InsertToList();
|
||||
|
||||
|
||||
DebugConsole.Log("Created " + Name + " (" + ID + ")");
|
||||
}
|
||||
|
||||
@@ -476,7 +539,7 @@ namespace Barotrauma
|
||||
{
|
||||
Bodies = new List<Body>();
|
||||
bodyDebugDimensions.Clear();
|
||||
|
||||
|
||||
float stairAngle = MathHelper.ToRadians(Math.Min(Prefab.StairAngle, 75.0f));
|
||||
|
||||
float bodyWidth = ConvertUnits.ToSimUnits(rect.Width / Math.Cos(stairAngle));
|
||||
@@ -504,9 +567,9 @@ namespace Barotrauma
|
||||
{
|
||||
int xsections = 1, ysections = 1;
|
||||
int width = rect.Width, height = rect.Height;
|
||||
|
||||
|
||||
if (!HasBody)
|
||||
{
|
||||
{
|
||||
if (FlippedX && IsHorizontal)
|
||||
{
|
||||
xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width);
|
||||
@@ -548,8 +611,8 @@ namespace Barotrauma
|
||||
if (FlippedX || FlippedY)
|
||||
{
|
||||
Rectangle sectionRect = new Rectangle(
|
||||
FlippedX ? rect.Right - (x + 1) * width : rect.X + x * width,
|
||||
FlippedY ? rect.Y - rect.Height + (y + 1) * height : rect.Y - y * height,
|
||||
FlippedX ? rect.Right - (x + 1) * width : rect.X + x * width,
|
||||
FlippedY ? rect.Y - rect.Height + (y + 1) * height : rect.Y - y * height,
|
||||
width, height);
|
||||
|
||||
if (FlippedX)
|
||||
@@ -645,8 +708,8 @@ namespace Barotrauma
|
||||
|
||||
Vector2 transformedMousePos = MathUtils.RotatePointAroundTarget(position, bodyPos, BodyRotation);
|
||||
|
||||
return
|
||||
Math.Abs(transformedMousePos.X - bodyPos.X) < rectSize.X / 2.0f &&
|
||||
return
|
||||
Math.Abs(transformedMousePos.X - bodyPos.X) < rectSize.X / 2.0f &&
|
||||
Math.Abs(transformedMousePos.Y - bodyPos.Y) < rectSize.Y / 2.0f;
|
||||
}
|
||||
else
|
||||
@@ -692,6 +755,10 @@ namespace Barotrauma
|
||||
|
||||
#if CLIENT
|
||||
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
||||
foreach (LightSource light in Lights)
|
||||
{
|
||||
light.Remove();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -724,6 +791,10 @@ namespace Barotrauma
|
||||
|
||||
#if CLIENT
|
||||
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
||||
foreach (LightSource light in Lights)
|
||||
{
|
||||
light.Remove();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -781,7 +852,7 @@ namespace Barotrauma
|
||||
|
||||
return (IsHorizontal ? Sections[sectionIndex].rect.Width : Sections[sectionIndex].rect.Height);
|
||||
}
|
||||
|
||||
|
||||
public override bool AddUpgrade(Upgrade upgrade, bool createNetworkEvent = false)
|
||||
{
|
||||
if (!upgrade.Prefab.IsWallUpgrade) { return false; }
|
||||
@@ -799,7 +870,7 @@ namespace Barotrauma
|
||||
Upgrades.Add(upgrade);
|
||||
upgrade.ApplyUpgrade();
|
||||
}
|
||||
|
||||
|
||||
UpdateSections();
|
||||
|
||||
return true;
|
||||
@@ -914,7 +985,7 @@ namespace Barotrauma
|
||||
{
|
||||
diffFromCenter = -diffFromCenter;
|
||||
}
|
||||
|
||||
|
||||
Vector2 sectionPos = Position + new Vector2(
|
||||
(float)Math.Cos(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation),
|
||||
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation)) * diffFromCenter;
|
||||
@@ -925,7 +996,7 @@ namespace Barotrauma
|
||||
}
|
||||
return sectionPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(Character attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
|
||||
{
|
||||
@@ -948,13 +1019,28 @@ namespace Barotrauma
|
||||
GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#if CLIENT
|
||||
if (playSound && damageAmount > 0)
|
||||
{
|
||||
SoundPlayer.PlayDamageSound(attack.StructureSoundType, damageAmount, worldPosition, tags: Tags);
|
||||
string damageSound = Prefab.DamageSound;
|
||||
if (string.IsNullOrWhiteSpace(damageSound))
|
||||
{
|
||||
damageSound = attack.StructureSoundType;
|
||||
}
|
||||
SoundPlayer.PlayDamageSound(damageSound, damageAmount, worldPosition, tags: Tags);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Submarine != null && damageAmount > 0 && attacker != null)
|
||||
{
|
||||
var abilityAttackerSubmarine = new AbilityCharacterSubmarine(attacker, Submarine);
|
||||
foreach (Character character in Character.CharacterList)
|
||||
{
|
||||
character.CheckTalents(AbilityEffectType.AfterSubmarineAttacked, abilityAttackerSubmarine);
|
||||
}
|
||||
}
|
||||
|
||||
return new AttackResult(damageAmount, null);
|
||||
}
|
||||
|
||||
@@ -965,7 +1051,7 @@ namespace Barotrauma
|
||||
if (!MathUtils.IsValid(damage)) { return; }
|
||||
|
||||
damage = MathHelper.Clamp(damage, 0.0f, MaxHealth - Prefab.MinHealth);
|
||||
|
||||
|
||||
#if SERVER
|
||||
if (GameMain.Server != null && createNetworkEvent && damage != Sections[sectionIndex].damage)
|
||||
{
|
||||
@@ -1011,10 +1097,10 @@ namespace Barotrauma
|
||||
{
|
||||
diffFromCenter = (gapRect.Center.X - this.rect.Center.X) / (float)this.rect.Width * BodyWidth;
|
||||
if (BodyWidth > 0.0f) { gapRect.Width = (int)(BodyWidth * (gapRect.Width / (float)this.rect.Width)); }
|
||||
if (BodyHeight > 0.0f)
|
||||
{
|
||||
if (BodyHeight > 0.0f)
|
||||
{
|
||||
gapRect.Y = (gapRect.Y - gapRect.Height / 2) + (int)(BodyHeight / 2 + BodyOffset.Y * scale);
|
||||
gapRect.Height = (int)BodyHeight;
|
||||
gapRect.Height = (int)BodyHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1023,7 +1109,7 @@ namespace Barotrauma
|
||||
if (BodyWidth > 0.0f)
|
||||
{
|
||||
gapRect.X = gapRect.Center.X + (int)(-BodyWidth / 2 + BodyOffset.X * scale);
|
||||
gapRect.Width = (int)BodyWidth;
|
||||
gapRect.Width = (int)BodyWidth;
|
||||
}
|
||||
if (BodyHeight > 0.0f) { gapRect.Height = (int)(BodyHeight * (gapRect.Height / (float)this.rect.Height)); }
|
||||
}
|
||||
@@ -1042,7 +1128,7 @@ namespace Barotrauma
|
||||
gapRect.Y += 10;
|
||||
gapRect.Width += 20;
|
||||
gapRect.Height += 20;
|
||||
|
||||
|
||||
bool horizontalGap = !IsHorizontal;
|
||||
if (Prefab.BodyRotation != 0.0f)
|
||||
{
|
||||
@@ -1079,7 +1165,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float gapOpen = MaxHealth <= 0.0f ? 0.0f : (damage / MaxHealth - LeakThreshold) * (1.0f / (1.0f - LeakThreshold));
|
||||
Sections[sectionIndex].gap.Open = gapOpen;
|
||||
Sections[sectionIndex].gap.Open = gapOpen;
|
||||
}
|
||||
|
||||
float damageDiff = damage - Sections[sectionIndex].damage;
|
||||
@@ -1095,9 +1181,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (damageDiff < 0.0f)
|
||||
{
|
||||
attacker.Info?.IncreaseSkillLevel("mechanical",
|
||||
-damageDiff * SkillSettings.Current.SkillIncreasePerRepairedStructureDamage / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f),
|
||||
SectionPosition(sectionIndex));
|
||||
attacker.Info?.IncreaseSkillLevel("mechanical",
|
||||
-damageDiff * SkillSettings.Current.SkillIncreasePerRepairedStructureDamage / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1105,7 +1190,7 @@ namespace Barotrauma
|
||||
bool hasHole = SectionBodyDisabled(sectionIndex);
|
||||
|
||||
if (hadHole == hasHole) { return; }
|
||||
|
||||
|
||||
UpdateSections();
|
||||
}
|
||||
|
||||
@@ -1187,7 +1272,7 @@ namespace Barotrauma
|
||||
if (BodyHeight > 0.0f) rect.Height = Math.Max((int)Math.Round(BodyHeight * (rect.Height / (float)this.rect.Height)), 1);
|
||||
}
|
||||
if (FlippedX) { diffFromCenter = -diffFromCenter; }
|
||||
|
||||
|
||||
Vector2 bodyOffset = ConvertUnits.ToSimUnits(Prefab.BodyOffset) * scale;
|
||||
if (FlippedX) { bodyOffset.X = -bodyOffset.X; }
|
||||
if (FlippedY) { bodyOffset.Y = -bodyOffset.Y; }
|
||||
@@ -1229,7 +1314,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
partial void CreateConvexHull(Vector2 position, Vector2 size, float rotation);
|
||||
|
||||
|
||||
public override void FlipX(bool relativeToSub)
|
||||
{
|
||||
base.FlipX(relativeToSub);
|
||||
@@ -1250,7 +1335,7 @@ namespace Barotrauma
|
||||
|
||||
CreateStairBodies();
|
||||
}
|
||||
|
||||
|
||||
if (HasBody)
|
||||
{
|
||||
CreateSections();
|
||||
@@ -1377,7 +1462,7 @@ namespace Barotrauma
|
||||
StructurePrefab prefab = null;
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
{
|
||||
//legacy support:
|
||||
//legacy support:
|
||||
//1. attempt to find a prefab with an empty identifier and a matching name
|
||||
prefab = MapEntityPrefab.Find(name, "") as StructurePrefab;
|
||||
//2. not found, attempt to find a prefab with a matching name
|
||||
@@ -1422,7 +1507,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
SerializableProperty.SerializeProperties(this, element);
|
||||
|
||||
|
||||
foreach (var upgrade in Upgrades)
|
||||
{
|
||||
upgrade.Save(element);
|
||||
@@ -1453,7 +1538,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (aiTarget != null)
|
||||
{
|
||||
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
|
||||
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : MathHelper.Lerp(aiTarget.MinSightRange, aiTarget.MaxSightRange, Submarine.Velocity.Length() / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user