gen

package
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component

func Component(f *jen.File, def ComponentDef)

func LinePrefixMatch

func LinePrefixMatch(line string, prefixes ...string) (rest string, match bool)

func ParsePrefixType

func ParsePrefixType(v string) (prefix, mtype string)

func System

func System(f *jen.File, def SystemDef)

Types

type ComponentDef

type ComponentDef struct {
	UUID          string
	StructName    string // if the ComponentName is "PositionComponent", this would be "Position"
	ComponentName string // if the StructName is "Position", this would be "PositionComponent"
	InitialCap    int    // initial slice capacity (default: 256)
	Async         bool   // Adds a mutex lock for accessing component data in parallel. Not recommended.
	NoInit        bool   // if true, the generated code does not define an init() to register this component
	OnWillResize  string // call a custom function before resizing
	OnResized     string // call a custom function after resizing
	OnAdd         string // call a custom function after adding a component to an entity
	OnRemove      string // call a custom function after adding a component to an entity
	OnWillRemove  string // call a custom function before removing a component from an entity
	OnSetup       string // call a custom function after the setup
}

type SystemDef

type SystemDef struct {
	UUID       string           `toml:"uuid" json:"uuid"`
	Priority   int64            `toml:"priority" json:"priority"`
	Name       string           `toml:"name" json:"name"`
	Async      bool             `toml:"async" json:"async"`
	Components []SystemViewItem `toml:"components" json:"components"`
	Members    []SystemMember   `toml:"members" json:"members"`
	// Custom function to add or remove an entity to this system
	AddRemoveMatchFn *SystemMatchFn `toml:"add_remove_match_fn" json:"add_remove_match_fn"`
	// Custom function to rescan all component references when a component slice changes capacity
	ResizeMatchFn         *SystemMatchFn `toml:"resize_match_fn" json:"resize_match_fn"`
	OnEntityAdded         string         `toml:"on_entity_added" json:"on_entity_added"`
	OnEntityRemoved       string         `toml:"on_entity_removed" json:"on_entity_removed"`
	OnComponentWillResize string         `toml:"on_component_will_resize" json:"on_component_will_resize"`
	OnComponentResized    string         `toml:"on_component_resized" json:"on_component_resized"`
	OnSetup               string         `toml:"on_setup" json:"on_setup"`
}

type SystemMatchFn

type SystemMatchFn struct {
	PackagePath  string `toml:"package_path" json:"package_path"`
	PackageAlias string `toml:"package_alias" json:"package_alias"`
	Name         string `toml:"name" json:"name"`
}

type SystemMember

type SystemMember struct {
	VarName         string `toml:"var_name" json:"var_name"`
	VarType         string `toml:"var_type" json:"var_type"`
	VarPackagePath  string `toml:"var_package_path" json:"var_package_path"`
	VarPackageAlias string `toml:"var_package_alias" json:"var_package_alias"`
	VarPrefix       string `toml:"var_prefix" json:"var_prefix"`
}

type SystemViewItem

type SystemViewItem struct {
	PackagePath     string `toml:"package_path" json:"package_path"`
	PackageAlias    string `toml:"package_alias" json:"package_alias"`
	StructName      string `toml:"struct_name" json:"struct_name"`
	ComponentGetter string `toml:"component_getter" json:"component_getter"`
	FlagGetter      string `toml:"flag_getter" json:"flag_getter"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL