chore!: renamed AABB to AABB2D
This commit is contained in:
@@ -143,7 +143,7 @@ public abstract class LiteNetLibCommunicatorBase : Behaviour, INetworkCommunicat
|
||||
private void SetupEnginePackets()
|
||||
{
|
||||
// I know, ugly af. I need to find a better way
|
||||
netPacketProcessor.RegisterNestedType(AABBNetPacker.Write, AABBNetPacker.Read);
|
||||
netPacketProcessor.RegisterNestedType(AABB2DNetPacker.Write, AABB2DNetPacker.Read);
|
||||
netPacketProcessor.RegisterNestedType(CircleNetPacker.Write, CircleNetPacker.Read);
|
||||
netPacketProcessor.RegisterNestedType(ColorHSVNetPacker.Write, ColorHSVNetPacker.Read);
|
||||
netPacketProcessor.RegisterNestedType(ColorRGBANetPacker.Write, ColorRGBANetPacker.Read);
|
||||
|
@@ -4,19 +4,19 @@ using Engine.Core;
|
||||
|
||||
namespace Engine.Systems.Network;
|
||||
|
||||
internal static class AABBNetPacker
|
||||
internal static class AABB2DNetPacker
|
||||
{
|
||||
internal static void Write(NetDataWriter writer, AABB data)
|
||||
internal static void Write(NetDataWriter writer, AABB2D data)
|
||||
{
|
||||
Vector2DNetPacker.Write(writer, data.LowerBoundary);
|
||||
Vector2DNetPacker.Write(writer, data.UpperBoundary);
|
||||
}
|
||||
|
||||
internal static AABB Read(NetDataReader reader)
|
||||
internal static AABB2D Read(NetDataReader reader)
|
||||
{
|
||||
Vector2D lowerBoundary = Vector2DNetPacker.Read(reader);
|
||||
Vector2D upperBoundary = Vector2DNetPacker.Read(reader);
|
||||
|
||||
return new AABB(lowerBoundary, upperBoundary);
|
||||
return new AABB2D(lowerBoundary, upperBoundary);
|
||||
}
|
||||
}
|
@@ -10,13 +10,13 @@ namespace Engine.Integration.MonoGame;
|
||||
public interface ISpriteBatch
|
||||
{
|
||||
void Begin(SpriteSortMode sortMode = SpriteSortMode.Deferred, BlendState? blendState = null, SamplerState? samplerState = null, DepthStencilState? depthStencilState = null, RasterizerState? rasterizerState = null, Effect? effect = null, Matrix? transformMatrix = null);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color, float rotation, Vector2D origin, Vector2D scale, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color, float rotation, Vector2D origin, float scale, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, AABB destinationAABB, AABB? sourceAABB, Color color, float rotation, Vector2D origin, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color);
|
||||
void Draw(Texture2D texture, AABB destinationAABB, AABB? sourceAABB, Color color);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, Vector2D scale, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, float scale, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, AABB2D destinationAABB, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, SpriteEffects effects, float layerDepth);
|
||||
void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color);
|
||||
void Draw(Texture2D texture, AABB2D destinationAABB, AABB2D? sourceAABB, Color color);
|
||||
void Draw(Texture2D texture, Vector2D position, Color color);
|
||||
void Draw(Texture2D texture, AABB destinationAABB, Color color);
|
||||
void Draw(Texture2D texture, AABB2D destinationAABB, Color color);
|
||||
void DrawString(SpriteFont spriteFont, string text, Vector2D position, Color color);
|
||||
void DrawString(SpriteFont spriteFont, string text, Vector2D position, Color color, float rotation, Vector2D origin, float scale, SpriteEffects effects, float layerDepth);
|
||||
void DrawString(SpriteFont spriteFont, string text, Vector2D position, Color color, float rotation, Vector2D origin, Vector2D scale, SpriteEffects effects, float layerDepth);
|
||||
|
@@ -14,25 +14,25 @@ public class SpriteBatchWrapper(GraphicsDevice graphicsDevice) : ISpriteBatch
|
||||
public void Begin(SpriteSortMode sortMode = SpriteSortMode.Deferred, BlendState? blendState = null, SamplerState? samplerState = null, DepthStencilState? depthStencilState = null, RasterizerState? rasterizerState = null, Effect? effect = null, Matrix? transformMatrix = null)
|
||||
=> spriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, transformMatrix);
|
||||
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color, float rotation, Vector2D origin, Vector2D scale, SpriteEffects effects, float layerDepth)
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, Vector2D scale, SpriteEffects effects, float layerDepth)
|
||||
=> spriteBatch.Draw(texture, position.ToDisplayVector2(), sourceAABB?.ToRectangle(), color, rotation, origin.ToDisplayVector2(), scale.ToDisplayVector2(), effects, layerDepth);
|
||||
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color, float rotation, Vector2D origin, float scale, SpriteEffects effects, float layerDepth)
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, float scale, SpriteEffects effects, float layerDepth)
|
||||
=> spriteBatch.Draw(texture, position.ToDisplayVector2(), sourceAABB?.ToRectangle(), color, rotation, origin.ToDisplayVector2(), scale, effects, layerDepth);
|
||||
|
||||
public void Draw(Texture2D texture, AABB destinationAABB, AABB? sourceAABB, Color color, float rotation, Vector2D origin, SpriteEffects effects, float layerDepth)
|
||||
public void Draw(Texture2D texture, AABB2D destinationAABB, AABB2D? sourceAABB, Color color, float rotation, Vector2D origin, SpriteEffects effects, float layerDepth)
|
||||
=> spriteBatch.Draw(texture, destinationAABB.ToRectangle(), sourceAABB?.ToRectangle(), color, rotation, origin.ToDisplayVector2(), effects, layerDepth);
|
||||
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB? sourceAABB, Color color)
|
||||
public void Draw(Texture2D texture, Vector2D position, AABB2D? sourceAABB, Color color)
|
||||
=> spriteBatch.Draw(texture, position.ToDisplayVector2(), sourceAABB?.ToRectangle(), color);
|
||||
|
||||
public void Draw(Texture2D texture, AABB destinationAABB, AABB? sourceAABB, Color color)
|
||||
public void Draw(Texture2D texture, AABB2D destinationAABB, AABB2D? sourceAABB, Color color)
|
||||
=> spriteBatch.Draw(texture, destinationAABB.ToRectangle(), sourceAABB?.ToRectangle(), color);
|
||||
|
||||
public void Draw(Texture2D texture, Vector2D position, Color color)
|
||||
=> spriteBatch.Draw(texture, position.ToDisplayVector2(), color);
|
||||
|
||||
public void Draw(Texture2D texture, AABB destinationAABB, Color color)
|
||||
public void Draw(Texture2D texture, AABB2D destinationAABB, Color color)
|
||||
=> spriteBatch.Draw(texture, destinationAABB.ToRectangle(), color);
|
||||
|
||||
public void DrawString(SpriteFont spriteFont, string text, Vector2D position, Color color)
|
||||
|
@@ -60,7 +60,7 @@ public static class EngineConverterExtensions
|
||||
};
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Rectangle ToRectangle(this AABB aabb) => new()
|
||||
public static Rectangle ToRectangle(this AABB2D aabb) => new()
|
||||
{
|
||||
X = (int)(aabb.LowerBoundary.X * screenScale.X),
|
||||
Y = (int)(aabb.LowerBoundary.Y * screenScale.Y),
|
||||
|
@@ -8,33 +8,33 @@ using YamlDotNet.Serialization;
|
||||
|
||||
namespace Engine.Serializers.Yaml;
|
||||
|
||||
public class AABBConverter : EngineTypeYamlSerializerBase<AABB>
|
||||
public class AABB2DConverter : EngineTypeYamlSerializerBase<AABB2D>
|
||||
{
|
||||
public override AABB Read(IParser parser, Type type, ObjectDeserializer rootDeserializer)
|
||||
public override AABB2D Read(IParser parser, Type type, ObjectDeserializer rootDeserializer)
|
||||
{
|
||||
parser.Consume<MappingStart>();
|
||||
|
||||
if (parser.Consume<Scalar>().Value.CompareTo(nameof(AABB.LowerBoundary)) != 0)
|
||||
throw new ArgumentException($"{nameof(AABB)} mapping must start with {nameof(AABB.LowerBoundary)}");
|
||||
if (parser.Consume<Scalar>().Value.CompareTo(nameof(AABB2D.LowerBoundary)) != 0)
|
||||
throw new ArgumentException($"{nameof(AABB2D)} mapping must start with {nameof(AABB2D.LowerBoundary)}");
|
||||
Vector2D lowerBoundary = (Vector2D)rootDeserializer(typeof(Vector2D))!;
|
||||
|
||||
if (parser.Consume<Scalar>().Value.CompareTo(nameof(AABB.UpperBoundary)) != 0)
|
||||
throw new ArgumentException($"{nameof(AABB)} mapping must end with {nameof(AABB.UpperBoundary)}");
|
||||
if (parser.Consume<Scalar>().Value.CompareTo(nameof(AABB2D.UpperBoundary)) != 0)
|
||||
throw new ArgumentException($"{nameof(AABB2D)} mapping must end with {nameof(AABB2D.UpperBoundary)}");
|
||||
Vector2D upperBoundary = (Vector2D)rootDeserializer(typeof(Vector2D))!;
|
||||
|
||||
parser.Consume<MappingEnd>();
|
||||
|
||||
return new AABB(lowerBoundary, upperBoundary);
|
||||
return new AABB2D(lowerBoundary, upperBoundary);
|
||||
}
|
||||
|
||||
public override void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
|
||||
{
|
||||
AABB aabb = (AABB)value!;
|
||||
AABB2D aabb = (AABB2D)value!;
|
||||
|
||||
emitter.Emit(new MappingStart());
|
||||
emitter.Emit(new Scalar(nameof(AABB.LowerBoundary)));
|
||||
emitter.Emit(new Scalar(nameof(AABB2D.LowerBoundary)));
|
||||
serializer(aabb.LowerBoundary, typeof(Vector2D));
|
||||
emitter.Emit(new Scalar(nameof(AABB.UpperBoundary)));
|
||||
emitter.Emit(new Scalar(nameof(AABB2D.UpperBoundary)));
|
||||
serializer(aabb.UpperBoundary, typeof(Vector2D));
|
||||
emitter.Emit(new MappingEnd());
|
||||
}
|
Reference in New Issue
Block a user