Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrofolium committed May 17, 2024
1 parent f08e0fe commit b7bba4f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cardinal/system/regen.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ import (
// RegenSystem replenishes the player's HP at every tick.
// This provides an example of a system that doesn't rely on a transaction to update a component.
func RegenSystem(world cardinal.WorldContext) error {
return cardinal.NewSearch().Entity(filter.Exact(filter.Component[comp.Player](), filter.Component[comp.Health]())).Each(world, func(id types.EntityID) bool {
health, err := cardinal.GetComponent[comp.Health](world, id)
if err != nil {
return cardinal.NewSearch().Entity(
filter.Exact(filter.Component[comp.Player](), filter.Component[comp.Health]())).
Each(world, func(id types.EntityID) bool {
health, err := cardinal.GetComponent[comp.Health](world, id)
if err != nil {
return true
}
health.HP++
if err := cardinal.SetComponent[comp.Health](world, id, health); err != nil {
return true
}
return true
}
health.HP++
if err := cardinal.SetComponent[comp.Health](world, id, health); err != nil {
return true
}
return true
})
})
}

0 comments on commit b7bba4f

Please sign in to comment.