TileSetScenesCollectionSource

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

When placed on a TileMapLayer, tiles from TileSetScenesCollectionSource will automatically instantiate an associated scene at the cell's position in the TileMapLayer.

Scenes are instantiated as children of the TileMapLayer after it enters the tree, at the end of the frame (their creation is deferred). If you add/remove a scene tile in the TileMapLayer that is already inside the tree, the TileMapLayer will automatically instantiate/free the scene accordingly.

Note: Scene tiles all occupy one tile slot and instead use alternate tile ID to identify scene index. TileSetSource.GetTilesCount will always return 1. Use GetSceneTilesCount to get a number of scenes in a TileSetScenesCollectionSource.

Use this code if you want to find the scene path at a given tile in TileMapLayer:

package main

import (
	"graphics.gd/classdb/TileMapLayer"
	"graphics.gd/classdb/TileSetScenesCollectionSource"
	"graphics.gd/variant/Object"
	"graphics.gd/variant/Vector2i"
)

func ExampleTileSetScenesCollectionSource(tileMapLayer TileMapLayer.Instance, x, y int) {
	sourceId := tileMapLayer.GetCellSourceId(Vector2i.New(x, y))
	if sourceId > -1 {
		var scene_source = tileMapLayer.TileSet().GetSource(sourceId)
		if scene_source, ok := Object.As[TileSetScenesCollectionSource.Instance](scene_source); ok {
			altId := tileMapLayer.GetCellAlternativeTile(Vector2i.New(x, y))
			var scene = scene_source.GetSceneTileScene(altId)
			_ = scene
		}
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsTileSetScenesCollectionSource() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsTileSetScenesCollectionSource

func (self *Extension[T]) AsTileSetScenesCollectionSource() Instance

func (*Extension[T]) AsTileSetSource

func (self *Extension[T]) AsTileSetSource() TileSetSource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTileSetScenesCollectionSource

func (self Instance) AsTileSetScenesCollectionSource() Instance

func (Instance) AsTileSetSource

func (self Instance) AsTileSetSource() TileSetSource.Instance

func (Instance) CreateSceneTile

func (self Instance) CreateSceneTile(packed_scene PackedScene.Instance) int

Creates a scene-based tile out of the given scene.

Returns a newly generated unique ID.

func (Instance) GetNextSceneTileId

func (self Instance) GetNextSceneTileId() int

Returns the scene ID a following call to CreateSceneTile would return.

func (Instance) GetSceneTileDisplayPlaceholder

func (self Instance) GetSceneTileDisplayPlaceholder(id int) bool

Returns whether the scene tile with 'id' displays a placeholder in the editor.

func (Instance) GetSceneTileId

func (self Instance) GetSceneTileId(index int) int

Returns the scene tile ID of the scene tile at 'index'.

func (Instance) GetSceneTileScene

func (self Instance) GetSceneTileScene(id int) PackedScene.Instance

Returns the PackedScene resource of scene tile with 'id'.

func (Instance) GetSceneTilesCount

func (self Instance) GetSceneTilesCount() int

Returns the number or scene tiles this TileSet source has.

func (Instance) HasSceneTileId

func (self Instance) HasSceneTileId(id int) bool

Returns whether this TileSet source has a scene tile with 'id'.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) RemoveSceneTile

func (self Instance) RemoveSceneTile(id int)

Remove the scene tile with 'id'.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSceneTileDisplayPlaceholder

func (self Instance) SetSceneTileDisplayPlaceholder(id int, display_placeholder bool)

Sets whether or not the scene tile with 'id' should display a placeholder in the editor. This might be useful for scenes that are not visible.

func (Instance) SetSceneTileId

func (self Instance) SetSceneTileId(id int, new_id int)

Changes a scene tile's ID from 'id' to 'new_id'. This will fail if there is already a tile with an ID equal to 'new_id'.

func (Instance) SetSceneTileScene

func (self Instance) SetSceneTileScene(id int, packed_scene PackedScene.Instance)

Assigns a PackedScene resource to the scene tile with 'id'. This will fail if the scene does not extend CanvasItem, as positioning properties are needed to place the scene on the TileMapLayer.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) CreateSceneTile

func (self MoreArgs) CreateSceneTile(packed_scene PackedScene.Instance, id_override int) int

Creates a scene-based tile out of the given scene.

Returns a newly generated unique ID.

Jump to

Keyboard shortcuts

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