Very bad implementation of shop and grenade
This commit is contained in:
parent
e9f4c6e5f8
commit
3868af29e3
13 changed files with 166 additions and 3 deletions
|
|
@ -91,11 +91,11 @@ func sync_session_server(id: int):
|
|||
data.encode_u8(4,defenders_alive)
|
||||
data.encode_u8(5,round_state)
|
||||
|
||||
sync_session_client.rpc_id(id,data)
|
||||
sync_session_client.rpc_id(id,data,player_data)
|
||||
late_player_connected.emit(id)
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func sync_session_client(data: PackedByteArray):
|
||||
func sync_session_client(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
|
||||
if not is_server_request():
|
||||
return
|
||||
|
||||
|
|
@ -106,7 +106,36 @@ func sync_session_client(data: PackedByteArray):
|
|||
defenders_alive = data.decode_u8(4)
|
||||
round_state = data.decode_u8(5) as ROUND_STATES
|
||||
session_started.emit()
|
||||
player_data = players_data_sent
|
||||
|
||||
func send_session_data():
|
||||
if multiplayer.is_server() == false or session_started_flag == false:
|
||||
return
|
||||
|
||||
var data: PackedByteArray
|
||||
data.resize(6)
|
||||
data.encode_u8(0,current_round)
|
||||
data.encode_u8(1,attacker_score)
|
||||
data.encode_u8(2,defender_score)
|
||||
data.encode_u8(3,attackers_alive)
|
||||
data.encode_u8(4,defenders_alive)
|
||||
data.encode_u8(5,round_state)
|
||||
|
||||
recieve_session_data.rpc(data,player_data)
|
||||
|
||||
@rpc("authority","call_remote","unreliable")
|
||||
func recieve_session_data(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
|
||||
if not is_server_request():
|
||||
return
|
||||
|
||||
current_round = data.decode_u8(0)
|
||||
attacker_score = data.decode_u8(1)
|
||||
defender_score = data.decode_u8(2)
|
||||
attackers_alive = data.decode_u8(3)
|
||||
defenders_alive = data.decode_u8(4)
|
||||
round_state = data.decode_u8(5) as ROUND_STATES
|
||||
session_started.emit()
|
||||
player_data = players_data_sent
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if multiplayer.is_server() == false or not session_started:
|
||||
|
|
@ -121,6 +150,7 @@ func _process(_delta: float) -> void:
|
|||
_:
|
||||
reference_round_time = 0
|
||||
update_clock.rpc(reference_round_time)
|
||||
send_session_data()
|
||||
|
||||
@rpc("authority","call_remote","unreliable")
|
||||
func update_clock(time: float):
|
||||
|
|
|
|||
11
scripts/weapon_system/molikman/molik/idle_state.gd
Normal file
11
scripts/weapon_system/molikman/molik/idle_state.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extends WeaponState
|
||||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix +"idle")
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func use_begin() -> void:
|
||||
if machine.ammo > 0:
|
||||
transition.emit("Throw")
|
||||
1
scripts/weapon_system/molikman/molik/idle_state.gd.uid
Normal file
1
scripts/weapon_system/molikman/molik/idle_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cnre3f01a2n88
|
||||
14
scripts/weapon_system/molikman/molik/intro_state.gd
Normal file
14
scripts/weapon_system/molikman/molik/intro_state.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var emptyable: bool
|
||||
|
||||
func enter() -> void:
|
||||
machine.animation_player.play(machine.animation_prefix + "intro")
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == machine.animation_prefix + "intro":
|
||||
transition.emit("Idle")
|
||||
1
scripts/weapon_system/molikman/molik/intro_state.gd.uid
Normal file
1
scripts/weapon_system/molikman/molik/intro_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://js2rkse5mka0
|
||||
12
scripts/weapon_system/molikman/molik/molik.gd
Normal file
12
scripts/weapon_system/molikman/molik/molik.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extends RigidBody3D
|
||||
|
||||
|
||||
var contacts: int = 0
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
contacts += 1
|
||||
if contacts > 2:
|
||||
var grenade = load("res://scenes/projectiles/molikman/molikman_molotov_fire.tscn").instantiate()
|
||||
Session.dynamic_objects_spawner.get_parent().add_child(grenade)
|
||||
grenade.global_position = global_position
|
||||
queue_free()
|
||||
1
scripts/weapon_system/molikman/molik/molik.gd.uid
Normal file
1
scripts/weapon_system/molikman/molik/molik.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://y1s64ppporww
|
||||
28
scripts/weapon_system/molikman/molik/throw.gd
Normal file
28
scripts/weapon_system/molikman/molik/throw.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends WeaponState
|
||||
|
||||
const molik: PackedScene = preload("res://scenes/weapons/molik.tscn")
|
||||
|
||||
func enter() -> void:
|
||||
fire()
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func exit() -> void:
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == machine.animation_prefix + "throw":
|
||||
transition.emit("Idle")
|
||||
|
||||
func fire() -> void:
|
||||
if machine.ammo == 0:
|
||||
return
|
||||
machine.ammo -= 1
|
||||
|
||||
machine.animation_player.stop()
|
||||
machine.animation_player.play(machine.animation_prefix + "shoot")
|
||||
|
||||
if is_multiplayer_authority():
|
||||
var molotov: RigidBody3D = molik.instantiate()
|
||||
Session.dynamic_objects_spawner.get_parent().add_child(molotov)
|
||||
molotov.global_transform = machine.player_camera.global_transform
|
||||
molotov.apply_impulse(-molotov.global_basis.z * 10)
|
||||
1
scripts/weapon_system/molikman/molik/throw.gd.uid
Normal file
1
scripts/weapon_system/molikman/molik/throw.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b6eio68csxw7v
|
||||
Loading…
Add table
Add a link
Reference in a new issue