change dictionaries to inner classes in main_camera and cursor
This commit is contained in:
@@ -30,33 +30,33 @@ func _process(delta: float) -> void:
|
||||
func _follow(player: Player, delta: float) -> Vector3:
|
||||
var id := player.get_instance_id()
|
||||
if not _player_offsets.has(id):
|
||||
_player_offsets[id] = {"floor_height": 0, "aim_offset": Vector3.ZERO}
|
||||
_player_offsets[id] = PlayerOffset.new()
|
||||
|
||||
var player_offset: Dictionary = _player_offsets[id]
|
||||
var player_offset: PlayerOffset = _player_offsets[id]
|
||||
|
||||
var player_position := player.global_position
|
||||
if player.is_on_floor():
|
||||
player_offset["floor_height"] = player_position.y
|
||||
player_position.y = player_offset["floor_height"] + Projectile.HEIGHT
|
||||
player_offset.floor_height = player_position.y
|
||||
player_position.y = player_offset.floor_height + Projectile.HEIGHT
|
||||
|
||||
if Referencer.players_count > 1:
|
||||
player_offset["aim_offset"] = Vector3.ZERO
|
||||
player_offset.aim_offset = Vector3.ZERO
|
||||
elif player.input_mode_is(Inputer.Mode.KB_MOUSE):
|
||||
player_offset["aim_offset"] = player.aiming.aim_offset
|
||||
player_offset.aim_offset = player.aiming.aim_offset
|
||||
elif player.input_mode_is(Inputer.Mode.CONTROLLER):
|
||||
var new_aim_offset := (
|
||||
Vector3.ZERO
|
||||
if player.aiming.aim_input.length() == 0
|
||||
else player.aiming.aim_offset
|
||||
)
|
||||
player_offset["aim_offset"] = player_offset["aim_offset"].lerp(
|
||||
player_offset.aim_offset = player_offset.aim_offset.lerp(
|
||||
new_aim_offset, _aim_damping * delta
|
||||
)
|
||||
|
||||
var follow_position := (
|
||||
player_position
|
||||
+ (
|
||||
player_offset["aim_offset"] as Vector3
|
||||
player_offset.aim_offset as Vector3
|
||||
* (
|
||||
_aim_offset_factor_mouse
|
||||
if player.input_mode_is(Inputer.Mode.KB_MOUSE)
|
||||
@@ -68,3 +68,8 @@ func _follow(player: Player, delta: float) -> Vector3:
|
||||
Debugger.circle("follow_position" + str(player.name), follow_position)
|
||||
|
||||
return follow_position
|
||||
|
||||
|
||||
class PlayerOffset:
|
||||
var floor_height: float = 0
|
||||
var aim_offset: Vector3 = Vector3.ZERO
|
||||
|
||||
Reference in New Issue
Block a user