Compare commits
4 Commits
fe0173b091
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 816d6e1846 | |||
| cb1e0aa0a7 | |||
| b35124aa6d | |||
| c11aced8d2 |
@@ -12,17 +12,18 @@ public class BasicConfiguration : IConfiguration
|
||||
|
||||
public IReadOnlyDictionary<string, object?> Values => values;
|
||||
|
||||
public T? Get<T>(string key, T? defaultValue = default)
|
||||
public T Get<T>(string key, T defaultValue) => Get<T>(key) ?? defaultValue;
|
||||
public T? Get<T>(string key)
|
||||
{
|
||||
if (!values.TryGetValue(key, out object? value))
|
||||
return defaultValue;
|
||||
return default;
|
||||
|
||||
if (value is T castedObject)
|
||||
return castedObject;
|
||||
|
||||
try { return (T?)System.Convert.ChangeType(value, typeof(T)); } catch { }
|
||||
|
||||
return defaultValue;
|
||||
return default;
|
||||
}
|
||||
|
||||
public object? Get(string key)
|
||||
|
||||
@@ -15,7 +15,8 @@ public interface IConfiguration
|
||||
|
||||
bool Has(string key);
|
||||
object? Get(string key);
|
||||
T? Get<T>(string key, T? defaultValue = default);
|
||||
T Get<T>(string key, T defaultValue);
|
||||
T? Get<T>(string key);
|
||||
void Set<T>(string key, T value);
|
||||
void Remove<T>(string key);
|
||||
|
||||
|
||||
@@ -95,7 +95,11 @@ public readonly struct ColorRGB(byte r, byte g, byte b) : IEquatable<ColorRGB>
|
||||
int greenDiff = to.G - from.G;
|
||||
int blueDiff = to.B - from.B;
|
||||
|
||||
return from + new ColorRGB((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t));
|
||||
return new(
|
||||
(byte)(from.R + redDiff * t),
|
||||
(byte)(from.G + greenDiff * t),
|
||||
(byte)(from.B + blueDiff * t)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Engine.Core.Debug;
|
||||
|
||||
namespace Engine.Core;
|
||||
|
||||
@@ -125,7 +126,12 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255) : IEquata
|
||||
int blueDiff = to.B - from.B;
|
||||
int alphaDiff = to.A - from.A;
|
||||
|
||||
return from + new ColorRGBA((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t), (byte)(alphaDiff * t));
|
||||
return new(
|
||||
(byte)(from.R + redDiff * t),
|
||||
(byte)(from.G + greenDiff * t),
|
||||
(byte)(from.B + blueDiff * t),
|
||||
(byte)(from.A + alphaDiff * t)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
Vector2 A = triangle.A.ToVector2();
|
||||
Vector2 B = triangle.B.ToVector2();
|
||||
Vector2 C = triangle.C.ToVector2();
|
||||
Color color = colorRGBA.ToColor();
|
||||
Color color = colorRGBA.ToPreMultipliedColor();
|
||||
|
||||
vertices[verticesIndex++] = new(new(A.X, A.Y, 0f), color);
|
||||
vertices[verticesIndex++] = new(new(B.X, B.Y, 0f), color);
|
||||
@@ -60,6 +60,8 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
return;
|
||||
|
||||
graphicsDevice.RasterizerState = rasterizerState;
|
||||
graphicsDevice.BlendState = BlendState.AlphaBlend;
|
||||
|
||||
basicEffect.Projection = projection;
|
||||
basicEffect.View = view;
|
||||
vertexBuffer.SetData(vertices);
|
||||
@@ -67,8 +69,10 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
graphicsDevice.SetVertexBuffer(vertexBuffer);
|
||||
|
||||
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, verticesIndex / 3);
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, verticesIndex / 3);
|
||||
}
|
||||
|
||||
verticesIndex = 0;
|
||||
}
|
||||
|
||||
1
Engine.Serializers/YamlDotNet
Submodule
1
Engine.Serializers/YamlDotNet
Submodule
Submodule Engine.Serializers/YamlDotNet added at 62048d7abe
Reference in New Issue
Block a user