v0.12.0.2

This commit is contained in:
Joonas Rikkonen
2021-02-10 17:08:21 +02:00
parent 5c80a59bdd
commit 694cdfee7b
353 changed files with 12897 additions and 5028 deletions
@@ -11,6 +11,9 @@ namespace Barotrauma
{
public float RotationState;
public float OffsetState;
public Vector2 RandomOffsetMultiplier = new Vector2(Rand.Range(-1.0f, 1.0f), Rand.Range(-1.0f, 1.0f));
public float RandomRotationFactor = Rand.Range(0.0f, 1.0f);
public float RandomScaleFactor = Rand.Range(0.0f, 1.0f);
public bool IsActive = true;
}
@@ -29,6 +32,9 @@ namespace Barotrauma
[Serialize("0,0", true), Editable]
public Vector2 Offset { get; private set; }
[Serialize("0,0", true), Editable]
public Vector2 RandomOffset { get; private set; }
[Serialize(AnimationType.None, false), Editable]
public AnimationType OffsetAnim { get; private set; }
@@ -66,6 +72,20 @@ namespace Barotrauma
}
}
private Vector2 randomRotationRadians;
[Serialize("0,0", true), Editable]
public Vector2 RandomRotation
{
get
{
return new Vector2(MathHelper.ToDegrees(randomRotationRadians.X), MathHelper.ToDegrees(randomRotationRadians.Y));
}
private set
{
randomRotationRadians = new Vector2(MathHelper.ToRadians(value.X), MathHelper.ToRadians(value.Y));
}
}
private float scale;
[Serialize(1.0f, true), Editable]
public float Scale
@@ -74,6 +94,13 @@ namespace Barotrauma
private set { scale = MathHelper.Clamp(value, 0.0f, 10.0f); }
}
[Serialize("0,0", true), Editable]
public Vector2 RandomScale
{
get;
private set;
}
[Serialize(AnimationType.None, false), Editable]
public AnimationType RotationAnim { get; private set; }
@@ -99,9 +126,10 @@ namespace Barotrauma
{
Sprite = new Sprite(element, path, file, lazyLoad: lazyLoad);
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
// TODO: what's the purpose of this?
// load property conditionals
foreach (XElement subElement in element.Elements())
{
//choose which list the new conditional should be placed to
List<PropertyConditional> conditionalList = null;
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -125,7 +153,7 @@ namespace Barotrauma
}
}
public Vector2 GetOffset(ref float offsetState, float rotation = 0.0f)
public Vector2 GetOffset(ref float offsetState, Vector2 randomOffsetMultiplier, float rotation = 0.0f)
{
Vector2 offset = Offset;
if (OffsetAnimSpeed > 0.0f)
@@ -146,6 +174,9 @@ namespace Barotrauma
break;
}
}
offset += new Vector2(
RandomOffset.X * randomOffsetMultiplier.X,
RandomOffset.Y * randomOffsetMultiplier.Y);
if (Math.Abs(rotation) > 0.01f)
{
Matrix transform = Matrix.CreateRotationZ(rotation);
@@ -154,24 +185,40 @@ namespace Barotrauma
return offset;
}
public float GetRotation(ref float rotationState)
public float GetRotation(ref float rotationState, float randomRotationFactor)
{
RotationSpeed = -Math.Abs(RotationSpeed);
switch (RotationAnim)
{
case AnimationType.Sine:
rotationState %= MathHelper.TwoPi / absRotationSpeedRadians;
return rotationRadians * (float)Math.Sin(rotationState * rotationSpeedRadians);
return
rotationRadians * (float)Math.Sin(rotationState * rotationSpeedRadians)
+ MathHelper.Lerp(randomRotationRadians.X, randomRotationRadians.Y, randomRotationFactor);
case AnimationType.Noise:
rotationState %= 1.0f / absRotationSpeedRadians;
return rotationRadians * (PerlinNoise.GetPerlin(rotationState * absRotationSpeedRadians, rotationState * absRotationSpeedRadians) - 0.5f);
return
rotationRadians * (PerlinNoise.GetPerlin(rotationState * absRotationSpeedRadians, rotationState * absRotationSpeedRadians) - 0.5f)
+ MathHelper.Lerp(randomRotationRadians.X, randomRotationRadians.Y, randomRotationFactor);
default:
return rotationState * rotationSpeedRadians;
return
rotationRadians +
rotationState * rotationSpeedRadians
+ MathHelper.Lerp(randomRotationRadians.X, randomRotationRadians.Y, randomRotationFactor);
}
}
public static void UpdateSpriteStates(Dictionary<int, List<DecorativeSprite>> spriteGroups, Dictionary<DecorativeSprite, State> animStates,
int entityID, float deltaTime, Func<PropertyConditional,bool> checkConditional)
public float GetScale(float randomScaleModifier)
{
if (RandomScale == Vector2.Zero)
{
return scale;
}
return MathHelper.Lerp(RandomScale.X, RandomScale.Y, randomScaleModifier);
}
public static void UpdateSpriteStates(Dictionary<int, List<DecorativeSprite>> spriteGroups, Dictionary<DecorativeSprite, State> animStates,
int entityID, float deltaTime, Func<PropertyConditional, bool> checkConditional)
{
foreach (int spriteGroup in spriteGroups.Keys)
{
@@ -23,13 +23,13 @@ namespace Barotrauma.SpriteDeformations
/// <summary>
/// How fast the sprite reacts to being stretched
/// </summary>
[Serialize(1.0f, true, description: "How fast the sprite reacts to being stretched"), Editable(MinValueFloat = 0.0f, MaxValueFloat = 10.0f)]
[Serialize(10.0f, true, description: "How fast the sprite reacts to being stretched"), Editable(MinValueFloat = 0.0f, MaxValueFloat = 10.0f)]
public float ReactionSpeed { get; set; }
/// <summary>
/// How fast the sprite returns back to normal after stretching ends
/// </summary>
[Serialize(0.1f, true, description: "How fast the sprite returns back to normal after stretching ends"), Editable(MinValueFloat = 0.0f, MaxValueFloat = 10.0f)]
[Serialize(0.05f, true, description: "How fast the sprite returns back to normal after stretching ends"), Editable(MinValueFloat = 0.0f, MaxValueFloat = 10.0f)]
public float RecoverSpeed { get; set; }
public PositionalDeformationParams(XElement element) : base(element)
@@ -56,13 +56,13 @@ namespace Barotrauma.SpriteDeformations
public override void Update(float deltaTime)
{
if (positionalDeformationParams.RecoverSpeed <= 0.0f) return;
if (positionalDeformationParams.RecoverSpeed <= 0.0f) { return; }
for (int x = 0; x < Resolution.X; x++)
{
for (int y = 0; y < Resolution.Y; y++)
{
if (Deformation[x,y].LengthSquared() < 0.0001f)
if (Deformation[x,y].LengthSquared() < 0.000001f)
{
Deformation[x, y] = Vector2.Zero;
continue;
@@ -78,9 +78,9 @@ namespace Barotrauma.SpriteDeformations
{
Vector2 pos = Vector2.Transform(worldPosition, transformMatrix);
Point deformIndex = new Point((int)(pos.X * (Resolution.X - 1)), (int)(pos.Y * (Resolution.Y - 1)));
if (deformIndex.X < 0 || deformIndex.Y < 0) return;
if (deformIndex.X >= Resolution.X || deformIndex.Y >= Resolution.Y) return;
if (deformIndex.X < 0 || deformIndex.Y < 0) { return; }
if (deformIndex.X >= Resolution.X || deformIndex.Y >= Resolution.Y) { return; }
amount = amount.ClampLength(positionalDeformationParams.MaxDeformation);
@@ -296,7 +296,7 @@ namespace Barotrauma
Matrix matrix = GetTransform(pos, origin, rotate, scale);
effect.Parameters["xTransform"].SetValue(matrix * cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f);
* Matrix.CreateOrthographic(cam.Resolution.X, cam.Resolution.Y, -1, 1) * 0.5f);
effect.Parameters["tintColor"].SetValue(color.ToVector4());
effect.Parameters["deformArray"].SetValue(deformAmount);
effect.Parameters["deformArrayWidth"].SetValue(deformArrayWidth);