Skip to content

Instantly share code, notes, and snippets.

@qxxxb
Last active February 18, 2020 03:36
Show Gist options
  • Save qxxxb/3b2d72d385b140b05ccd5788262d2ca1 to your computer and use it in GitHub Desktop.
Save qxxxb/3b2d72d385b140b05ccd5788262d2ca1 to your computer and use it in GitHub Desktop.
Reset entities
using GameProject.ComponentEnums;
namespace GameProject.Command
{
public class Reset : ICommmand
{
Game1 game;
public Reset(Game1 game)
{
this.game = game;
}
public void Execute()
{
EcRegistry ecRegistry = ServiceLocator.EcRegistry;
// This could be encapsulated in a method of `EcRegistry`
ecRegistry.data.Clear();
ecRegistry.dataGrouped.Clear();
ecRegistry.nextEntity = 0;
game.player.Spawn();
game.item.Spawn();
game.enemy.Spawn();
game.block.Spawn();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment