Documentation ¶
Overview ¶
Package resource provides commonly used resources (in the ECS sense).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rand ¶
Rand is a PRNG resource to be used in [System] implementations.
This resource is provided by github.com/mlange-42/arche-model/model.Model per default.
Example ¶
package main import ( "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/resource" "github.com/mlange-42/arche/ecs" "golang.org/x/exp/rand" ) func main() { m := model.New() src := ecs.GetResource[resource.Rand](&m.World) rng := rand.New(src.Source) _ = rng.NormFloat64() }
Output:
type SelectedEntity ¶ added in v0.2.0
SelectedEntity is a resource holding the currently selected entity.
The primarily purpose is communication between UI systems, e.g. for entity inspection or manipulation by the user.
Example ¶
package main import ( "fmt" "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/resource" "github.com/mlange-42/arche/ecs" ) func main() { m := model.New() ecs.AddResource(&m.World, &resource.SelectedEntity{}) sel := ecs.GetResource[resource.SelectedEntity](&m.World) fmt.Println(sel.Selected.IsZero()) }
Output: true
type Termination ¶
type Termination struct {
Terminate bool // Whether the simulation run is finished. Can be set by systems.
}
Termination is a resource holding whether the simulation should terminate after the current step.
This resource is provided by github.com/mlange-42/arche-model/model.Model per default.
Example ¶
package main import ( "fmt" "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/resource" "github.com/mlange-42/arche/ecs" ) func main() { m := model.New() term := ecs.GetResource[resource.Termination](&m.World) fmt.Println(term.Terminate) }
Output: false
type Tick ¶
type Tick struct {
Tick int64 // The current model tick.
}
Tick is a resource holding the model's time step.
This resource is provided by github.com/mlange-42/arche-model/model.Model per default.
Example ¶
package main import ( "fmt" "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/resource" "github.com/mlange-42/arche/ecs" ) func main() { m := model.New() tick := ecs.GetResource[resource.Tick](&m.World) fmt.Println(tick.Tick) }
Output: 0