• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / ark-tools / 13609285641 / 1

Source File

100.0
/system/callback_termination.go
1
package system
2

3
import (
4
        "github.com/mlange-42/ark-tools/resource"
5
        "github.com/mlange-42/ark/ecs"
6
)
7

8
// CallbackTermination system.
9
//
10
// Terminates a run according to the return value of a callback function.
11
//
12
// Expects a resource of type [app.Termination].
13
type CallbackTermination struct {
14
        Callback func(t int64) bool // The callback. ends the simulation when it returns true.
15
        termRes  ecs.Resource[resource.Termination]
16
        step     int64
17
}
18

19
// Initialize the system
20
func (s *CallbackTermination) Initialize(w *ecs.World) {
2✔
21
        s.termRes = ecs.NewResource[resource.Termination](w)
2✔
22
        s.step = 0
2✔
23
}
2✔
24

25
// Update the system
26
func (s *CallbackTermination) Update(w *ecs.World) {
200✔
27
        term := s.termRes.Get()
200✔
28

200✔
29
        if s.Callback(s.step) {
202✔
30
                term.Terminate = true
2✔
31
        }
2✔
32
        s.step++
200✔
33
}
34

35
// Finalize the system
36
func (s *CallbackTermination) Finalize(w *ecs.World) {}
2✔
  • Back to Build 13609285641
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc