# Rally Rush: godot::Spawner Class Reference

Loading...
Searching...
No Matches
godot::Spawner Class Reference

Singleton managing enemy and key spawning. Spawns a single enemy at an interval, selecting drone or car based on which is required or taking turns if both. Spawns three keys at the start of the game. More...

`#include <spawner.hpp>`

Inheritance diagram for godot::Spawner:

## Public Member Functions

virtual void | _enter_tree () override
| Spawn three keys. Store gamemode reference.
virtual void | _process (double delta_time) override
| Update timer, spawn new enemy as required.
int | max_enemy_cars ()
| The max number of cars, increases with number of keys found.
int | max_enemy_drones ()
| The max number of drones, increases with number of enemies found.

## Protected Member Functions

void | spawn_enemy_car ()
| Spawn an enemy car at a random spawnpoint. Increases car counter.
void | spawn_enemy_drone ()
| Spawn an enemy drone at a random spawnpoint. Increases drone counter.
void | spawn_key ()
| Spawn a key at a random spawnpoint.
void | decrement_cars ()
| Listener for when a car is destroyed somehow. Decreases car counter.
void | decrement_drones ()
| Listener for when a drone is destroyed somehow. Decreases drone counter.
void | set_drone_scene (Ref< PackedScene > scene)
| The scene to instantiate for drones.
Ref< PackedScene > | get_drone_scene () const
| The scene to instantiate for drones.
void | set_car_scene (Ref< PackedScene > scene)
| The scene to instantiate for cars.
Ref< PackedScene > | get_car_scene () const
| The scene to instantiate for cars.
void | set_key_scene (Ref< PackedScene > scene)
| The scene to instantiate for keys.
Ref< PackedScene > | get_key_scene () const
| The scene to instantiate for keys.

## Private Member Functions

| GDCLASS (Spawner, Node)

## Static Private Member Functions

static void | _bind_methods ()
| Register editor properties.

## Private Attributes

double | next {0}
| Time at which the next spawn tick will go.
unsigned | tick {0}
| The number of spawn ticks that have happened, could overflow, though that's not a problem.
Ref< PackedScene > | drone_scene {}
Ref< PackedScene > | car_scene {}
Ref< PackedScene > | key_scene {}
RandomNumberGenerator | rng {}
unsigned | num_cars {0}
unsigned | num_drones {0}
RallyRushGameMode * | game_mode
| Reference to the game mode.

## Detailed Description

Singleton managing enemy and key spawning. Spawns a single enemy at an interval, selecting drone or car based on which is required or taking turns if both. Spawns three keys at the start of the game.

## Member Function Documentation

## _bind_methods()

void godot::Spawner::_bind_methods | ( |  | ) |

staticprivate

Register editor properties.

## _enter_tree()

void godot::Spawner::_enter_tree | ( |  | ) |

overridevirtual

Spawn three keys. Store gamemode reference.

## _process()

void godot::Spawner::_process | ( | double | delta_time | ) |

overridevirtual

Update timer, spawn new enemy as required.

## decrement_cars()

void godot::Spawner::decrement_cars | ( |  | ) |

protected

Listener for when a car is destroyed somehow. Decreases car counter.

## decrement_drones()

void godot::Spawner::decrement_drones | ( |  | ) |

protected

Listener for when a drone is destroyed somehow. Decreases drone counter.

## GDCLASS()

godot::Spawner::GDCLASS | ( | Spawner | ,
|  | Node |
| ) |  |

private

## get_car_scene()

Ref< PackedScene > godot::Spawner::get_car_scene | ( |  | ) | const

protected

The scene to instantiate for cars.

## get_drone_scene()

Ref< PackedScene > godot::Spawner::get_drone_scene | ( |  | ) | const

protected

The scene to instantiate for drones.

## get_key_scene()

Ref< PackedScene > godot::Spawner::get_key_scene | ( |  | ) | const

protected

The scene to instantiate for keys.

## max_enemy_cars()

int godot::Spawner::max_enemy_cars | ( |  | ) |

The max number of cars, increases with number of keys found.

## max_enemy_drones()

int godot::Spawner::max_enemy_drones | ( |  | ) |

The max number of drones, increases with number of enemies found.

## set_car_scene()

void godot::Spawner::set_car_scene | ( | Ref< PackedScene > | scene | ) |

protected

The scene to instantiate for cars.

## set_drone_scene()

void godot::Spawner::set_drone_scene | ( | Ref< PackedScene > | scene | ) |

protected

The scene to instantiate for drones.

## set_key_scene()

void godot::Spawner::set_key_scene | ( | Ref< PackedScene > | scene | ) |

protected

The scene to instantiate for keys.

## spawn_enemy_car()

void godot::Spawner::spawn_enemy_car | ( |  | ) |

protected

Spawn an enemy car at a random spawnpoint. Increases car counter.

## spawn_enemy_drone()

void godot::Spawner::spawn_enemy_drone | ( |  | ) |

protected

Spawn an enemy drone at a random spawnpoint. Increases drone counter.

## spawn_key()

void godot::Spawner::spawn_key | ( |  | ) |

protected

Spawn a key at a random spawnpoint.

## Member Data Documentation

## car_scene

Ref<PackedScene> godot::Spawner::car_scene {}

private

## drone_scene

Ref<PackedScene> godot::Spawner::drone_scene {}

private

## game_mode

RallyRushGameMode* godot::Spawner::game_mode

private

Reference to the game mode.

## key_scene

Ref<PackedScene> godot::Spawner::key_scene {}

private

## next

double godot::Spawner::next {0}

private

Time at which the next spawn tick will go.

## num_cars

unsigned godot::Spawner::num_cars {0}

private

## num_drones

unsigned godot::Spawner::num_drones {0}

private

## rng

RandomNumberGenerator godot::Spawner::rng {}

private

## tick

unsigned godot::Spawner::tick {0}

private

The number of spawn ticks that have happened, could overflow, though that's not a problem.

The documentation for this class was generated from the following files:

- src/spawner.hpp
- src/spawner.cpp