A whole lotta bodges for multiplayer. Gonna need to rethink some things.
This commit is contained in:
parent
0248be637d
commit
9283a3263f
|
|
@ -37,9 +37,10 @@ func _ready() -> void:
|
||||||
puppet_anim_sprite_name = animated_sprite.animation
|
puppet_anim_sprite_name = animated_sprite.animation
|
||||||
puppet_anim_sprite_frame = animated_sprite.frame
|
puppet_anim_sprite_frame = animated_sprite.frame
|
||||||
puppet_transform = transform
|
puppet_transform = transform
|
||||||
# if not is_network_master():
|
## Disable Process and Physics on puppets
|
||||||
# animated_sprite.set_process(false)
|
if not is_network_master():
|
||||||
# animated_sprite.set_physics_process(false)
|
animated_sprite.set_process(false)
|
||||||
|
animated_sprite.set_physics_process(false)
|
||||||
#movement_state_machine.init_animated_actor(self)
|
#movement_state_machine.init_animated_actor(self)
|
||||||
#movement_component.attack_function = funcref(self, "attack")
|
#movement_component.attack_function = funcref(self, "attack")
|
||||||
# movement_component.player_number = player_number
|
# movement_component.player_number = player_number
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,17 @@ func _ready():
|
||||||
PlayerInfo.player_inventory = player_inventory
|
PlayerInfo.player_inventory = player_inventory
|
||||||
# PlayerInfo.player_stamina = stamina_component.stamina
|
# PlayerInfo.player_stamina = stamina_component.stamina
|
||||||
|
|
||||||
player_info_index = PlayerInfo.register_player()
|
# I think we only want to do this for network master players now
|
||||||
print ("Registered as player: ", player_info_index)
|
if is_network_master():
|
||||||
player_data = PlayerInfo.get_player_data(player_info_index)
|
player_info_index = PlayerInfo.register_player()
|
||||||
PlayerInfo.get_player_data(player_info_index).player_health = health_component.health
|
print ("Registered as player: ", player_info_index)
|
||||||
print ("My health is: ", player_data.player_health)
|
player_data = PlayerInfo.get_player_data(player_info_index)
|
||||||
player_data.player_inventory = player_inventory
|
PlayerInfo.get_player_data(player_info_index).player_health = health_component.health
|
||||||
player_data.player_stamina = stamina_component.stamina
|
print ("My health is: ", player_data.player_health)
|
||||||
|
player_data.player_inventory = player_inventory
|
||||||
|
player_data.player_stamina = stamina_component.stamina
|
||||||
|
else:
|
||||||
|
$Hurtbox_Component.hurtbox_entered_function = ''
|
||||||
|
|
||||||
# Set initial player position in world.
|
# Set initial player position in world.
|
||||||
global_position = LevelInfo.player_start_position
|
global_position = LevelInfo.player_start_position
|
||||||
|
|
@ -51,40 +55,38 @@ func _ready():
|
||||||
|
|
||||||
movement_component.state_stamina_cost = state_stamina_cost
|
movement_component.state_stamina_cost = state_stamina_cost
|
||||||
|
|
||||||
puppet_pos = position
|
|
||||||
|
|
||||||
|
|
||||||
#var stamina_recovery :float = 0.0
|
#var stamina_recovery :float = 0.0
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
#PlayerInfo.player_position = global_position.round()
|
if is_network_master():
|
||||||
player_data.player_position = global_position.round()
|
#PlayerInfo.player_position = global_position.round()
|
||||||
# stamina_recovery += delta
|
player_data.player_position = global_position.round()
|
||||||
# if stamina_recovery > 1.0:
|
# stamina_recovery += delta
|
||||||
# stamina_component.recover(1)
|
# if stamina_recovery > 1.0:
|
||||||
# stamina_recovery = 0.0
|
# stamina_component.recover(1)
|
||||||
# #print("recover ", stamina_component.stamina)
|
# stamina_recovery = 0.0
|
||||||
|
# #print("recover ", stamina_component.stamina)
|
||||||
|
|
||||||
#PlayerInfo.player_stamina = stamina_component.stamina
|
#PlayerInfo.player_stamina = stamina_component.stamina
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
|
|
||||||
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
||||||
if state_damage_amount.has(movement_state_machine.current_state.name):
|
if state_damage_amount.has(movement_state_machine.current_state.name):
|
||||||
$Hitbox_Component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
$Hitbox_Component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
||||||
else:
|
else:
|
||||||
$Hitbox_Component.damage_amount = 10
|
$Hitbox_Component.damage_amount = 10
|
||||||
|
|
||||||
match movement_state_machine.current_state.name:
|
match movement_state_machine.current_state.name:
|
||||||
"idle":
|
"idle":
|
||||||
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
||||||
var _selected_item = player_inventory.switch_primary()
|
var _selected_item = player_inventory.switch_primary()
|
||||||
if _selected_item:
|
if _selected_item:
|
||||||
print("Switched Primary item to: ", _selected_item.name)
|
print("Switched Primary item to: ", _selected_item.name)
|
||||||
elif Input.is_action_just_released("switch_secondary_item_" + str(player_number)):
|
elif Input.is_action_just_released("switch_secondary_item_" + str(player_number)):
|
||||||
var _selected_item = player_inventory.switch_secondary()
|
var _selected_item = player_inventory.switch_secondary()
|
||||||
if _selected_item:
|
if _selected_item:
|
||||||
print("Switched Secondary item to: ", _selected_item.name)
|
print("Switched Secondary item to: ", _selected_item.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user