Améliorer les ticks #25

Closed
opened 2022-07-10 22:38:19 +02:00 by Sceptique · 3 comments
Owner

La fréquence du tick doit être ajustable par une fréquence.

Les systèmes de jeu doivent être réactifs à l'event "new day" ou quelque chose du genre.

La fréquence du tick doit être ajustable par une fréquence. Les systèmes de jeu doivent être réactifs à l'event "new day" ou quelque chose du genre.
Sceptique added this to the v0.2: Get population nicer milestone 2022-07-10 22:38:19 +02:00
Sceptique added this to the v0.2 project 2022-07-10 22:38:20 +02:00
Author
Owner

bordel le reactive system segfault 😭

bordel le reactive system segfault 😭
Author
Owner
diff --git a/src/systems/infrastructure_upgrades.cr b/src/systems/infrastructure_upgrades.cr
index c598c1d..8821aef 100644
--- a/src/systems/infrastructure_upgrades.cr
+++ b/src/systems/infrastructure_upgrades.cr
@@ -1,13 +1,17 @@
-require "../components"
-
-class TETU::InfrastructureUpgradesSystem
+class TETU::InfrastructureUpgradesSystem < Entitas::MultiReactiveSystem
   include Entitas::Systems::ExecuteSystem
   spoved_logger level: :info, io: STDOUT, bind: true

   def initialize(@contexts : Contexts); end

-  def execute
-    producer = @contexts.game.get_group Entitas::Matcher.all_of Resources, InfrastructureUpgrades, ManpowerAllocation
+  def get_trigger(contexts : Contexts) : Array(Entitas::ICollector)
+    [
+      @contexts.time.get_group(Entitas::Matcher.all_of(DayPassedEvent))
+    ]
+  end
+
+  def execute(entities : Array(Entitas::IEntity))
+    producer = @contexts.game.get_group Entitas::Matcher.all_of(Resources, InfrastructureUpgrades, ManpowerAllocation)
     producer.entities.each do |e|
       # pay the cost
       # logger.debug { "e.infrastructure_upgrades.upgrades = #{e.infrastructure_upgrades.upgrades.size}" }
diff --git a/src/systems/time.cr b/src/systems/time.cr
index c61f319..f236113 100644
--- a/src/systems/time.cr
+++ b/src/systems/time.cr
@@ -1,5 +1,6 @@
 class TETU::TimeSystem
   include Entitas::Systems::ExecuteSystem
+  include Entitas::Systems::InitializeSystem
   spoved_logger level: :info, io: STDOUT, bind: true

   @tick : Int64
@@ -14,6 +15,10 @@ class TETU::TimeSystem
     @main_timeline = @contexts.time.create_entity
   end

+  def init
+    # MMMMMHHHHH
+  end
+
   NANO_SECOND           = 1_000_000
   REAL_TIME_DAY_SPAN_MS = GALAXY_CONF["real_time_day_span"].as_i
   REAL_TIME_DAY_SPAN    = Time::Span.new(nanoseconds: NANO_SECOND)

``` diff --git a/src/systems/infrastructure_upgrades.cr b/src/systems/infrastructure_upgrades.cr index c598c1d..8821aef 100644 --- a/src/systems/infrastructure_upgrades.cr +++ b/src/systems/infrastructure_upgrades.cr @@ -1,13 +1,17 @@ -require "../components" - -class TETU::InfrastructureUpgradesSystem +class TETU::InfrastructureUpgradesSystem < Entitas::MultiReactiveSystem include Entitas::Systems::ExecuteSystem spoved_logger level: :info, io: STDOUT, bind: true def initialize(@contexts : Contexts); end - def execute - producer = @contexts.game.get_group Entitas::Matcher.all_of Resources, InfrastructureUpgrades, ManpowerAllocation + def get_trigger(contexts : Contexts) : Array(Entitas::ICollector) + [ + @contexts.time.get_group(Entitas::Matcher.all_of(DayPassedEvent)) + ] + end + + def execute(entities : Array(Entitas::IEntity)) + producer = @contexts.game.get_group Entitas::Matcher.all_of(Resources, InfrastructureUpgrades, ManpowerAllocation) producer.entities.each do |e| # pay the cost # logger.debug { "e.infrastructure_upgrades.upgrades = #{e.infrastructure_upgrades.upgrades.size}" } diff --git a/src/systems/time.cr b/src/systems/time.cr index c61f319..f236113 100644 --- a/src/systems/time.cr +++ b/src/systems/time.cr @@ -1,5 +1,6 @@ class TETU::TimeSystem include Entitas::Systems::ExecuteSystem + include Entitas::Systems::InitializeSystem spoved_logger level: :info, io: STDOUT, bind: true @tick : Int64 @@ -14,6 +15,10 @@ class TETU::TimeSystem @main_timeline = @contexts.time.create_entity end + def init + # MMMMMHHHHH + end + NANO_SECOND = 1_000_000 REAL_TIME_DAY_SPAN_MS = GALAXY_CONF["real_time_day_span"].as_i REAL_TIME_DAY_SPAN = Time::Span.new(nanoseconds: NANO_SECOND) ```
Author
Owner

d9dfa2aff7

This one is an angel. Or some kind of incarnation of love

https://github.com/spoved/entitas.cr/commit/d9dfa2aff7e0e616ca837004458e9de160d5dab7 This one is an angel. Or some kind of incarnation of love
Sceptique added the
think
economy
labels 2022-07-26 23:42:41 +02:00
Sign in to join this conversation.
No Label
IA
UI
bug
economy
think
war
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TETU/Core#25
No description provided.