initial commit
This commit is contained in:
commit
79951d8075
22 changed files with 729 additions and 0 deletions
36
gears/ball.gd
Normal file
36
gears/ball.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
class_name Ball extends "gear.gd"
|
||||
|
||||
func gear_name():
|
||||
return "Ball"
|
||||
func gear_id():
|
||||
return 1
|
||||
func continuous():
|
||||
return false
|
||||
|
||||
func make_ball(player):
|
||||
var ball = RigidBody3D.new()
|
||||
var cs = CollisionShape3D.new()
|
||||
cs.shape = SphereShape3D.new()
|
||||
ball.name = "Ball"
|
||||
ball.mass = 4
|
||||
ball.position = Vector3.ZERO
|
||||
ball.global_transform = Transform3D(
|
||||
player.get_node("Pivot/Container").global_transform)
|
||||
|
||||
ball.set_collision_layer_value(1, false)
|
||||
ball.set_collision_layer_value(3, true)
|
||||
ball.set_collision_mask_value(3, true)
|
||||
|
||||
var mesh = $GearMesh.duplicate()
|
||||
mesh.position = Vector3.ZERO
|
||||
ball.add_child(mesh)
|
||||
ball.add_child(cs)
|
||||
|
||||
return ball
|
||||
|
||||
func on_use(player):
|
||||
var ball = make_ball(player)
|
||||
var impulse = player.get_node("CameraGimbal").basis.z * -64
|
||||
impulse.y = 4
|
||||
ball.apply_central_impulse(impulse)
|
||||
player.add_sibling(ball)
|
||||
22
gears/ball.tscn
Normal file
22
gears/ball.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c117buhmmkvkt"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://s3273etto01h" path="res://gears/ball.gd" id="1_1ps3n"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1ps3n"]
|
||||
albedo_color = Color(1, 0.5647059, 0.5647059, 1)
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_g55y5"]
|
||||
material = SubResource("StandardMaterial3D_1ps3n")
|
||||
|
||||
[node name="Gear" type="Node3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0, 0)
|
||||
rotation_edit_mode = 2
|
||||
script = ExtResource("1_1ps3n")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="GearMesh" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_g55y5")
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
43
gears/gear.gd
Normal file
43
gears/gear.gd
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
@icon("./gear.png")
|
||||
class_name Gear extends Node3D
|
||||
|
||||
var idle_basis = Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 1, 0),
|
||||
Vector3(0, 0, 1))
|
||||
var use_basis = Basis(
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 0, -1),
|
||||
Vector3(0, 1, 0))
|
||||
var pickup_basis = idle_basis
|
||||
|
||||
func gear_name():
|
||||
return "Gear"
|
||||
func gear_id():
|
||||
return 0
|
||||
func model_file():
|
||||
return "hammer.glb"
|
||||
func continuous():
|
||||
return false
|
||||
|
||||
# this can be redefined to make a custom
|
||||
# gear mesh, e.g. a SphereMesh
|
||||
func use(player):
|
||||
basis = use_basis
|
||||
$Timer.start()
|
||||
on_use(player)
|
||||
|
||||
func on_use(_player):
|
||||
pass
|
||||
|
||||
func on_ready():
|
||||
pass
|
||||
|
||||
func _on_timer_timeout():
|
||||
basis = idle_basis
|
||||
|
||||
func _ready():
|
||||
basis = idle_basis
|
||||
if get_parent() is GearPickup:
|
||||
basis = pickup_basis
|
||||
on_ready()
|
||||
BIN
gears/gear.png
Normal file
BIN
gears/gear.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
17
gears/gear.tscn
Normal file
17
gears/gear.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bafl8q0r61xrg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dc83u0v4s15yc" path="res://gears/gear.gd" id="1_0lgiy"]
|
||||
[ext_resource type="PackedScene" uid="uid://btkm0yadpycun" path="res://models/hammer.glb" id="2_i4ub2"]
|
||||
|
||||
[node name="Gear" type="Node3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0, 0)
|
||||
rotation_edit_mode = 2
|
||||
script = ExtResource("1_0lgiy")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="GearMesh" parent="." instance=ExtResource("2_i4ub2")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
13
gears/gear_pickup.gd
Normal file
13
gears/gear_pickup.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class_name GearPickup extends Area3D
|
||||
|
||||
@export var one_shot = false
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body is not Player:
|
||||
return
|
||||
var taken = body.equip($Gear)
|
||||
if taken and one_shot:
|
||||
queue_free()
|
||||
|
||||
func _ready():
|
||||
assert($Gear is Gear, "GearPickup instantiated without child Gear!")
|
||||
16
gears/gear_pickup.tscn
Normal file
16
gears/gear_pickup.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://of6tq8gpjxtu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dc84ngcaxqd0c" path="res://gears/gear_pickup.gd" id="1_46ram"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_eqvx5"]
|
||||
size = Vector3(1.5, 1.5, 1.5)
|
||||
|
||||
[node name="GearPickup" type="Area3D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_46ram")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("BoxShape3D_eqvx5")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue