Moar Gamecraft commands!
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

55 рядки
1.7KB

  1. using System.Collections.Generic;
  2. using Svelto.ECS;
  3. //using Svelto.Context;
  4. using GamecraftModdingAPI.Commands;
  5. using GamecraftModdingAPI;
  6. using GamecraftModdingAPI.Players;
  7. namespace ExtraCommands.Waypoints
  8. {
  9. [CustomCommand("Waypoints")]
  10. class TeleportWaypointCommandEngine : ICustomCommandEngine
  11. {
  12. private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>();
  13. public string Description => "";
  14. public string Name => "Waypoints";
  15. public EntitiesDB entitiesDB { set; private get; }
  16. public bool isRemovable => true;
  17. public void Ready()
  18. {
  19. CommandRegistrationHelper.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
  20. CommandRegistrationHelper.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
  21. }
  22. private void CreateWaypointCommand(object name)
  23. {
  24. Player reference = new Player(PlayerType.Local);
  25. _waypoints[name] = new float[3] { reference.Position.x, reference.Position.y, reference.Position.z };
  26. uREPL.Log.Output("Saved " + name.ToString());
  27. }
  28. private void TeleportToWaypointCommand(object name)
  29. {
  30. if (!_waypoints.ContainsKey(name))
  31. {
  32. uREPL.Log.Error("Waypoint not found");
  33. return;
  34. }
  35. float[] loc = _waypoints[name];
  36. uREPL.RuntimeCommands.Call<float, float, float>("TeleportPlayerAbsolute", loc[0], loc[1], loc[2]);
  37. }
  38. public void Dispose()
  39. {
  40. CommandRegistrationHelper.Unregister("CreateWaypoint");
  41. CommandRegistrationHelper.Unregister("TeleportPlayerWaypoint");
  42. }
  43. }
  44. }