updates
This commit is contained in:
parent
4298caf5cb
commit
2e6638b744
19 changed files with 484 additions and 185 deletions
|
|
@ -1,13 +1,14 @@
|
|||
class_name WeaponModels
|
||||
extends Node3D
|
||||
## The scarecrow's weapons as it holds them (ScarecrowCombat), from the models in
|
||||
## assets/weapons/, on the scarecrow's model (which faces -Z), only the one in use showing. The
|
||||
## Blender exports sit far from the origin, so each mesh is re-centered (mesh_of) and posed here:
|
||||
## assets/weapons/, on the scarecrow's model (which faces -Z): the main weapon in use in the
|
||||
## right hand, the off-hand one in the left. The Blender exports sit far from the origin, so each
|
||||
## mesh is re-centered (mesh_of) and posed here:
|
||||
## pitchfork held low like a spear at the right side, tines forward; a stab thrusts it out
|
||||
## corn shooter at the gun's spot, its corn-cob muzzle at the gameplay muzzle point; each shot
|
||||
## kicks it back
|
||||
## pumpkin bomb in the right hand; after a throw the next one grows back in the hand over the
|
||||
## recharge (set_bomb_charge)
|
||||
## pumpkin bomb in the left hand (the off-hand); after a throw the next one grows back in the
|
||||
## hand over the recharge (set_bomb_charge)
|
||||
## attack() plays the weapon's motion (the pumpkin just leaves the hand: the thrown one is
|
||||
## PumpkinBombs').
|
||||
|
||||
|
|
@ -26,6 +27,7 @@ const KICK := 0.09
|
|||
static var _meshes := {}
|
||||
|
||||
var weapon: int = 0
|
||||
var offhand: int = -1
|
||||
var _pivots: Array[Node3D] = []
|
||||
var _rest: Array[Transform3D] = []
|
||||
var _attack_t := -1.0
|
||||
|
|
@ -42,8 +44,8 @@ static func mesh_of(index: int) -> Mesh:
|
|||
return _meshes[index]
|
||||
|
||||
|
||||
## Builds the three under model. muzzle: the gameplay muzzle point on the model (the corn
|
||||
## shooter's tip goes there).
|
||||
## Builds the three under model, the pitchfork in hand and the off-hand empty. muzzle: the
|
||||
## gameplay muzzle point on the model (the corn shooter's tip goes there).
|
||||
func setup(model: Node3D, muzzle: Vector3) -> void:
|
||||
name = "Weapons"
|
||||
model.add_child(self)
|
||||
|
|
@ -52,9 +54,10 @@ func setup(model: Node3D, muzzle: Vector3) -> void:
|
|||
# Corn shooter: its tip (the mesh's +Z end, 0.59 m out) turned forward onto the muzzle point.
|
||||
var tip := 0.589 * SCALES[1]
|
||||
_add(1, Transform3D(Basis.from_euler(Vector3(0.0, PI, 0.0)), muzzle + Vector3(0.0, 0.0, tip)))
|
||||
# Pumpkin: in the right hand, in front.
|
||||
_add(2, Transform3D(Basis.IDENTITY, Vector3(0.42, 1.2, -0.5)))
|
||||
# Pumpkin: in the left hand, in front.
|
||||
_add(2, Transform3D(Basis.IDENTITY, Vector3(-0.42, 1.2, -0.5)))
|
||||
show_weapon(0)
|
||||
show_offhand(-1)
|
||||
|
||||
|
||||
func _add(index: int, rest: Transform3D) -> void:
|
||||
|
|
@ -70,19 +73,25 @@ func _add(index: int, rest: Transform3D) -> void:
|
|||
_rest.append(rest)
|
||||
|
||||
|
||||
## Shows only this weapon (ScarecrowCombat.Weapon).
|
||||
## Shows this main weapon (ScarecrowCombat.Weapon) in the right hand, and no other.
|
||||
func show_weapon(index: int) -> void:
|
||||
weapon = index
|
||||
_attack_t = -1.0
|
||||
for i in _pivots.size():
|
||||
for i in ScarecrowCombat.MAIN_WEAPONS:
|
||||
_pivots[i].visible = i == index
|
||||
_pivots[i].transform = _rest[i]
|
||||
_apply_charge()
|
||||
|
||||
|
||||
## The weapon's attack motion: a stab or a kick.
|
||||
## Shows this off-hand weapon in the left hand (-1: none).
|
||||
func show_offhand(index: int) -> void:
|
||||
offhand = index
|
||||
for i in ScarecrowCombat.OFFHAND_WEAPONS:
|
||||
_pivots[i].visible = i == index
|
||||
|
||||
|
||||
## The main weapon's attack motion: a stab or a kick.
|
||||
func attack(index: int) -> void:
|
||||
if index == weapon and index < 2:
|
||||
if index == weapon:
|
||||
_attack_t = 0.0
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue