diff --git a/Scripts/Classes/Entities/Player.gd b/Scripts/Classes/Entities/Player.gd index 89ffccb..a2a1bdd 100644 --- a/Scripts/Classes/Entities/Player.gd +++ b/Scripts/Classes/Entities/Player.gd @@ -280,9 +280,16 @@ func editor_level_start() -> void: func _physics_process(delta: float) -> void: if Input.is_action_just_pressed("debug_reload"): set_power_state_frame() - if Input.is_action_just_pressed("debug_noclip") and Global.debug_mode: - state_machine.transition_to("NoClip") - Global.log_comment("NOCLIP Enabled") + + # guzlad: noclip without dev only works while playtesting. + if (Input.is_action_just_pressed("debug_noclip") or Input.is_action_just_pressed("jump_0")) and ((Global.debug_mode) or (Global.level_editor_is_playtesting())): + if state_machine.is_state("NoClip"): + state_machine.transition_to("Normal") + Global.log_comment("NOCLIP Disabled") + elif !Input.is_action_just_pressed("jump_0") and !state_machine.is_state("NoClip"): + state_machine.transition_to("NoClip") + Global.log_comment("NOCLIP Enabled") + up_direction = -gravity_vector handle_directions() handle_block_collision_detection() diff --git a/Scripts/Classes/Singletons/Global.gd b/Scripts/Classes/Singletons/Global.gd index 4f9fbb5..43195a2 100644 --- a/Scripts/Classes/Singletons/Global.gd +++ b/Scripts/Classes/Singletons/Global.gd @@ -454,6 +454,12 @@ func log_comment(msg := "") -> void: await get_tree().create_timer(2, false).timeout error_message.queue_free() +func level_editor_is_playtesting() -> bool: + if Global.current_game_mode == Global.GameMode.LEVEL_EDITOR: + if Global.level_editor.current_state == LevelEditor.EditorState.PLAYTESTING: + return true + return false + func unlock_achievement(achievement_id := AchievementID.SMB1_CLEAR) -> void: achievements[achievement_id] = "1" if achievement_id != AchievementID.COMPLETIONIST: diff --git a/Scripts/Classes/States/Player/NoClip.gd b/Scripts/Classes/States/Player/NoClip.gd index 38f1ae1..03c913e 100755 --- a/Scripts/Classes/States/Player/NoClip.gd +++ b/Scripts/Classes/States/Player/NoClip.gd @@ -13,9 +13,6 @@ func enter(_msg := {}) -> void: func physics_update(_delta: float) -> void: player.velocity = Input.get_vector("move_left_0", "move_right_0", "move_up_0", "move_down_0") * (FAST_SPEED if Input.is_action_pressed("run_0") else SLOW_SPEED) player.move_and_slide() - if Input.is_action_just_pressed("jump_0"): - state_machine.transition_to("Normal") - Global.log_comment("NOCLIP Disabled") func exit() -> void: player.can_hurt = false diff --git a/Scripts/Classes/States/StateMachine.gd b/Scripts/Classes/States/StateMachine.gd index 8c21936..56e857a 100755 --- a/Scripts/Classes/States/StateMachine.gd +++ b/Scripts/Classes/States/StateMachine.gd @@ -15,3 +15,11 @@ func _physics_process(delta: float) -> void: func _process(delta: float) -> void: state.update(delta) + +func get_state() -> String: + if (state != null): + return state.name + return "" + +func is_state(state_to_check := "") -> bool: + return get_state() == state_to_check