General code improvements, progress step tracker implementation for worldgen, and work towards enemy behavior
This commit is contained in:
@ -1,59 +1,67 @@
|
||||
class_name StandardEntityMarker
|
||||
extends Node2D
|
||||
|
||||
enum SPAWN_METHOD {
|
||||
ALL,
|
||||
FURTHEST,
|
||||
ONCE,
|
||||
NONE
|
||||
}
|
||||
## The method used to spawn entities
|
||||
##
|
||||
## ALL: Spawns all entities in the list
|
||||
## FURTHEST: Spawns the entity furthest from the player
|
||||
## ONCE: Spawns the entity once at a random marker
|
||||
## NONE: Does not spawn any entities
|
||||
enum EntitySpawnMethod { ALL, FURTHEST, ONCE, NONE }
|
||||
|
||||
enum ENTITY_SELECTION_METHOD {
|
||||
RANDOM,
|
||||
POP
|
||||
}
|
||||
## The method used to select entities
|
||||
##
|
||||
## RANDOM: Selects a random entity from the list
|
||||
## POP: Removes the entity from the list after it is selected
|
||||
enum EntitySelectionMethod { RANDOM, POP }
|
||||
|
||||
@export_category("Entity Spawning")
|
||||
@export
|
||||
var marker_id: String
|
||||
## The ID representing the type of this marker
|
||||
@export var marker_id: String
|
||||
|
||||
@export
|
||||
var entities: Array[PackedScene] = []
|
||||
## The entities that can be spawned by this marker
|
||||
@export var entities: Array[PackedScene] = []
|
||||
|
||||
@export
|
||||
var spawn_method: SPAWN_METHOD
|
||||
## The method used to spawn entities
|
||||
@export var spawn_method: EntitySpawnMethod
|
||||
|
||||
@export_range(0, 1.0)
|
||||
var spawn_chance: float = 1.0
|
||||
## The chance that an entity will be spawned
|
||||
@export_range(0, 1.0) var spawn_chance: float = 1.0
|
||||
|
||||
@export
|
||||
var entity_selection_method: ENTITY_SELECTION_METHOD
|
||||
## The method used to select entities
|
||||
@export var entity_selection_method: EntitySelectionMethod
|
||||
|
||||
@export_category("Marker Debug")
|
||||
@export
|
||||
var debug_color: Color = Color.WHITE
|
||||
## The color of the debug sprite
|
||||
@export var debug_color: Color = Color.WHITE
|
||||
|
||||
## The size of the debug sprite
|
||||
@export var marker_size: int = 16
|
||||
|
||||
@export
|
||||
var marker_size: int = 16
|
||||
|
||||
func _ready() -> void:
|
||||
self.add_to_group("genv2:entity_marker")
|
||||
|
||||
|
||||
## Create a debug sprite if one doesn't exist
|
||||
var sprite: Sprite2D = self.get_node_or_null("Sprite2D")
|
||||
if not sprite:
|
||||
sprite = Sprite2D.new()
|
||||
sprite.texture = _get_debug_texture()
|
||||
self.add_child(sprite)
|
||||
|
||||
func _register(gen: StandardWorldGenerator) -> void:
|
||||
|
||||
|
||||
## Registers this marker with the world generator
|
||||
func register(gen: StandardWorldGenerator) -> void:
|
||||
if self.marker_id == "":
|
||||
push_error("Marker ID is empty, this marker will not be used for spawning entities.")
|
||||
return
|
||||
gen._register_marker("genv2:entity_marker:%s" % self.marker_id, self)
|
||||
gen.register_marker("genv2:entity_marker:%s" % self.marker_id, self)
|
||||
|
||||
|
||||
## Generates a texture for the debug sprite
|
||||
func _get_debug_texture() -> Texture2D:
|
||||
var texture = GradientTexture2D.new()
|
||||
|
||||
|
||||
var gradient = Gradient.new()
|
||||
gradient.colors = [self.debug_color]
|
||||
|
||||
@ -61,5 +69,5 @@ func _get_debug_texture() -> Texture2D:
|
||||
|
||||
texture.width = self.marker_size
|
||||
texture.height = self.marker_size
|
||||
|
||||
|
||||
return texture
|
||||
|
Reference in New Issue
Block a user