Loads and loads of small improvements I added while developing on my game

This commit is contained in:
Michel Fedde 2021-03-02 19:54:19 +01:00
parent 41421b1df9
commit a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions

View file

@ -7,11 +7,15 @@ namespace SM.Base.Types
/// A One-dimensional Vector (also known as <see cref="float"/>), in a class.
/// </summary>
public class CVector1
{
{
/// <summary>
/// X - Component
/// </summary>
public float X { get; set; }
public float X
{
get;
set;
}
/// <summary>
/// The length/magnitute of the vector.
@ -26,6 +30,8 @@ namespace SM.Base.Types
/// </remarks>
public float LengthSquared => GetLength(true);
public event Action Changed;
/// <summary>
/// Creates a class vector
/// </summary>
@ -63,14 +69,16 @@ namespace SM.Base.Types
/// Sets the X-Component.
/// </summary>
/// <param name="x">X-Component</param>
public virtual void Set(float uniform)
public virtual void Set(float uniform, bool triggerChanged = true)
{
X = uniform;
if (triggerChanged) TriggerChanged();
}
public virtual void Add(float uniform)
public virtual void Add(float uniform, bool triggerChanged = true)
{
X += uniform;
if (triggerChanged) TriggerChanged();
}
/// <summary>
@ -82,15 +90,20 @@ namespace SM.Base.Types
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
public static implicit operator CVector1(float f) => new CVector1(f);
//public static implicit operator CVector1(float f) => new CVector1(f);
private protected virtual float GetLengthProcess()
protected virtual float GetLengthProcess()
{
return X * X;
}
private protected virtual void NormalizationProcess(float length)
protected virtual void NormalizationProcess(float length)
{
X *= length;
}
protected void TriggerChanged()
{
Changed?.Invoke();
}
}
}

View file

@ -29,12 +29,12 @@ namespace SM.Base.Types
Y = y;
}
private protected override float GetLengthProcess()
protected override float GetLengthProcess()
{
return base.GetLengthProcess() + Y * Y;
}
private protected override void NormalizationProcess(float length)
protected override void NormalizationProcess(float length)
{
base.NormalizationProcess(length);
Y *= length;
@ -44,19 +44,19 @@ namespace SM.Base.Types
/// Sets each component to the same value
/// </summary>
/// <param name="uniform"></param>
public override void Set(float uniform)
public override void Set(float uniform, bool triggerChanged = true)
{
base.Set(uniform);
Y = uniform;
base.Set(uniform, triggerChanged);
}
/// <summary>
/// Sets each component to the <see cref="Vector2"/> counter-part.
/// </summary>
/// <param name="vector"></param>
public void Set(Vector2 vector)
public void Set(Vector2 vector, bool triggerChanged = true)
{
Set(vector.X, vector.Y);
Set(vector.X, vector.Y, triggerChanged);
}
/// <summary>
@ -64,27 +64,27 @@ namespace SM.Base.Types
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
public void Set(float x, float y)
public void Set(float x, float y, bool triggerChanged = true)
{
base.Set(x);
Y = y;
base.Set(x, triggerChanged);
}
public override void Add(float uniform)
public override void Add(float uniform, bool triggerChanged = true)
{
base.Add(uniform);
Y += uniform;
base.Add(uniform, triggerChanged);
}
public void Add(Vector2 vector)
public void Add(Vector2 vector, bool triggerChanged = true)
{
Add(vector.X, vector.Y);
Add(vector.X, vector.Y, triggerChanged);
}
public void Add(float x, float y)
public void Add(float x, float y, bool triggerChanged = true)
{
base.Add(x);
Y += y;
base.Add(x, triggerChanged);
}
/// <summary>

View file

@ -28,56 +28,56 @@ namespace SM.Base.Types
Z = z;
}
private protected override float GetLengthProcess()
protected override float GetLengthProcess()
{
return base.GetLengthProcess() + Z * Z;
}
private protected override void NormalizationProcess(float length)
protected override void NormalizationProcess(float length)
{
base.NormalizationProcess(length);
Z *= length;
}
/// <inheritdoc />
public override void Set(float uniform)
public override void Set(float uniform, bool triggerChanged = true)
{
base.Set(uniform);
Z = uniform;
base.Set(uniform, triggerChanged);
}
/// <summary>
/// Sets the a own value to each component.
/// </summary>
public void Set(float x, float y, float z)
public void Set(float x, float y, float z, bool triggerChanged = true)
{
base.Set(x,y);
Z = z;
base.Set(x,y, triggerChanged);
}
/// <summary>
/// Sets each component to the <see cref="Vector3"/> counter-part.
/// </summary>
/// <param name="vector"></param>
public void Set(Vector3 vector)
public void Set(Vector3 vector, bool triggerChanged = true)
{
Set(vector.X, vector.Y, vector.Z);
Set(vector.X, vector.Y, vector.Z, triggerChanged);
}
public override void Add(float uniform)
public override void Add(float uniform, bool triggerChanged = true)
{
base.Add(uniform);
Z += uniform;
base.Add(uniform, triggerChanged);
}
public void Add(Vector3 vector)
public void Add(Vector3 vector, bool triggerChanged = true)
{
Add(vector.X, vector.Y, vector.Z);
Add(vector.X, vector.Y, vector.Z, triggerChanged);
}
public void Add(float x, float y, float z)
public void Add(float x, float y, float z, bool triggerChanged = true)
{
base.Add(x,y);
Z += z;
base.Add(x,y, triggerChanged);
}
/// <summary>