mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-21 23:34:18 +00:00
Delete corrupt gemstone spawner
This commit is contained in:
parent
fd580fa2d6
commit
58afa4abc3
2 changed files with 0 additions and 85 deletions
|
@ -1,65 +0,0 @@
|
||||||
extends Area2D
|
|
||||||
class_name GemstoneSpawner
|
|
||||||
|
|
||||||
## A node which spawns things!
|
|
||||||
|
|
||||||
## The scene to spawn.
|
|
||||||
@export var scene: PackedScene
|
|
||||||
|
|
||||||
## The node to add new scenes to.
|
|
||||||
@export var target: Node
|
|
||||||
|
|
||||||
## Count of how many items should be spawned when possible.
|
|
||||||
var buffer: int = 0
|
|
||||||
|
|
||||||
## Maximum amount of items whose spawn can be buffered.
|
|
||||||
@export var buffer_cap: int
|
|
||||||
|
|
||||||
## Rect in which scenes can be spawned randomly in.
|
|
||||||
@export var spawn_rect: Rect2
|
|
||||||
|
|
||||||
## Minimum rotation degrees that an object can spawn with.
|
|
||||||
@export_range(0, 360) var spawn_rotation_degrees_min: float
|
|
||||||
|
|
||||||
## Maximum rotation degrees that an object can spawn with.
|
|
||||||
@export_range(0, 360) var spawn_rotation_degrees_max: float
|
|
||||||
|
|
||||||
## Maximum amount of bodies overlapping the spawner's area before the spawner stops spawning.
|
|
||||||
@export_range(0, 16, 1, "or_greater") var overlapping_body_count_limit: int
|
|
||||||
|
|
||||||
|
|
||||||
signal spawned(what: Node2D)
|
|
||||||
|
|
||||||
func gem_roll():
|
|
||||||
return Randomizer.rng.randi_range(0,360)
|
|
||||||
|
|
||||||
func spawn():
|
|
||||||
buffer += 1
|
|
||||||
if buffer > buffer_cap:
|
|
||||||
buffer = buffer_cap
|
|
||||||
|
|
||||||
func _select_spawn_position() -> Vector2:
|
|
||||||
return Vector2(
|
|
||||||
Randomizer.rng.randf_range(spawn_rect.position.x, spawn_rect.end.x),
|
|
||||||
Randomizer.rng.randf_range(spawn_rect.position.y, spawn_rect.end.y),
|
|
||||||
)
|
|
||||||
|
|
||||||
func _select_spawn_rotation() -> float:
|
|
||||||
return Randomizer.rng.randf_range(
|
|
||||||
spawn_rotation_degrees_min,
|
|
||||||
spawn_rotation_degrees_max
|
|
||||||
)
|
|
||||||
|
|
||||||
func _do_spawn():
|
|
||||||
if len(get_overlapping_bodies()) > overlapping_body_count_limit:
|
|
||||||
return
|
|
||||||
var instantiated = scene.instantiate()
|
|
||||||
instantiated.global_position = global_position + _select_spawn_position()
|
|
||||||
instantiated.rotation_degrees = _select_spawn_rotation()
|
|
||||||
target.add_child(instantiated)
|
|
||||||
spawned.emit()
|
|
||||||
buffer -= 1
|
|
||||||
|
|
||||||
func _physics_process(_delta):
|
|
||||||
if buffer > 0:
|
|
||||||
_do_spawn()
|
|
|
@ -1,20 +0,0 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cqbqoc8ftxfos"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://spawner/gemstone_spawner.gd" id="1_fk8ci"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="2_2di81"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://6pp1pebasum3" path="res://entity/gem/gemstone.tscn" id="3_goofg"]
|
|
||||||
[ext_resource type="Script" path="res://spawner/Node.gd" id="3_ra5b3"]
|
|
||||||
|
|
||||||
[node name="GemstoneSpawner" type="Node2D"]
|
|
||||||
script = ExtResource("1_fk8ci")
|
|
||||||
buffer_cap = null
|
|
||||||
spawn_rect = null
|
|
||||||
spawn_rotation_degrees_min = null
|
|
||||||
spawn_rotation_degrees_max = null
|
|
||||||
overlapping_body_count_limit = null
|
|
||||||
|
|
||||||
[node name="Spawner" parent="." instance=ExtResource("2_2di81")]
|
|
||||||
scene = ExtResource("3_goofg")
|
|
||||||
|
|
||||||
[node name="GemRandomizer" type="Node" parent="."]
|
|
||||||
script = ExtResource("3_ra5b3")
|
|
Loading…
Reference in a new issue