mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
ff2e40198f
WorldEnvironment's Environment sub-resource was shared across every instantiate() of a cached arena PackedScene, so glow/brightness/sky tweaks in Arena._ready() compounded further each time a player re-entered an arena instead of applying fresh.
61 lines
2.0 KiB
GDScript
61 lines
2.0 KiB
GDScript
class_name Arena
|
|
extends Node3D
|
|
|
|
# A reusable stadium: terrain, lighting, environment, two team goals, and
|
|
# spawn markers. An arena holds no rules and no state — game modes query it
|
|
# for spawn transforms and goals, then spawn ships/ball themselves.
|
|
|
|
# Per-arena Environment tuning. These live as exports (rather than baked
|
|
# into each arena's Environment sub-resource) because Godot's scene
|
|
# inheritance can only override whole top-level node properties, not
|
|
# properties nested inside a sub-resource — so each arena_0N.tscn overrides
|
|
# these on the Arena root instead, and _ready() applies them here.
|
|
@export var sky_material: Material
|
|
@export var ambient_light_color := Color(0.55, 0.6, 0.75, 1)
|
|
@export var ambient_light_energy := 0.4
|
|
@export var glow_intensity := 0.9
|
|
@export var glow_strength := 1.2
|
|
@export var glow_bloom := 0.05
|
|
@export var glow_hdr_threshold := 1.0
|
|
|
|
|
|
func _ready():
|
|
add_to_group("arena")
|
|
var world_env := get_node_or_null("WorldEnvironment") as WorldEnvironment
|
|
if world_env and world_env.environment:
|
|
var env := world_env.environment.duplicate(true) as Environment
|
|
world_env.environment = env
|
|
if sky_material:
|
|
if not env.sky:
|
|
env.sky = Sky.new()
|
|
env.sky.sky_material = sky_material
|
|
env.ambient_light_color = ambient_light_color
|
|
env.ambient_light_energy = ambient_light_energy
|
|
env.glow_intensity = glow_intensity
|
|
env.glow_strength = glow_strength
|
|
env.glow_bloom = glow_bloom
|
|
env.glow_hdr_threshold = glow_hdr_threshold
|
|
VideoSettings.apply_to_environment(env)
|
|
|
|
|
|
func get_ball_spawn() -> Transform3D:
|
|
return $BallSpawn.global_transform
|
|
|
|
|
|
func get_ship_spawns(team: int) -> Array[Transform3D]:
|
|
var spawns: Array[Transform3D] = []
|
|
var container := get_node_or_null("SpawnsTeam%d" % team)
|
|
if container:
|
|
for child in container.get_children():
|
|
if child is Marker3D:
|
|
spawns.append(child.global_transform)
|
|
return spawns
|
|
|
|
|
|
func get_goals() -> Array[Goal]:
|
|
var goals: Array[Goal] = []
|
|
for child in get_children():
|
|
if child is Goal:
|
|
goals.append(child)
|
|
return goals
|