geep: add new gear
This commit is contained in:
parent
20d1f62a7d
commit
e16f87cbfa
4 changed files with 157 additions and 0 deletions
62
gears/geep.gd
Normal file
62
gears/geep.gd
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
class_name Geep extends "gear.gd"
|
||||
|
||||
func gear_name():
|
||||
return "Geep"
|
||||
func continuous():
|
||||
return false
|
||||
func use_basis():
|
||||
return idle_basis()
|
||||
|
||||
# multiplier of player's speed
|
||||
const speed = 2
|
||||
# how far the vehicle lifts the player off the ground
|
||||
const lift = 2
|
||||
|
||||
var box = null
|
||||
var driver = null
|
||||
var active = false
|
||||
|
||||
func init_driver(player):
|
||||
driver = player
|
||||
if not box:
|
||||
box = Vector3(driver.get_node("CollisionShape3D").shape.size)
|
||||
|
||||
func mount():
|
||||
active = true
|
||||
position = Vector3(-driver.get_node("Pivot/Container").position)
|
||||
position.y += 1
|
||||
driver.message(
|
||||
"Press [%s] to exit the Geep"
|
||||
% Util.input_action_string("gear_use"))
|
||||
driver.get_node("CameraGimbal").position.y += lift
|
||||
driver.get_node("Pivot/Mesh").position.y += lift
|
||||
driver.get_node("CollisionShape3D").shape.size = $GearMesh/Vehicle/CollisionShape3D.shape.size
|
||||
driver.protected = true
|
||||
driver.suspended = true
|
||||
|
||||
func unmount():
|
||||
active = false
|
||||
position = Vector3.ZERO
|
||||
driver.message("")
|
||||
driver.get_node("CameraGimbal").position = Vector3.ZERO
|
||||
driver.get_node("Pivot/Mesh").position = Vector3.ZERO
|
||||
driver.get_node("CollisionShape3D").shape.size = box
|
||||
driver.protected = false
|
||||
driver.suspended = false
|
||||
|
||||
func on_use(player):
|
||||
init_driver(player)
|
||||
if active:
|
||||
unmount()
|
||||
else:
|
||||
mount()
|
||||
|
||||
func on_unequip(player):
|
||||
init_driver(player)
|
||||
unmount()
|
||||
|
||||
func _physics_process(_delta):
|
||||
if not active:
|
||||
return
|
||||
|
||||
driver.move_player(0, -speed)
|
||||
Loading…
Add table
Add a link
Reference in a new issue