Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e0e73b

Browse files
authored
Merge pull request Interkarma#2277 from extract/master
Add toggle noclip console command
2 parents 887366d + c5abbe1 commit 6e0e73b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Assets/Game/Addons/UnityConsole/Console/Scripts/DefaultCommands.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void Start()
3636
ConsoleCommandsDatabase.RegisterCommand(HelpCommand.name, HelpCommand.description, HelpCommand.usage, HelpCommand.Execute);
3737
ConsoleCommandsDatabase.RegisterCommand(LoadCommand.name, LoadCommand.description, LoadCommand.usage, LoadCommand.Execute);
3838
ConsoleCommandsDatabase.RegisterCommand(GodCommand.name, GodCommand.description, GodCommand.usage, GodCommand.Execute);
39+
ConsoleCommandsDatabase.RegisterCommand(NoClipCommand.name, NoClipCommand.description, NoClipCommand.usage, NoClipCommand.Execute);
3940
ConsoleCommandsDatabase.RegisterCommand(NoTargetCommand.name, NoTargetCommand.description, NoTargetCommand.usage, NoTargetCommand.Execute);
4041
ConsoleCommandsDatabase.RegisterCommand(ToggleAICommand.name, ToggleAICommand.description, ToggleAICommand.usage, ToggleAICommand.Execute);
4142
ConsoleCommandsDatabase.RegisterCommand(CreateMobileCommand.name, CreateMobileCommand.description, CreateMobileCommand.usage, CreateMobileCommand.Execute);
@@ -385,6 +386,31 @@ public static string Execute(params string[] args)
385386
}
386387
}
387388

389+
private static class NoClipCommand
390+
{
391+
public static readonly string name = "tcl";
392+
public static readonly string error = "Failed to set TCL, PlayerEntity or Levitate could not be found";
393+
public static readonly string usage = "tcl";
394+
public static readonly string description = "Toggle noclip by turning off all collisions and activates levitate";
395+
396+
public static string Execute(params string[] args)
397+
{
398+
PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
399+
LevitateMotor levitateMotor = GameManager.Instance.PlayerMotor.GetComponent<LevitateMotor>();
400+
401+
if (playerEntity && levitateMotor)
402+
{
403+
playerEntity.NoClipMode = !playerEntity.NoClipMode;
404+
levitateMotor.IsLevitating = playerEntity.NoClipMode;
405+
GameManager.Instance.PlayerController.gameObject.layer = playerEntity.NoClipMode ? LayerMask.NameToLayer("NoclipLayer") : LayerMask.NameToLayer("Player");
406+
407+
return string.Format("Noclip enabled: {0}", playerEntity.NoClipMode);
408+
}
409+
else
410+
return error;
411+
}
412+
}
413+
388414
private static class NoTargetCommand
389415
{
390416
public static readonly string name = "nt";

Assets/Scripts/Game/Entities/PlayerEntity.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class PlayerEntity : DaggerfallEntity
4242
public const string lycanthropySpellTag = "lycanthrope";
4343

4444
bool godMode = false;
45+
bool noClipMode = false;
4546
bool noTargetMode = false;
4647
bool preventEnemySpawns = false;
4748
bool preventNormalizingReputations = false;
@@ -139,6 +140,7 @@ public class PlayerEntity : DaggerfallEntity
139140
#region Properties
140141

141142
public bool GodMode { get { return godMode; } set { godMode = value; } }
143+
public bool NoClipMode { get { return noClipMode; } set { noClipMode = value; } }
142144
public bool NoTargetMode { get { return noTargetMode; } set { noTargetMode = value; } }
143145
public bool PreventEnemySpawns { get { return preventEnemySpawns; } set { preventEnemySpawns = value; } }
144146
public bool PreventNormalizingReputations { get { return preventNormalizingReputations; } set { preventNormalizingReputations = value; } }

0 commit comments

Comments
 (0)