You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem;usingScellecs.Morpeh;usingScellecs.Morpeh.Systems;usingUnityEngine;[Serializable]publicstructHeroComponent:IComponent{}[Serializable]publicstructHeroDamagedMarker:IComponent{}[Serializable]publicstructHeroDeadMarker:IComponent{}publicclassHealthBarSystem:UpdateSystem{[SerializeField]privateGameObjecthealthBarPrefab;privateSystemStateProcessor<HealthBarSystemStateComponent>heroProcessor;publicoverridevoidOnAwake(){heroProcessor=World.Filter.With<HeroComponent>().With<HeroDamagedMarker>().Without<HeroDeadMarker>().ToSystemStateProcessor(CreateHealthBarForHero,RemoveHealthBarForHero);}publicoverridevoidDispose(){heroProcessor.Dispose();}publicoverridevoidOnUpdate(floatdeltaTime){heroProcessor.Process();}// Called when an entity has been added to the FilterprivateHealthBarSystemStateComponentCreateHealthBarForHero(EntityheroEntity){varhealthBar=Instantiate(healthBarPrefab);returnnewHealthBarSystemStateComponent{healthBar=healthBar,};}// Called when an entity has been removed from filter or has been destroyedprivatevoidRemoveHealthBarForHero(refHealthBarSystemStateComponentstate){Destroy(state.healthBar);}[Serializable]privatestructHealthBarSystemStateComponent:ISystemStateComponent{publicGameObjecthealthBar;}}