-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce experimental
fall
command
- makes a player fall through the ground
- Loading branch information
1 parent
72a4a47
commit 4d7200c
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
using GameNetcodeStuff; | ||
using Hax; | ||
using UnityEngine; | ||
|
||
[Command("fall")] | ||
class FallCommand : ICommand { | ||
public void Execute(StringArray args) { | ||
if (Helper.LocalPlayer is not PlayerControllerB localPlayer) return; | ||
if (args.Length is 0) { | ||
Chat.Print("Usage: /fall <player>"); | ||
return; | ||
} | ||
|
||
if (Helper.Enemies.First() is not EnemyAI enemy) { | ||
Chat.Print("An enemy must have spawned to use this command!"); | ||
return; | ||
} | ||
|
||
if (Helper.GetPlayer(args[0]) is not PlayerControllerB targetPlayer) { | ||
Chat.Print("Target player is not found!"); | ||
return; | ||
} | ||
|
||
enemy.ChangeEnemyOwnerServerRpc(localPlayer.actualClientId); | ||
enemy.serverPosition = enemy.serverPosition == Vector3.positiveInfinity | ||
? targetPlayer.transform.position | ||
: Vector3.positiveInfinity; | ||
|
||
Helper.ShortDelay(() => | ||
enemy.ChangeEnemyOwnerServerRpc(targetPlayer.actualClientId) | ||
); | ||
} | ||
} |