Skip to content

Commit

Permalink
Ensure all classes initialize all variables
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnvoker committed Oct 12, 2023
1 parent 051e63e commit af50a7d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
7 changes: 6 additions & 1 deletion bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ void Bullet::_bind_methods() {

Bullet::Bullet() {
ci_rid = RS::get_singleton()->canvas_item_create();
direction = Vector2(0, 0);
direction = Vector2();
position = Vector2();
type = Ref<BulletType>();
rotation = 0.0;
_offset = Vector2();
_popped = false;
}

Bullet::~Bullet() {
Expand Down
2 changes: 2 additions & 0 deletions bullet_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ void BulletServer::_bind_methods() {

BulletServer::BulletServer() {
bullet_pool_size = 1500;
max_lifetime = 0.0;
play_area_allow_incoming = true;
play_area_mode = VIEWPORT;
play_area_margin = 0;
play_area_rect = Rect2();
Expand Down
19 changes: 18 additions & 1 deletion bullet_spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,23 +754,40 @@ void BulletSpawner::_bind_methods() {
//initialiser/terminator
BulletSpawner::BulletSpawner() {
autofire = false;
_autofire_time = 0.0;
interval_frames = 10;

shot_count = 1;

radius = 10.0;
arc_width = 0.0;
arc_rotation = 0.0;
arc_offset = 0.0;

bullet_type = Ref<BulletType>();

aim_mode = RADIAL;
aim_angle = 0.0;
aim_target_position = Vector2();

scatter_mode = NONE;
scatter_range = 0.0;

pattern_mode = ALL;
active_shot_indices = PackedInt32Array();

preview_visible_in_game = false;
preview_color = Color(0.0, 1.0, 0.0, 1.0); //green
preview_shot_color = Color(1.0, 1.0, 1.0, 1.0);
preview_arc_points = 32;
preview_extent = 50;
preview_arc_points = 32;

relay_autoconnect = true;

_cached_volley = Array();
_volley_changed = true;

_previous_transform = Transform2D();
}

BulletSpawner::~BulletSpawner() {
Expand Down
15 changes: 8 additions & 7 deletions bullet_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,29 @@ void BulletType::_bind_methods() {
}

BulletType::BulletType() {
speed = 100.0;
damage = 0.0;
lifetime = 0.0;
texture = Ref<Texture2D>();
modulate = Color(1, 1, 1, 1);
light_mask = 1;
material = Ref<Material>();
face_direction = false;
scale = Vector2(1, 1);
damage = 0.0;
collision_shape = Ref<Shape2D>();
collision_mask = 1;
collision_detect_bodies = true;
collision_detect_areas = true;
speed = 100.0;
linear_acceleration = 0.0;
curve_rate = 0.0;
h_wave_type = WaveType::NONE;
h_wave_amplitude = 0.0;
h_wave_frequency = 0.0;
v_wave_type = WaveType::NONE;
v_wave_amplitude = 0.0;
v_wave_frequency = 0.0;
face_direction = false;
rotation = 0.0;
h_wave_type = WaveType::NONE;
h_wave_amplitude = 0.0;
h_wave_frequency = 0.0;
scale = Vector2(1, 1);
custom_data = Dictionary();
}

BulletType::~BulletType() {
Expand Down
4 changes: 2 additions & 2 deletions doc_classes/BulletServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
A [BulletServer] generates all bullets on ready, and adds/removes them from play by cycling them between active and inactive groups. Spawning bullets pulls them from the inactive group and makes them active, and recycles the oldest active bullet if no inactive bullets are available.
</member>
<member name="max_lifetime" type="float" setter="set_max_lifetime" getter="get_max_lifetime" default="0.0">
The maximium lifetime of any [Bullet] managed by the server. Bullets older than this are automatically popped.
The maximium lifetime of any [Bullet] managed by the server. Bullets older than this are automatically popped. Setting to 0.0 means bullets do not pop automatically.
</member>
<member name="play_area_allow_incoming" type="bool" setter="set_play_area_allow_incoming" getter="get_play_area_allow_incoming" default="false">
<member name="play_area_allow_incoming" type="bool" setter="set_play_area_allow_incoming" getter="get_play_area_allow_incoming" default="true">
If [code]true[/code], bullets outside of the play area will only be automatically popped if they are moving away from it.
Bullets outside of the play area will not detect collisions.
Calculation of whether bullet is "incoming" is approximate, and based on its angle to the center of the play area, so bullets that would enter a corner of the play area at an oblique angle may still be popped.
Expand Down

0 comments on commit af50a7d

Please sign in to comment.