Skip to content

Commit fa02e8d

Browse files
committed
Removed RenderableSpace Class in favor of Direct World Code.
Note: Its overcomplicating something that doesn't need to be. Want to expand it? Make a new thread and update an instance of your own code. There's no reason to include example code if it varies.
1 parent 0303b97 commit fa02e8d

5 files changed

Lines changed: 19 additions & 146 deletions

File tree

DOCUMENTATION/ExampleSpace2D.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

DOCUMENTATION/ExampleSpace3D.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

Scenes/BaseScene.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public abstract class BaseScene
2929
/// </remarks>
3030
public IWorld? GameWorld;
3131

32+
/// <summary>
33+
/// Initializes game world in this scene.
34+
/// </summary>
3235
public void Initialize(GraphicsDeviceManager manager, SpriteBatch gameSpriteBatch, GumProjectSave? gumProjectSave, ref IWorld? world)
3336
{
3437
_spriteBatch = gameSpriteBatch;

Scenes/BaseWorld.cs

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
using Microsoft.Xna.Framework;
22
using SKSSL.ECS;
3-
using SKSSL.Space;
43

54
// ReSharper disable PublicConstructorInAbstractClass
65

76
namespace SKSSL.Scenes;
87

98
/// <summary>
109
/// Common contract for all worlds (used by SceneManager, ECSController, etc.)
10+
/// All worlds are inherently renderable spaces, but additional rendering code is required on the developer's part.
11+
/// This may not include menus if GumUI is used on the Screen layer.
1112
/// </summary>
1213
public interface IWorld
1314
{
14-
RenderableSpace Space { get; }
15+
/// Initializes the Game World.
1516
void Initialize(GraphicsDeviceManager graphics);
17+
/// Update calls made into the game world.
1618
void Update(GameTime gameTime);
19+
/// Draw calls made into the game world.
1720
void Draw(GameTime gameTime);
21+
/// Actions taken before the world is destroyed. Saving measures, deletions, etc.
1822
void Destroy();
1923
}
2024

2125
/// <summary>
22-
/// Overridable inherited dictation of how a World, its <see cref="RenderableSpace"/>, and its systems.
26+
/// Overridable inherited dictation of how a World, its Renderable Space, and its systems.
2327
/// <see cref="UsesECS"/> toggled override will permit automatic updating of underlying systems.
28+
/// A "physical" virtual space or area that is rendered for gameplay. Constitutes, typically, the entire field that
29+
/// which the user will play in. Implement this class however you see fit.
30+
/// Add your rendering / other code within your World class.
2431
/// </summary>
2532
public abstract class BaseWorld : IWorld
2633
{
2734
#pragma warning disable CS0618 // Type or member is obsolete
28-
public RenderableSpace Space { get; private set; } = new BlankWorldSpace();
2935
protected bool IsInitialized { get; private set; }
3036

3137
/// Most worlds use ECS — this depends on overall dictation. If ECS is enabled,
@@ -36,54 +42,29 @@ public abstract class BaseWorld : IWorld
3642
/// ECS controller unique to this world instance. Left null of no ECS controller.
3743
public ECSController? ECS { get; private set; } = null;
3844

39-
/// Assign Rendered space field with provided space definition.
40-
public void SetSpace(RenderableSpace worldSpace)
41-
{
42-
Space.Destroy();
43-
Space = worldSpace;
44-
}
45-
4645
/// Calls ECS Init() (if enabled)
4746
protected BaseWorld()
4847
{
4948
// ReSharper disable once VirtualMemberCallInConstructor
5049
// Enable ECS if toggled-on.
5150
if (!UsesECS) return;
5251
ECS = new ECSController(this);
53-
ECS.Initialize();
5452
}
5553

5654

5755
/// Calls Spacial Initializations as base class method.
58-
public virtual void Initialize(GraphicsDeviceManager? graphics)
59-
{
60-
// Avoid re-initializing what already has been initialized.
61-
if (IsInitialized) return;
62-
IsInitialized = true;
63-
64-
// Initialize WorldSpace assuming graphics provided + exception.
65-
if (graphics != null)
66-
Space.Initialize(graphics);
67-
else if (Space == null && graphics != null)
68-
throw new NullReferenceException("Attempted to initialize WorldSpace with null GraphicsDeviceManager");
69-
}
56+
public virtual void Initialize(GraphicsDeviceManager? graphics) => ECS?.Initialize();
7057

71-
public virtual void Update(GameTime gameTime)
72-
{
73-
ECS?.Update(gameTime);
74-
Space.Update(gameTime);
75-
}
58+
/// <inheritdoc cref="IWorld.Update"/>
59+
public virtual void Update(GameTime gameTime) => ECS?.Update(gameTime);
7660

77-
public virtual void Draw(GameTime gameTime)
78-
{
79-
ECS?.Draw(gameTime);
80-
Space.Draw(gameTime);
81-
}
61+
/// <inheritdoc cref="IWorld.Draw"/>
62+
public virtual void Draw(GameTime gameTime) => ECS?.Draw(gameTime);
8263

64+
/// <inheritdoc cref="IWorld.Destroy"/>
8365
public virtual void Destroy()
8466
{
8567
ECS?.Destroy();
86-
Space.Destroy();
8768
ECS = null;
8869
IsInitialized = false;
8970
}

Space/RenderableSpace.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)