console is now independent
This commit is contained in:
@@ -19,6 +19,7 @@ config/icon="res://assets/textures/debug/dummy-player-normal.png"
|
||||
|
||||
Essential="res://src/essential.cs"
|
||||
PlayerVariables="*res://src/player_variables.cs"
|
||||
Console="*res://scenes/gui/console.tscn"
|
||||
|
||||
[display]
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://bxaheg7l4h1ip"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://bxaheg7l4h1ip"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"]
|
||||
[ext_resource type="Texture2D" uid="uid://olceowuycu8c" path="res://assets/textures/debug/dummy-player-atlas.png" id="2_yu1q5"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkm7365u1mm3o" path="res://scenes/gui/dialog_bubble.tscn" id="3_8f573"]
|
||||
[ext_resource type="PackedScene" uid="uid://dlkpivjpbxnlg" path="res://scenes/gui/console.tscn" id="4_kw3hh"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tokqm"]
|
||||
atlas = ExtResource("2_yu1q5")
|
||||
@@ -131,7 +130,6 @@ zoom = Vector2(0.8, 0.8)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="audio_listener_2d" type="AudioListener2D" parent="."]
|
||||
current = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="dialog_bubble" parent="." instance=ExtResource("3_8f573")]
|
||||
@@ -142,7 +140,4 @@ position = Vector2(0, 38)
|
||||
rotation = 1.57345
|
||||
shape = SubResource("CapsuleShape2D_38v5o")
|
||||
|
||||
[node name="console" parent="." instance=ExtResource("4_kw3hh")]
|
||||
visible = false
|
||||
|
||||
[connection signal="animation_changed" from="animated_sprite_2d" to="." method="OnAnimationChanged"]
|
||||
|
@@ -11,6 +11,7 @@ public partial class console : PopupPanel
|
||||
//functions with capital letters can't be used inside the console
|
||||
public override void _Ready()
|
||||
{
|
||||
Visible = false;
|
||||
textblock = GetNode<RichTextLabel>("v_box_container/rich_text_label");
|
||||
line = GetNode<LineEdit>("v_box_container/line_edit");
|
||||
commandDict = Json.ParseString(FileAccess.GetFileAsString("res://src/scene-scripts/console/commands.json").ToString()).AsGodotDictionary();
|
||||
@@ -19,12 +20,13 @@ public partial class console : PopupPanel
|
||||
{
|
||||
if (Input.IsActionJustPressed("console"))
|
||||
{
|
||||
|
||||
Visible = !Visible;
|
||||
line.GrabFocus();
|
||||
GetParent<player>().allowMovement = !Visible;
|
||||
player.allowMovement = !Visible;
|
||||
}
|
||||
}
|
||||
private void OnPopupHide() => GetParent<player>().allowMovement = true;
|
||||
private void OnPopupHide() => player.allowMovement = true;
|
||||
private void OnLineEditTextSubmitted(string command)
|
||||
{
|
||||
line.Clear();
|
||||
@@ -74,38 +76,27 @@ public partial class console : PopupPanel
|
||||
private void consoleclear() => textblock.Clear();
|
||||
private void speed(float multiplier)
|
||||
{
|
||||
GetParent<player>().speed = Mathf.Clamp(multiplier, 0.01f, 15f);
|
||||
textblock.AddText("Set speed to " + Mathf.Clamp(multiplier, 0.01f, 15f) + "\n");
|
||||
player.speed = Mathf.Clamp(multiplier, 0.01f, 15f);
|
||||
textblock.AddText("Set player speed to " + Mathf.Clamp(multiplier, 0.01f, 15f) + "\n");
|
||||
}
|
||||
private void noclip()
|
||||
{
|
||||
CollisionShape2D collision = GetParent<player>().GetNode<CollisionShape2D>("collision_shape");
|
||||
collision.Disabled = !collision.Disabled;
|
||||
textblock.AddText("Noclip is now set to: " + collision.Disabled + "\n");
|
||||
try { textblock.AddText(player.CollisionToggle()); } catch { textblock.AddText("Player is not accessable\n"); }
|
||||
}
|
||||
private void stickycamera()
|
||||
{
|
||||
Camera2D cheatCam = GetParent<player>().GetNode<Camera2D>("cheat_cam");
|
||||
Camera2D mainCam = GetParent<player>().GetNode<Camera2D>("main_cam");
|
||||
if (mainCam.Enabled)
|
||||
{
|
||||
cheatCam.Enabled = true;
|
||||
mainCam.Enabled = false;
|
||||
textblock.AddText("cheat_cam has been enabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
cheatCam.Enabled = false;
|
||||
mainCam.Enabled = true;
|
||||
textblock.AddText("cheat_cam has been disabled\n");
|
||||
}
|
||||
try { textblock.AddText(player.CheatCam()); } catch { textblock.AddText("Player is not accessable\n"); }
|
||||
}
|
||||
private void playername(string name)
|
||||
{
|
||||
player_variables.PlayerName = name;
|
||||
textblock.AddText("Your new name is now: " + player_variables.PlayerName + "\n");
|
||||
}
|
||||
private void reload() => GetTree().ReloadCurrentScene();
|
||||
private void reload()
|
||||
{
|
||||
GetTree().ReloadCurrentScene();
|
||||
textblock.AddText("Level got reloaded!\n");
|
||||
}
|
||||
private void visiblecollision()
|
||||
{
|
||||
GetTree().DebugCollisionsHint = !GetTree().DebugCollisionsHint;
|
||||
|
@@ -33,7 +33,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
|
||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
|
||||
GetNode<Label>("box/name_label").Text = title;
|
||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
|
||||
if (GetParent().Name == "player") player.allowMovement = false;
|
||||
|
||||
//Get first key
|
||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
||||
@@ -158,6 +158,6 @@ public partial class dialog_bubble : CanvasLayer
|
||||
richText.VisibleCharacters = -1;
|
||||
GetNode<Label>("box/name_label").Text = "???";
|
||||
richText.Text = "";
|
||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = true;
|
||||
if (GetParent().Name == "player") player.allowMovement = true;
|
||||
}
|
||||
}
|
@@ -4,18 +4,25 @@ using System.Text.RegularExpressions;
|
||||
|
||||
public partial class player : CharacterBody2D
|
||||
{
|
||||
[Export] public float speed = 1;
|
||||
public bool allowMovement = true;
|
||||
[Export] public static float speed = 1;
|
||||
public static bool allowMovement = true;
|
||||
public Vector2 movement;
|
||||
public AnimatedSprite2D animatedSprite;
|
||||
public Marker2D rotCenter;
|
||||
public RayCast2D dialogRayCast;
|
||||
//console cheats:
|
||||
private static Camera2D cheatCam;
|
||||
private static Camera2D mainCam;
|
||||
private static CollisionShape2D collision;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
animatedSprite = GetNode<AnimatedSprite2D>("animated_sprite_2d");
|
||||
rotCenter = GetNode<Marker2D>("rotation_center");
|
||||
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");
|
||||
cheatCam = GetNode<Camera2D>("cheat_cam");
|
||||
mainCam = GetNode<Camera2D>("main_cam");
|
||||
collision = GetNode<CollisionShape2D>("collision_shape");
|
||||
}
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
@@ -67,4 +74,27 @@ public partial class player : CharacterBody2D
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//CONSOLE CHEATS
|
||||
public static string CheatCam()
|
||||
{
|
||||
|
||||
if (mainCam.Enabled)
|
||||
{
|
||||
cheatCam.Enabled = true;
|
||||
mainCam.Enabled = false;
|
||||
return "cheat_cam has been enabled\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cheatCam.Enabled = false;
|
||||
mainCam.Enabled = true;
|
||||
return "cheat_cam has been disabled\n";
|
||||
}
|
||||
}
|
||||
public static string CollisionToggle()
|
||||
{
|
||||
collision.Disabled = !collision.Disabled;
|
||||
return ("Noclip is now set to: " + collision.Disabled + "\n");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user