diff --git a/SMCode/SM.Base/SM.Base.csproj b/SMCode/SM.Base/SM.Base.csproj
index e658130..7f23c7e 100644
--- a/SMCode/SM.Base/SM.Base.csproj
+++ b/SMCode/SM.Base/SM.Base.csproj
@@ -66,6 +66,7 @@
+
diff --git a/SMCode/SM.Base/Scene/GenericItemCollection.cs b/SMCode/SM.Base/Scene/GenericItemCollection.cs
index ead3352..3385669 100644
--- a/SMCode/SM.Base/Scene/GenericItemCollection.cs
+++ b/SMCode/SM.Base/Scene/GenericItemCollection.cs
@@ -1,5 +1,6 @@
#region usings
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SM.Base.Drawing;
@@ -91,13 +92,14 @@ namespace SM.Base.Scene
}
///
- /// Adds a item to the draw and the script collection, when applicable.
+ /// Adds items to the draw and the script collection, when applicable.
///
- public void Add(params IShowItem[] items)
+ public void Add(params ICollectionItem[] items)
{
foreach (var item in items)
{
- AddObject(item);
+ if (item is IShowItem show)
+ addObject(show);
if (item is IScriptable scriptable)
AddScript(scriptable);
@@ -106,11 +108,33 @@ namespace SM.Base.Scene
}
}
+
///
/// Adds the object to the collection.
///
///
+ [Obsolete("Please use Add()")]
public void AddObject(IShowItem item)
+ {
+ addObject(item);
+ }
+
+ ///
+ /// Adds the script to the collection.
+ ///
+ ///
+ [Obsolete("Please use Add()")]
+ public void AddScript(IScriptable item)
+ {
+ addScript(item);
+ }
+
+
+ ///
+ /// Adds the object to the collection.
+ ///
+ ///
+ private void addObject(IShowItem item)
{
base.Add(item);
item.Parent = this;
@@ -121,7 +145,8 @@ namespace SM.Base.Scene
/// Adds the script to the collection.
///
///
- public void AddScript(IScriptable item)
+ [Obsolete("Please use Add()")]
+ public void addScript(IScriptable item)
{
_scriptableObjects.Add(item);
if (item is IFixedScriptable fs) _fixedScriptables.Add(fs);
@@ -132,11 +157,12 @@ namespace SM.Base.Scene
/// If the object is a scriptable object, it will remove the object from that list as well.
///
///
- public void Remove(params IShowItem[] items)
+ public void Remove(params ICollectionItem[] items)
{
foreach (var item in items)
{
- RemoveObject(item);
+ if (item is IShowItem show)
+ RemoveObject(show);
if (item is IScriptable scriptable)
RemoveScript(scriptable);
@@ -150,6 +176,7 @@ namespace SM.Base.Scene
/// Remove the object from the draw collection.
///
///
+ [Obsolete("Please use Remove()")]
public void RemoveObject(IShowItem item)
{
base.Remove(item);
@@ -161,6 +188,7 @@ namespace SM.Base.Scene
/// Remove the object from the script collection.
///
///
+ [Obsolete("Please use Remove()")]
public void RemoveScript(IScriptable item)
{
_scriptableObjects.Remove(item);
diff --git a/SMCode/SM.Base/Scene/ICollectionItem.cs b/SMCode/SM.Base/Scene/ICollectionItem.cs
new file mode 100644
index 0000000..091cad2
--- /dev/null
+++ b/SMCode/SM.Base/Scene/ICollectionItem.cs
@@ -0,0 +1,10 @@
+namespace SM.Base.Scene
+{
+ ///
+ /// Dummy interface for adding items.
+ ///
+ public interface ICollectionItem
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/SMCode/SM.Base/Scene/IShowItem.cs b/SMCode/SM.Base/Scene/IShowItem.cs
index 2878da3..56b2cb7 100644
--- a/SMCode/SM.Base/Scene/IShowItem.cs
+++ b/SMCode/SM.Base/Scene/IShowItem.cs
@@ -12,7 +12,7 @@ namespace SM.Base.Scene
///
/// Adds requirements to object, to be properly used as a update and/or draw item.
///
- public interface IShowItem
+ public interface IShowItem : ICollectionItem
{
///
/// Parent of the object.
diff --git a/SMCode/SM2D/Drawing/DrawBackground.cs b/SMCode/SM2D/Drawing/DrawBackground.cs
index 7808855..3fabd1d 100644
--- a/SMCode/SM2D/Drawing/DrawBackground.cs
+++ b/SMCode/SM2D/Drawing/DrawBackground.cs
@@ -4,6 +4,7 @@ using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using SM.Base.Drawing;
+using SM.Base.Objects.Static;
using SM.Base.Scene;
using SM.Base.Textures;
using SM.Base.Window;
@@ -53,6 +54,7 @@ namespace SM2D.Drawing
public DrawBackground(Color4 color)
{
Color = color;
+ Mesh = Plate.Object;
}
///
@@ -62,6 +64,7 @@ namespace SM2D.Drawing
public DrawBackground(Bitmap texture)
{
Texture = (Texture) texture;
+ Mesh = Plate.Object;
}
///
@@ -73,6 +76,7 @@ namespace SM2D.Drawing
{
Color = tint;
Texture = (Texture) texture;
+ Mesh = Plate.Object;
}
diff --git a/SMCode/SM2D/Scene/Camera.cs b/SMCode/SM2D/Scene/Camera.cs
index ca39f81..1c521a1 100644
--- a/SMCode/SM2D/Scene/Camera.cs
+++ b/SMCode/SM2D/Scene/Camera.cs
@@ -2,6 +2,7 @@
using System;
using OpenTK;
+using SM.Base;
using SM.Base.Scene;
using SM.Base.Types;
using SM.Base.Window;
@@ -38,6 +39,22 @@ namespace SM2D.Scene
}
}
+ ///
+ /// Will always return a updated version of the world scale.
+ ///
+ public Vector2 CalculatedWorldScale
+ {
+ get
+ {
+ if (ResizeCounter != _resizeCounter || _updateWorldScale)
+ {
+ CalculateWorldScale(SMRenderer.CurrentWindow);
+ }
+
+ return WorldScale;
+ }
+ }
+
///
/// The world scale that got calculated.
///
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index 2c0f58a..0ffc516 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using OpenTK;
+using OpenTK.Graphics;
using SM.Base.Animation;
using SM.Base.Controls;
using SM.Base.Drawing.Text;
@@ -32,17 +33,10 @@ namespace SM_TEST
window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off);
window.ApplySetup(new Window2DSetup());
- window.SetRenderPipeline(new TestRenderPipeline());
-
+
window.SetScene(scene = new Scene());
- DrawParticles particles = new DrawParticles(TimeSpan.FromSeconds(5))
- {
- Direction = new Vector2(0, 1),
- DirectionRadius = 10
- };
- particles.Trigger();
- scene.Objects.Add(particles);
+ scene.Background.Color = Color4.Blue;
window.UpdateFrame += WindowOnUpdateFrame;
window.RenderFrame += Window_RenderFrame;