Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
|
|
@ -4,20 +4,38 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base;
|
||||
using SM.Base.Drawing;
|
||||
using SM.Base.Objects.Static;
|
||||
using SM.Base.Scene;
|
||||
using SM.Base.Textures;
|
||||
using SM.Base.Windows;
|
||||
using SM.OGL.Texture;
|
||||
using SM2D.Scene;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawBackground : IBackgroundItem
|
||||
public class DrawBackground : DrawingBasis, IBackgroundItem
|
||||
{
|
||||
private Material _material = new Material();
|
||||
public Color4 Color
|
||||
{
|
||||
get => Material.Tint;
|
||||
set => Material.Tint = value;
|
||||
}
|
||||
|
||||
public TextureBase Texture
|
||||
{
|
||||
get => Material.Texture;
|
||||
set
|
||||
{
|
||||
if (Material.Tint == Color4.Black) Material.Tint = Color4.White;
|
||||
Material.Texture = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DrawBackground() : this(Color4.Black) {}
|
||||
|
||||
public DrawBackground(Color4 color)
|
||||
{
|
||||
|
|
@ -35,41 +53,12 @@ namespace SM2D.Drawing
|
|||
Texture = (Texture) texture;
|
||||
}
|
||||
|
||||
public Color4 Color
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
get => _material.Tint;
|
||||
set => _material.Tint = value;
|
||||
}
|
||||
|
||||
public TextureBase Texture
|
||||
{
|
||||
get => _material.Texture;
|
||||
set => _material.Texture = value;
|
||||
}
|
||||
|
||||
public object Parent { get; set; }
|
||||
public string Name { get; set; } = "Background";
|
||||
public ICollection<string> Flags { get; set; } = new string[0];
|
||||
|
||||
public void Update(UpdateContext context)
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(DrawContext context)
|
||||
{
|
||||
context.Material = _material;
|
||||
context.Mesh = Plate.Object;
|
||||
|
||||
context.ModelMaster = Matrix4.CreateScale(context.WorldScale.X, context.WorldScale.Y, 1);
|
||||
base.DrawContext(ref context);
|
||||
context.ModelMatrix = Matrix4.CreateScale((context.UseCamera as Camera).WorldScale.X, (context.UseCamera as Camera).WorldScale.Y, 1);
|
||||
context.Shader.Draw(context);
|
||||
}
|
||||
|
||||
public void OnAdded(object sender)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnRemoved(object sender)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,8 @@ using SM2D.Types;
|
|||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawParticles : ParticleDrawingBasis<Transformation, Vector2>, I2DShowItem
|
||||
public class DrawParticles : ParticleDrawingBasis<Transformation, Vector2>
|
||||
{
|
||||
public int ZIndex { get; set; }
|
||||
public override Func<Vector2, ParticleContext, Vector2> MovementCalculation { get; set; } = ParticleMovement.Default2D;
|
||||
|
||||
public DrawParticles(TimeSpan duration) : base(duration)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#region usings
|
||||
|
||||
using SM.Base.Contexts;
|
||||
using SM.Base;
|
||||
using SM.Base.Drawing.Text;
|
||||
using SM.Base.Types;
|
||||
using SM.Base.Windows;
|
||||
using SM2D.Scene;
|
||||
using SM2D.Types;
|
||||
|
||||
|
|
@ -10,7 +11,7 @@ using SM2D.Types;
|
|||
|
||||
namespace SM2D.Drawing
|
||||
{
|
||||
public class DrawText : TextDrawingBasis<Transformation>, I2DShowItem
|
||||
public class DrawText : TextDrawingBasis<Transformation>
|
||||
{
|
||||
public DrawText(Font font, string text) : base(font)
|
||||
{
|
||||
|
|
@ -18,8 +19,6 @@ namespace SM2D.Drawing
|
|||
Transform.Size = new CVector2(1);
|
||||
}
|
||||
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
protected override void DrawContext(ref DrawContext context)
|
||||
{
|
||||
base.DrawContext(ref context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue