-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
199 additions
and
186 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
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 |
---|---|---|
@@ -1,42 +1,38 @@ | ||
using CommandSystem; | ||
using InventorySystem.Items.Pickups; | ||
using InventorySystem; | ||
using MapGeneration; | ||
using Mirror; | ||
using PluginAPI.Core; | ||
using System; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace CustomDoors.Commands | ||
{ | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
public class PositionCommand : ICommand | ||
{ | ||
public string Command { get; } = "Position"; | ||
namespace CustomDoors.Commands; | ||
|
||
public string[] Aliases { get; } = new string[] { }; | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
public sealed class PositionCommand : ICommand | ||
{ | ||
public string Command { get; } = "Position"; | ||
|
||
public string Description { get; } = "Gives you your position."; | ||
public string[] Aliases { get; } = new string[] { }; | ||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
Player player = Player.Get(((CommandSender)sender).SenderId); | ||
RoomIdentifier room = player.Room; | ||
Vector3 position = player.Position; | ||
public string Description { get; } = "Gives you your position."; | ||
|
||
if (arguments.Count > 0 && bool.TryParse(arguments.First(), out bool doRaycast) && doRaycast && Physics.Raycast(player.Camera.position, player.Camera.forward, out RaycastHit hitInfo, 50)) | ||
{ | ||
position = hitInfo.point; | ||
if (RoomIdentifier.RoomsByCoordinates.TryGetValue(new Vector3Int(Mathf.RoundToInt(hitInfo.point.x / RoomIdentifier.GridScale.x), Mathf.RoundToInt(hitInfo.point.y / 100f), Mathf.RoundToInt(hitInfo.point.z / RoomIdentifier.GridScale.z)), out RoomIdentifier value)) | ||
room = value; | ||
} | ||
|
||
response = $"{room.name} :\nRoom position : {room.transform.position}\nRoom rotation : {room.transform.rotation.eulerAngles}\nPosition : {position}\nRelative position to room :\nx = {(position - room.transform.position).x}\ny = {(position - room.transform.position).y}\nz = {(position - room.transform.position).z}"; | ||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
Player player = Player.Get(((CommandSender)sender).SenderId); | ||
RoomIdentifier room = player.Room; | ||
Vector3 position = player.Position; | ||
|
||
if (PluginClass.Singleton.config.InfoPositionCommand) | ||
Log.Info(response); | ||
return true; | ||
if (arguments.Count > 0 && bool.TryParse(arguments.First(), out bool doRaycast) && doRaycast && Physics.Raycast(player.Camera.position, player.Camera.forward, out RaycastHit hitInfo, 50)) | ||
{ | ||
position = hitInfo.point; | ||
if (RoomIdentifier.RoomsByCoordinates.TryGetValue(new Vector3Int(Mathf.RoundToInt(hitInfo.point.x / RoomIdentifier.GridScale.x), Mathf.RoundToInt(hitInfo.point.y / 100f), Mathf.RoundToInt(hitInfo.point.z / RoomIdentifier.GridScale.z)), out RoomIdentifier value)) | ||
room = value; | ||
} | ||
|
||
response = $"{room.name} :\nRoom position : {room.transform.position}\nRoom rotation : {room.transform.rotation.eulerAngles}\nPosition : {position}\nRelative position to room :\nx = {(position - room.transform.position).x}\ny = {(position - room.transform.position).y}\nz = {(position - room.transform.position).z}"; | ||
|
||
if (PluginClass.Singleton.config.InfoPositionCommand) | ||
Log.Info(response); | ||
return true; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,87 +1,86 @@ | ||
using Interactables.Interobjects.DoorUtils; | ||
using System.ComponentModel; | ||
|
||
namespace CustomDoors | ||
namespace CustomDoors; | ||
|
||
public sealed class Config | ||
{ | ||
public class Config | ||
[Description("Inform of position command's response ? (sends a debug message to the server console when using position command) :")] | ||
public bool InfoPositionCommand { get; set; } = false; | ||
|
||
[Description("Inform of attachments command's response ? (sends a debug message to the server console when using attachments command) :")] | ||
public bool InfoAttachmentsCommand { get; set; } = false; | ||
|
||
/*[Description("List of spawnable objects and their caracteristics")] Doesn't work : if you restart your server configs get changed to a useless config file that only contains SpawnableConfig but no DoorConfig nor ItemConfig | ||
public SpawnableConfig[] SpawnableObjects { get; set; } = new SpawnableConfig[5] | ||
{ | ||
[Description("Inform of position command's response ? (sends a debug message to the server console when using position command) :")] | ||
public bool InfoPositionCommand { get; set; } = false; | ||
|
||
[Description("Inform of attachments command's response ? (sends a debug message to the server console when using attachments command) :")] | ||
public bool InfoAttachmentsCommand { get; set; } = false; | ||
|
||
/*[Description("List of spawnable objects and their caracteristics")] Doesn't work : if you restart your server configs get changed to a useless config file that only contains SpawnableConfig but no DoorConfig nor ItemConfig | ||
public SpawnableConfig[] SpawnableObjects { get; set; } = new SpawnableConfig[5] | ||
{ | ||
new DoorConfig() { Type = "HCZ", RoomName = "Outside", RelativePositionX =29, RelativePositionY = -8.35f, RelativePositionZ = -42.8f, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ExitGates }, | ||
new DoorConfig() { Type = "EZ", RoomName = "LCZ_Airlock (1)", DefaultRoomRotationYAxis = 90, RelativePositionX = -3.5f, RelativePositionY = 0.9685f, RelativePositionZ= 0, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ContainmentLevelOne, Opened = true }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1 }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1, RelativeRotationY = 90 }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 2, ScaleY = 1, ScaleZ = 2 }, | ||
};*/ | ||
|
||
[Description("List of doors and their caracteristics")] | ||
public DoorConfig[] Doors { get; set; } = new DoorConfig[2] | ||
{ | ||
new DoorConfig() { Type = "HCZ", RoomName = "Outside", RelativePositionX =29, RelativePositionY = -8.35f, RelativePositionZ = -42.8f, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ExitGates }, | ||
new DoorConfig() { Type = "EZ", RoomName = "LCZ_Airlock (1)", DefaultRoomRotationYAxis = 90, RelativePositionX = -3.5f, RelativePositionY = 0, RelativePositionZ = 0, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ContainmentLevelOne, Opened = false } | ||
}; | ||
|
||
[Description("List of items and their caracteristics")] | ||
public ItemConfig[] Items { get; set; } = new ItemConfig[3] | ||
{ | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1 }, | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1, RelativeRotationY = 90 }, | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 2, ScaleY = 1, ScaleZ = 2 }, | ||
}; | ||
} | ||
|
||
public class SpawnableConfig | ||
new DoorConfig() { Type = "HCZ", RoomName = "Outside", RelativePositionX =29, RelativePositionY = -8.35f, RelativePositionZ = -42.8f, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ExitGates }, | ||
new DoorConfig() { Type = "EZ", RoomName = "LCZ_Airlock (1)", DefaultRoomRotationYAxis = 90, RelativePositionX = -3.5f, RelativePositionY = 0.9685f, RelativePositionZ= 0, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ContainmentLevelOne, Opened = true }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1 }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1, RelativeRotationY = 90 }, | ||
new ItemConfig() { Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 2, ScaleY = 1, ScaleZ = 2 }, | ||
};*/ | ||
|
||
[Description("List of doors and their caracteristics")] | ||
public DoorConfig[] Doors { get; set; } = new DoorConfig[2] | ||
{ | ||
public string RoomName { get; set; } | ||
new DoorConfig() { Type = "HCZ", RoomName = "Outside", RelativePositionX =29, RelativePositionY = -8.35f, RelativePositionZ = -42.8f, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ExitGates }, | ||
new DoorConfig() { Type = "EZ", RoomName = "LCZ_Airlock (1)", DefaultRoomRotationYAxis = 90, RelativePositionX = -3.5f, RelativePositionY = 0, RelativePositionZ = 0, ScaleX = 1, ScaleY =1, ScaleZ = 1, KeycardPermissions = KeycardPermissions.ContainmentLevelOne, Opened = false } | ||
}; | ||
|
||
public float DefaultRoomRotationYAxis { get; set; } | ||
[Description("List of items and their caracteristics")] | ||
public ItemConfig[] Items { get; set; } = new ItemConfig[3] | ||
{ | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1 }, | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 1, ScaleY = 1, ScaleZ = 1, RelativeRotationY = 90 }, | ||
new ItemConfig() { RelativePositionY = 1, Item = ItemType.Medkit, RoomName = "LCZ_ClassDSpawn (1)", ScaleX = 2, ScaleY = 1, ScaleZ = 2 }, | ||
}; | ||
} | ||
|
||
public float RelativePositionX { get; set; } | ||
public float RelativePositionY { get; set; } | ||
public float RelativePositionZ { get; set; } | ||
public abstract class SpawnableConfig | ||
{ | ||
public string RoomName { get; set; } | ||
|
||
public float ScaleX { get; set; } | ||
public float ScaleY { get; set; } | ||
public float ScaleZ { get; set; } | ||
public float DefaultRoomRotationYAxis { get; set; } | ||
|
||
public float RelativeRotationX { get; set; } | ||
public float RelativeRotationY { get; set; } | ||
public float RelativeRotationZ { get; set; } | ||
} | ||
public float RelativePositionX { get; set; } | ||
public float RelativePositionY { get; set; } | ||
public float RelativePositionZ { get; set; } | ||
|
||
public class DoorConfig : SpawnableConfig | ||
{ | ||
public string Type { get; set; } | ||
public float ScaleX { get; set; } | ||
public float ScaleY { get; set; } | ||
public float ScaleZ { get; set; } | ||
|
||
public KeycardPermissions KeycardPermissions { get; set; } | ||
public bool Opened { get; set; } | ||
public bool Locked { get; set; } | ||
} | ||
public float RelativeRotationX { get; set; } | ||
public float RelativeRotationY { get; set; } | ||
public float RelativeRotationZ { get; set; } | ||
} | ||
|
||
public class ItemConfig : SpawnableConfig | ||
{ | ||
public ItemType Item { get; set; } | ||
public ushort Ammo { get; set; } | ||
public uint Attachments { get; set; } | ||
} | ||
public sealed class DoorConfig : SpawnableConfig | ||
{ | ||
public string Type { get; set; } | ||
|
||
/*public class PrimitiveConfig : SpawnableConfig | ||
{ | ||
public PrimitiveType PrimitiveType { get; set; } | ||
public Color Color { get; set; } | ||
} | ||
public KeycardPermissions KeycardPermissions { get; set; } | ||
public bool Opened { get; set; } | ||
public bool Locked { get; set; } | ||
} | ||
|
||
public class LightConfig : SpawnableConfig | ||
{ | ||
public PrimitiveType PrimitiveType { get; set; } | ||
public Color Color { get; set; } | ||
public float Range { get; set; } | ||
}*/ | ||
} | ||
public sealed class ItemConfig : SpawnableConfig | ||
{ | ||
public ItemType Item { get; set; } | ||
public ushort Ammo { get; set; } | ||
public uint Attachments { get; set; } | ||
} | ||
|
||
/*public class PrimitiveConfig : SpawnableConfig | ||
{ | ||
public PrimitiveType PrimitiveType { get; set; } | ||
public Color Color { get; set; } | ||
} | ||
public class LightConfig : SpawnableConfig | ||
{ | ||
public PrimitiveType PrimitiveType { get; set; } | ||
public Color Color { get; set; } | ||
public float Range { get; set; } | ||
}*/ |
Oops, something went wrong.