console is now independent
This commit is contained in:
@@ -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