|
- using System.Collections.Generic;
- using Svelto.ECS;
- //using Svelto.Context;
-
- using GamecraftModdingAPI.Commands;
- using GamecraftModdingAPI;
- using GamecraftModdingAPI.Players;
-
- namespace ExtraCommands.Waypoints
- {
- [CustomCommand("Waypoints")]
- class TeleportWaypointCommandEngine : ICustomCommandEngine
- {
- private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>();
-
- public string Description => "";
-
- public string Name => "Waypoints";
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public bool isRemovable => true;
-
- public void Ready()
- {
- CommandRegistrationHelper.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location");
- CommandRegistrationHelper.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint");
- }
-
- private void CreateWaypointCommand(object name)
- {
- Player reference = new Player(PlayerType.Local);
- _waypoints[name] = new float[3] { reference.Position.x, reference.Position.y, reference.Position.z };
- uREPL.Log.Output("Saved " + name.ToString());
- }
-
- private void TeleportToWaypointCommand(object name)
- {
- if (!_waypoints.ContainsKey(name))
- {
- uREPL.Log.Error("Waypoint not found");
- return;
- }
- float[] loc = _waypoints[name];
- uREPL.RuntimeCommands.Call<float, float, float>("TeleportPlayerAbsolute", loc[0], loc[1], loc[2]);
- }
-
- public void Dispose()
- {
- CommandRegistrationHelper.Unregister("CreateWaypoint");
- CommandRegistrationHelper.Unregister("TeleportPlayerWaypoint");
- }
- }
- }
|