-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using DefaultEcs; | ||
|
||
namespace MonoDreams.Message; | ||
|
||
public readonly record struct SizeChangeMessage(Entity entity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace MonoDreams; | ||
|
||
public struct Size | ||
{ | ||
public Vector2 CurrentSize; | ||
public Vector2 NextSize; | ||
public Vector2 LastSize; | ||
|
||
public bool HasUpdates => CurrentSize != NextSize || LastSize != CurrentSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using DefaultEcs; | ||
using DefaultEcs.System; | ||
using DefaultEcs.Threading; | ||
using MonoDreams.Message; | ||
using MonoDreams.State; | ||
|
||
namespace MonoDreams.System; | ||
|
||
public sealed class SizeSystem : AEntitySetSystem<GameState> | ||
{ | ||
private readonly World _world; | ||
|
||
public SizeSystem(World world, IParallelRunner runner) | ||
: base(world.GetEntities().With((in Size p) => p.HasUpdates).AsSet(), runner) | ||
{ | ||
_world = world; | ||
} | ||
|
||
protected override void Update(GameState state, in Entity entity) | ||
{ | ||
ref var size = ref entity.Get<Size>(); | ||
size.LastSize.X = size.CurrentSize.X; | ||
size.LastSize.Y = size.CurrentSize.Y; | ||
size.CurrentSize.X = size.NextSize.X; | ||
size.CurrentSize.Y = size.NextSize.Y; | ||
_world.Publish(new SizeChangeMessage(entity)); | ||
} | ||
} |