engine

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreDirEntry

func IgnoreDirEntry(entry os.DirEntry) bool

IgnoreDirEntry reports whether the given directory entry should be ignored. If no directory entry is given, then the entry is always ignored.

A directory entry is ignored if it is not a directory or its name starts with an underscore.

Parameters:

  • entry: The directory entry to check.

Returns:

  • bool: `true` if the entry should be ignored, `false` otherwise.

func IncludeAsset

func IncludeAsset(pb *ProjectBuilder, asset_name, filename string) error

IncludeAsset adds an asset to the project.

Only PNG assets are supported.

Parameters:

  • pb: The project builder to use.
  • asset_name: The name of the asset to include.
  • filename: The name of the asset to include.

Returns:

  • error: An error if the asset could not be included.

Errors:

  • errors.ErrBadParam: If the project builder is `nil`.
  • errors.NewF: If the extension is not supported.
  • any other error: Depends on the call to os.ReadFile, the unmarshal raw method of the asset, and the include game asset method of ProjectBuilder.

func IncludeDirectory

func IncludeDirectory(pb *ProjectBuilder, asset_name, dirname string) error

IncludeDirectory adds all the assets in the given directory to the project.

This function recursively includes all the assets in the directory.

Parameters:

  • pb: The project builder to use.
  • asset_name: The name of the asset to include.
  • dirname: The name of the directory.

Returns:

  • error: An error if the directory could not be included.

Errors:

  • errors.ErrNilReceiver: If the receiver is `nil`.
  • slices.ErrSizeExceeded: If the number of assets exceeds the maximum allowed.
  • errors.NewF: If the directory could not be included.

func WalkProject

func WalkProject(root string) iter.Seq2[WPInfo, error]

WalkProject returns an iterator that walks the project directory.

The iterator is not single use only and traverses the directory in a DFS manner. It stops either when an error is returned or when the directory stack is empty.

Parameters:

  • root: The directory to walk.

Returns:

  • iter.Seq2[WPInfo, error]: The iterator. It is never `nil`.

Types

type AssetBundler

type AssetBundler struct {
	// contains filtered or unexported fields
}

AssetBundler is the struct that bundles assets together.

func (*AssetBundler) IncludeAsset

func (ab *AssetBundler) IncludeAsset(name string, ga asl.GameAsset) error

type ProjectBuilder

type ProjectBuilder struct {
	// contains filtered or unexported fields
}

ProjectBuilder is the struct that builds a project.

func NewProjectBuilder

func NewProjectBuilder(root string) (*ProjectBuilder, error)

NewProjectBuilder returns a new ProjectBuilder.

Parameters:

  • root: The root directory of the project.

Returns:

  • *ProjectBuilder: The newly created ProjectBuilder.
  • error: An error if the root directory could not be made absolute.

Errors:

func (*ProjectBuilder) Build

func (pb *ProjectBuilder) Build() error

Build builds the project.

Returns:

  • error: An error if the project could not be built.

Errors:

  • errors.ErrNilReceiver: If the receiver is `nil`.

func (*ProjectBuilder) Contains

func (pb *ProjectBuilder) Contains(filename string) bool

Contains reports whether the project contains the given asset. If the receiver is `nil`, the project is defined to not contain the asset.

Parameters:

  • filename: The name of the asset to check.

Returns:

  • bool: `true` if the project contains the given asset, `false` otherwise.

func (*ProjectBuilder) IncludeGameAsset

func (pb *ProjectBuilder) IncludeGameAsset(name string, ga asl.GameAsset) error

IncludeGameAsset adds a game asset to the project.

Parameters:

  • name: The name of the asset of the game asset.
  • ga: The game asset to include.

Returns:

  • error: An error if the asset could not be included.

Errors:

  • errors.ErrNilReceiver: If the receiver is `nil`.
  • errors.ErrBadParam: If the game asset is `nil`.
  • memory.ErrIllegalAccess: If the project builder has been destroyed.
  • slices.ErrSizeExceeded: If the number of assets exceeds the maximum allowed.
  • errors.New: If the asset is already included.

func (*ProjectBuilder) List

func (pb *ProjectBuilder) List() []string

List returns the list of assets in the project. If the receiver is `nil`, no list is returned.

The list of assets is in alphabetical order. Only the first slices.MAX_SLICE_SIZE assets are returned.

Returns:

  • []string: The list of assets.

func (*ProjectBuilder) Root

func (pb *ProjectBuilder) Root() string

Root returns the root directory of the project. If the receiver is `nil`, no root directory is returned.

Returns:

  • string: The root directory of the project.

type WPInfo

type WPInfo struct {
	// RelativePath is the path to the file.
	RelativePath string

	// Name is the name of the file.
	Name string

	// Ext is the extension of the file.
	Ext string
}

WPInfo is the info about the walk project iterator.

Jump to

Keyboard shortcuts

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