summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-10-30 01:59:06 -0400
committerMalfurious <m@lfurio.us>2022-10-30 01:59:06 -0400
commit57eaeff00597f8ae6289b935dec0c408e21759ab (patch)
tree37d052e275b1937a760350339be465f19cc4acf3
parentacaea7bf1657f02670c2551357be178b0bf16f75 (diff)
downloadproject-s-57eaeff00597f8ae6289b935dec0c408e21759ab.tar.gz
project-s-57eaeff00597f8ae6289b935dec0c408e21759ab.zip
Convert script tabs to spaces
and other whitespace fixes! Signed-off-by: Malfurious <m@lfurio.us>
-rw-r--r--assets/characters/base_character/BaseCharacter.gd22
-rw-r--r--assets/maps/misc/test_map/test_map_assets/crane/crane_carriage/crane_carriage.gd46
-rw-r--r--assets/maps/misc/test_map/test_map_assets/crane/crane_frame/animation.gd3
-rw-r--r--assets/view_model/ViewModel.gd134
-rw-r--r--assets/weapons/goo_gun/Bullet.gd6
-rw-r--r--assets/weapons/goo_gun/GooGun.gd28
-rw-r--r--custom_shaders/liquid.gdshader4
-rw-r--r--utility_scripts/shader_compiler.gd98
8 files changed, 166 insertions, 175 deletions
diff --git a/assets/characters/base_character/BaseCharacter.gd b/assets/characters/base_character/BaseCharacter.gd
index 5d1b013..f9df8e9 100644
--- a/assets/characters/base_character/BaseCharacter.gd
+++ b/assets/characters/base_character/BaseCharacter.gd
@@ -7,16 +7,16 @@ export var weapon_pitch = 0
export var weapon_pitch_bias = deg2rad(20)
func _ready():
- look_angle = rotation.y
- if material != null:
- $Body.set("material/0", material)
- $GooGun.projectile_material = material
+ look_angle = rotation.y
+ if material != null:
+ $Body.set("material/0", material)
+ $GooGun.projectile_material = material
func _process(_delta):
- var effective_weapon_pitch = weapon_pitch - weapon_pitch_bias if is_firing else weapon_pitch
- effective_weapon_pitch = clamp(effective_weapon_pitch, deg2rad(-90), deg2rad(90))
- $GooGun.is_firing = is_firing
- $GooGun.look_angle = look_angle
- $GooGun.weapon_pitch = effective_weapon_pitch
- $GooGun.rotation.x = effective_weapon_pitch
- rotation.y = look_angle
+ var effective_weapon_pitch = weapon_pitch - weapon_pitch_bias if is_firing else weapon_pitch
+ effective_weapon_pitch = clamp(effective_weapon_pitch, deg2rad(-90), deg2rad(90))
+ $GooGun.is_firing = is_firing
+ $GooGun.look_angle = look_angle
+ $GooGun.weapon_pitch = effective_weapon_pitch
+ $GooGun.rotation.x = effective_weapon_pitch
+ rotation.y = look_angle
diff --git a/assets/maps/misc/test_map/test_map_assets/crane/crane_carriage/crane_carriage.gd b/assets/maps/misc/test_map/test_map_assets/crane/crane_carriage/crane_carriage.gd
index 7618ed3..2b21dac 100644
--- a/assets/maps/misc/test_map/test_map_assets/crane/crane_carriage/crane_carriage.gd
+++ b/assets/maps/misc/test_map/test_map_assets/crane/crane_carriage/crane_carriage.gd
@@ -1,6 +1,6 @@
extends Spatial
-#This script runs the crane animations in a loop.
+#This script runs the crane animations in a loop.
onready var anim = $AnimationPlayer
onready var timer = $crane_load/Timer
@@ -8,31 +8,27 @@ onready var timer = $crane_load/Timer
var stage = 0
func _ready():
- timer.wait_time = 10
- timer.one_shot = true
- timer.start()
-
-
+ timer.wait_time = 10
+ timer.one_shot = true
+ timer.start()
func _on_Timer_timeout():
- if stage == 0:
- anim.play("pick_up_crate")
- elif stage == 1:
- anim.play("move_x_negative")
- elif stage == 2:
- anim.play_backwards("pick_up_crate")
- elif stage == 3:
- anim.play("pick_up_crate")
- elif stage == 4:
- anim.play_backwards("move_x_negative")
- elif stage == 5:
- anim.play_backwards("pick_up_crate")
- elif stage == 6:
- stage = 0
- timer.start()
-
+ if stage == 0:
+ anim.play("pick_up_crate")
+ elif stage == 1:
+ anim.play("move_x_negative")
+ elif stage == 2:
+ anim.play_backwards("pick_up_crate")
+ elif stage == 3:
+ anim.play("pick_up_crate")
+ elif stage == 4:
+ anim.play_backwards("move_x_negative")
+ elif stage == 5:
+ anim.play_backwards("pick_up_crate")
+ elif stage == 6:
+ stage = 0
+ timer.start()
func _on_AnimationPlayer_animation_finished(_anim_name):
- stage += 1
- timer.start()
-
+ stage += 1
+ timer.start()
diff --git a/assets/maps/misc/test_map/test_map_assets/crane/crane_frame/animation.gd b/assets/maps/misc/test_map/test_map_assets/crane/crane_frame/animation.gd
index c139e88..8b674ef 100644
--- a/assets/maps/misc/test_map/test_map_assets/crane/crane_frame/animation.gd
+++ b/assets/maps/misc/test_map/test_map_assets/crane/crane_frame/animation.gd
@@ -1,5 +1,4 @@
extends AnimationPlayer
-
func _ready():
- self.play("flash_beacon")
+ self.play("flash_beacon")
diff --git a/assets/view_model/ViewModel.gd b/assets/view_model/ViewModel.gd
index 949bfab..96e0f3e 100644
--- a/assets/view_model/ViewModel.gd
+++ b/assets/view_model/ViewModel.gd
@@ -14,78 +14,78 @@ onready var spring_arm = $Anchor/SpringArm
onready var fps_label = $fps_label
func _ready():
- Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _process(_delta):
- # The character model and the spring arm anchor are independent to allow them to rotate
- # independently. Recouple their translations here so that the camera follows the model through
- # space.
- anchor.translation = character.translation
-
- # Update fps counter in HUD
- fps_label.text = "FPS: " + str(Engine.get_frames_per_second())
+ # The character model and the spring arm anchor are independent to allow them to rotate
+ # independently. Recouple their translations here so that the camera follows the model through
+ # space.
+ anchor.translation = character.translation
+
+ # Update fps counter in HUD
+ fps_label.text = "FPS: " + str(Engine.get_frames_per_second())
func _physics_process(delta):
- # Intended movement direction with the rotational angle adjusted by the camera's aim direction
- var move_direction = Vector3.ZERO
- move_direction.x = Input.get_action_strength("right") - Input.get_action_strength("left")
- move_direction.z = Input.get_action_strength("back") - Input.get_action_strength("forward")
- move_direction = move_direction.rotated(Vector3.UP, spring_arm.rotation.y).normalized()
-
- # Update velocity by new movement direction and continued effect of "gravity"
- velocity.x = move_direction.x * movement_speed
- velocity.z = move_direction.z * movement_speed
- velocity.y -= gravity * delta
-
- # Snap vector management: set to ZERO to enable jumping, DOWN otherwise to stick to surfaces.
- # Allow jump action for only one frame if already standing on a floor.
- var just_landed = character.is_on_floor() and snap == Vector3.ZERO
- var jump = character.is_on_floor() and Input.is_action_just_pressed("jump")
- if jump:
- velocity.y = jump_strength
- snap = Vector3.ZERO
- elif just_landed:
- snap = Vector3.DOWN
-
- # Move character. Param 4 (true) means stop on slopes
- velocity = character.move_and_slide_with_snap(velocity, snap, Vector3.UP, true)
-
- # Update character look direction to face towards aiming if firing
- if Input.is_action_pressed("fire"):
- character.look_angle = spring_arm.rotation.y
- character.weapon_pitch = -spring_arm.rotation.x
- # Update character look direction if moved
- elif move_direction.length() > 0.2:
- var look_direction = Vector2(-velocity.z, -velocity.x)
- character.look_angle = look_direction.angle()
- character.weapon_pitch = 0
- else:
- character.weapon_pitch = 0
-
- # Handle extra player inputs
- character.is_firing = Input.is_action_pressed("fire")
-
- if Input.is_action_just_pressed("ping"):
- cycle_parent()
-
- if Input.is_action_just_pressed("menu"):
- get_tree().quit()
+ # Intended movement direction with the rotational angle adjusted by the camera's aim direction
+ var move_direction = Vector3.ZERO
+ move_direction.x = Input.get_action_strength("right") - Input.get_action_strength("left")
+ move_direction.z = Input.get_action_strength("back") - Input.get_action_strength("forward")
+ move_direction = move_direction.rotated(Vector3.UP, spring_arm.rotation.y).normalized()
+
+ # Update velocity by new movement direction and continued effect of "gravity"
+ velocity.x = move_direction.x * movement_speed
+ velocity.z = move_direction.z * movement_speed
+ velocity.y -= gravity * delta
+
+ # Snap vector management: set to ZERO to enable jumping, DOWN otherwise to stick to surfaces.
+ # Allow jump action for only one frame if already standing on a floor.
+ var just_landed = character.is_on_floor() and snap == Vector3.ZERO
+ var jump = character.is_on_floor() and Input.is_action_just_pressed("jump")
+ if jump:
+ velocity.y = jump_strength
+ snap = Vector3.ZERO
+ elif just_landed:
+ snap = Vector3.DOWN
+
+ # Move character. Param 4 (true) means stop on slopes
+ velocity = character.move_and_slide_with_snap(velocity, snap, Vector3.UP, true)
+
+ # Update character look direction to face towards aiming if firing
+ if Input.is_action_pressed("fire"):
+ character.look_angle = spring_arm.rotation.y
+ character.weapon_pitch = -spring_arm.rotation.x
+ # Update character look direction if moved
+ elif move_direction.length() > 0.2:
+ var look_direction = Vector2(-velocity.z, -velocity.x)
+ character.look_angle = look_direction.angle()
+ character.weapon_pitch = 0
+ else:
+ character.weapon_pitch = 0
+
+ # Handle extra player inputs
+ character.is_firing = Input.is_action_pressed("fire")
+
+ if Input.is_action_just_pressed("ping"):
+ cycle_parent()
+
+ if Input.is_action_just_pressed("menu"):
+ get_tree().quit()
func _unhandled_input(event):
- # Implement mouse aim direction
- if event is InputEventMouseMotion:
- spring_arm.rotation_degrees.x -= event.relative.y * aim_sensitivity
- spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -90, 90)
-
- spring_arm.rotation_degrees.y -= event.relative.x * aim_sensitivity
- spring_arm.rotation_degrees.y = wrapf(spring_arm.rotation_degrees.y, 0, 360)
+ # Implement mouse aim direction
+ if event is InputEventMouseMotion:
+ spring_arm.rotation_degrees.x -= event.relative.y * aim_sensitivity
+ spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -90, 90)
+
+ spring_arm.rotation_degrees.y -= event.relative.x * aim_sensitivity
+ spring_arm.rotation_degrees.y = wrapf(spring_arm.rotation_degrees.y, 0, 360)
func cycle_parent():
- var parents = get_tree().get_nodes_in_group("players")
- var idx = parents.find(character)
-
- if idx < 0 or idx == parents.size() - 1:
- if parents.size() > 0:
- character = parents[0]
- else:
- character = parents[idx + 1]
+ var parents = get_tree().get_nodes_in_group("players")
+ var idx = parents.find(character)
+
+ if idx < 0 or idx == parents.size() - 1:
+ if parents.size() > 0:
+ character = parents[0]
+ else:
+ character = parents[idx + 1]
diff --git a/assets/weapons/goo_gun/Bullet.gd b/assets/weapons/goo_gun/Bullet.gd
index 2edba6b..5c5097f 100644
--- a/assets/weapons/goo_gun/Bullet.gd
+++ b/assets/weapons/goo_gun/Bullet.gd
@@ -3,8 +3,8 @@ extends RigidBody
export var material : Material = null
func _ready():
- if material != null:
- $MeshInstance.set("material/0", material)
+ if material != null:
+ $MeshInstance.set("material/0", material)
func _on_Bullet_body_entered(_body):
- queue_free()
+ queue_free()
diff --git a/assets/weapons/goo_gun/GooGun.gd b/assets/weapons/goo_gun/GooGun.gd
index 6cb87fc..8ee6e0f 100644
--- a/assets/weapons/goo_gun/GooGun.gd
+++ b/assets/weapons/goo_gun/GooGun.gd
@@ -13,19 +13,19 @@ var time_since_fire = 0
var Bullet = preload("res://assets/weapons/goo_gun/Bullet.tscn")
func _physics_process(delta):
- if is_firing:
- time_since_fire += delta
- if time_since_fire >= fire_rate:
- time_since_fire -= fire_rate
- do_fire_projectile()
- else:
- time_since_fire = fire_rate
+ if is_firing:
+ time_since_fire += delta
+ if time_since_fire >= fire_rate:
+ time_since_fire -= fire_rate
+ do_fire_projectile()
+ else:
+ time_since_fire = fire_rate
func do_fire_projectile():
- var bullet = Bullet.instance()
- bullet.material = projectile_material
- $Nozzle.add_child(bullet)
- bullet.set_as_toplevel(true)
- var shoot_direction = Vector3.FORWARD.rotated(Vector3.LEFT, weapon_pitch)
- shoot_direction = shoot_direction.rotated(Vector3.UP, look_angle)
- bullet.apply_central_impulse(shoot_direction.normalized() * projectile_scalar)
+ var bullet = Bullet.instance()
+ bullet.material = projectile_material
+ $Nozzle.add_child(bullet)
+ bullet.set_as_toplevel(true)
+ var shoot_direction = Vector3.FORWARD.rotated(Vector3.LEFT, weapon_pitch)
+ shoot_direction = shoot_direction.rotated(Vector3.UP, look_angle)
+ bullet.apply_central_impulse(shoot_direction.normalized() * projectile_scalar)
diff --git a/custom_shaders/liquid.gdshader b/custom_shaders/liquid.gdshader
index b5b913b..529f25c 100644
--- a/custom_shaders/liquid.gdshader
+++ b/custom_shaders/liquid.gdshader
@@ -12,9 +12,7 @@ uniform sampler2D normal : hint_normal;
uniform float wave_speed : hint_range(0.0, 10.0);
uniform float wave_height : hint_range(0.0, 10.0);
-
-void fragment(){
-
+void fragment() {
vec2 moving_uv = UV + (TIME * normal_speed);
ALBEDO = albedo.rgb;
diff --git a/utility_scripts/shader_compiler.gd b/utility_scripts/shader_compiler.gd
index 7ef6104..8048c8a 100644
--- a/utility_scripts/shader_compiler.gd
+++ b/utility_scripts/shader_compiler.gd
@@ -1,10 +1,10 @@
extends Spatial
#This script loops through all the nodes in the scene, finds their materials,
-#then adds them to a generated quad mesh to force all shaders to be compiled.
+#then adds them to a generated quad mesh to force all shaders to be compiled.
#Once they are all compiled, the node emits a signal saying it's done and frees itself.
-#This is to prevent frame stutter when compiling shaders mid-game.
+#This is to prevent frame stutter when compiling shaders mid-game.
#If you need to compile a material that is not present
#when the scene loads (i.e. instanced nodes) add a copy of their .tscn as a child of
#this node in the scene window.
@@ -20,59 +20,57 @@ var found_materials = []
var found_particles = []
var counter = 0
-
func _ready():
- compile_shaders(get_tree().root)
+ compile_shaders(get_tree().root)
func _process(_delta):
- counter += 1
- if counter >= num_frames:
- emit_signal("all_shaders_compiled")
- queue_free()
-
+ counter += 1
+ if counter >= num_frames:
+ emit_signal("all_shaders_compiled")
+ queue_free()
+
func compile_shaders(scene):
- for child in scene.get_children():
- if child is MeshInstance:
- for i in range(child.get_surface_material_count()):
- var mat = child.get_surface_material(i)
- if mat == null:
- mat = child.mesh.surface_get_material(i)
- if mat == null:
- print("Error: No material assigned to " + str(child.name) + ". Could not compile.")
-
- if is_instance_valid(mat):
- if not mat in found_materials:
- generate_quad(mat)
- found_materials.append(mat)
-
- if child is Particles:
- var particle = child as Particles
- var particle_mat = particle.get_process_material()
-
- if particle_mat == null:
- print("Error: No process material assigned to " + str(child.name) + ". Could not compile.")
-
- if is_instance_valid(particle_mat):
- if not particle_mat in found_particles:
- var particles_to_compile = particle.duplicate()
- duplicate_particles(particles_to_compile)
- found_particles.append(particle_mat)
-
- compile_shaders(child)
-
+ for child in scene.get_children():
+ if child is MeshInstance:
+ for i in range(child.get_surface_material_count()):
+ var mat = child.get_surface_material(i)
+ if mat == null:
+ mat = child.mesh.surface_get_material(i)
+ if mat == null:
+ print("Error: No material assigned to " + str(child.name) + ". Could not compile.")
+
+ if is_instance_valid(mat):
+ if not mat in found_materials:
+ generate_quad(mat)
+ found_materials.append(mat)
+
+ if child is Particles:
+ var particle = child as Particles
+ var particle_mat = particle.get_process_material()
+
+ if particle_mat == null:
+ print("Error: No process material assigned to " + str(child.name) + ". Could not compile.")
+
+ if is_instance_valid(particle_mat):
+ if not particle_mat in found_particles:
+ var particles_to_compile = particle.duplicate()
+ duplicate_particles(particles_to_compile)
+ found_particles.append(particle_mat)
+
+ compile_shaders(child)
func generate_quad(material):
- var quad = QuadMesh.new()
- var mesh = MeshInstance.new()
- mesh.mesh = quad
- mesh.set_surface_material(0, material)
- add_child(mesh)
-
- mesh.global_transform.origin.x += randf() * 0.5
- mesh.global_transform.origin.y += randf() * 0.5
- mesh.global_transform.origin.z += randf() * 0.5
+ var quad = QuadMesh.new()
+ var mesh = MeshInstance.new()
+ mesh.mesh = quad
+ mesh.set_surface_material(0, material)
+ add_child(mesh)
+
+ mesh.global_transform.origin.x += randf() * 0.5
+ mesh.global_transform.origin.y += randf() * 0.5
+ mesh.global_transform.origin.z += randf() * 0.5
func duplicate_particles(particle_node):
- particle_node.translation = self.translation
- particle_node.rotation = Vector3.ZERO
- add_child(particle_node)
+ particle_node.translation = self.translation
+ particle_node.rotation = Vector3.ZERO
+ add_child(particle_node)