multiplayer pretty much works now i think

This commit is contained in:
2023-11-17 20:49:38 +11:00
parent 2d123bd731
commit 9cf6944ac8
87 changed files with 1476 additions and 1223 deletions

View File

@ -24,6 +24,7 @@ func networked_spawn_projectile(peer_id, direction):
projectile.damage = damage
projectile.direction = direction
projectile.force = force
projectile.owner_id = peer_id
projectile.name = str(peer_id) + str(projectile_id)
get_tree().root.add_child(projectile)
projectile_id += 1

View File

@ -0,0 +1,55 @@
extends Weapon
class_name ShapecastWeapon
@export var shapecast : ShapeCast3D
@export var range_debug_indicator : CSGSphere3D
@export var status_stats : StatusStats
@export var particles : GPUParticles3D
var attack_range := 0.0
func _ready() -> void:
super._ready()
attack_range = stats.get_attribute("Range")
range_debug_indicator.radius = attack_range
shapecast.shape.size.z = attack_range
shapecast.target_position = -hero.camera.basis.z * (attack_range / 2.0)
func _process(delta: float) -> void:
super._process(delta)
particles.emitting = trigger_held
func shoot():
super.shoot()
for index in shapecast.get_collision_count():
var target = shapecast.get_collider(index)
if target:
var target_hitbox = target.shape_owner_get_owner(shapecast.get_collider_shape(index))
if target_hitbox is Hitbox:
hit(target, target_hitbox)
if Data.preferences.display_self_damage_indicators:
spawn_damage_indicator(target.sprite.global_position)
networked_hit.rpc(get_tree().root.get_path_to(target), get_tree().root.get_path_to(target_hitbox))
func build_status_object() -> StatusEffect:
var status = StatusEffect.new()
status.stats = status_stats
return status
func hit(target, target_hitbox : Hitbox):
target_hitbox.damage(damage)
target.status_manager.add_effect(build_status_object())
@rpc("reliable")
func networked_hit(target_path : String, target_hitbox_path : String):
var target = get_tree().root.get_node(target_path)
var target_hitbox = get_tree().root.get_node(target_hitbox_path) as Hitbox
hit(target, target_hitbox)
if Data.preferences.display_party_damage_indicators:
spawn_damage_indicator(target.sprite.global_position)