Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Text;
- using UnityEngine;
- using Leopotam.Ecs;
- public class LeoECSGame : RB.IRetroBlitGame
- {
- EcsWorld _world;
- EcsSystems _systemsUpdate;
- EcsSystems _systemsRender;
- public RB.HardwareSettings QueryHardware()
- {
- var hw = new RB.HardwareSettings();
- hw.DisplaySize = new Vector2i(320, 320);
- return hw;
- }
- public bool Initialize()
- {
- _world = new EcsWorld();
- #if UNITY_EDITOR
- Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(_world);
- #endif
- //
- _systemsUpdate = new EcsSystems(_world)
- .Add(new Client.CommonFilters())
- .Add(new Client.GameInit())
- .Add(new Client.GameInput());
- _systemsRender = new EcsSystems(_world)
- .Add(new Client.CommonFilters())
- .Add(new Client.Prerender())
- .Add(new Client.DrawSprites());
- //
- #if UNITY_EDITOR
- Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systemsUpdate);
- Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(_systemsRender);
- #endif
- //
- _systemsUpdate.Initialize();
- _systemsRender.Initialize();
- return true;
- }
- public void Update()
- {
- _systemsUpdate.Run();
- }
- public void Render()
- {
- _systemsRender.Run();
- _world.RemoveOneFrameComponents();
- }
- public void GameEnd()
- {
- _systemsUpdate.Dispose();
- _systemsUpdate = null;
- _systemsRender.Dispose();
- _systemsRender = null;
- _world.Dispose();
- _world = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement