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

@ -2,30 +2,30 @@
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base.Contexts;
using SM.Base;
using SM.Base.Drawing;
using SM.Base.Objects;
using SM.Base.Textures;
using SM.Base.Windows;
using SM.OGL.Mesh;
using SM2D.Object;
using SM2D.Scene;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawObject2D : DrawingBasis<Transformation>, I2DShowItem
public class DrawObject2D : DrawingBasis<Transformation>
{
public int ZIndex { get; set; }
public Texture Texture
{
get => (Texture) _material.Texture;
set => _material.Texture = value;
get => (Texture) Material.Texture;
set => Material.Texture = value;
}
public Color4 Color
{
get => _material.Tint;
set => _material.Tint = value;
get => Material.Tint;
set => Material.Tint = value;
}
protected override void DrawContext(ref DrawContext context)
@ -33,37 +33,32 @@ namespace SM2D.Drawing
base.DrawContext(ref context);
context.Shader.Draw(context);
}
public void SetShader(MaterialShader shader) => Material.CustomShader = shader;
public Material GetMaterialReference() => _material;
public void SetMaterialReference(Material material) => _material = material;
public void SetShader(MaterialShader shader) => _material.CustomShader = shader;
public Polygon ApplyPolygon(ICollection<Vector2> vertices)
public Polygon ApplyPolygon(ICollection<Vector2> vertices, bool centerUVs = false)
{
Polygon polygon = new Polygon(vertices);
_mesh = polygon;
Mesh = polygon;
return polygon;
}
public Polygon ApplyPolygon(ICollection<PolygonVertex> vertices)
public Polygon ApplyPolygon(ICollection<PolygonVertex> vertices, bool centerUVs = false)
{
Polygon polygon = new Polygon(vertices);
_mesh = polygon;
Mesh = polygon;
return polygon;
}
public void ApplyPolygon(Polygon polygon)
{
_mesh = polygon;
Mesh = polygon;
}
public void ApplyMesh(Mesh mesh) => _mesh = mesh;
public Polygon ApplyCircle(int segments = 32)
public Polygon ApplyCircle(int segments = 32, bool centerUVs = false)
{
Polygon pol = Polygon.GenerateCircle(segments);
_mesh = pol;
Mesh = pol;
return pol;
}
}
}