diff --git a/BreakAndEnter.cs b/BreakAndEnter.cs new file mode 100644 index 0000000..5da9d9e --- /dev/null +++ b/BreakAndEnter.cs @@ -0,0 +1,30 @@ +using Rocket.Core.Logging; +using Rocket.Core.Plugins; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Rocket.API.Collections; + +namespace ExtraConcentratedJuice.BreakAndEnter +{ + public class BreakAndEnter : RocketPlugin + { + public static BreakAndEnter instance; + + protected override void Load() => instance = this; + + public override TranslationList DefaultTranslations => + new TranslationList + { + { "no_object", "No object was found in your line of sight." }, + { "structure_removed", "Structure removed successfully." }, + { "barricade_removed", "Barricade removed successfully." }, + { "invalid_destroy", "The object that you are looking at is not a barricade nor a structure." }, + { "invalid_door", "The object that you are looking at is not a door." }, + { "door_toggle", "Door {0}." }, + { "storage_open", "Opened storage." }, + { "invalid_storage", "The object that you are looking at is not a storage unit." } + }; + } +} diff --git a/BreakAndEnter.csproj b/BreakAndEnter.csproj new file mode 100644 index 0000000..f9091ce --- /dev/null +++ b/BreakAndEnter.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {315C09F9-9709-4CF9-AD2B-AED6C198CA68} + Library + Properties + ExtraConcentratedJuice + BreakAndEnter + v3.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + Libraries\Assembly-CSharp.dll + + + False + Libraries\Assembly-CSharp-firstpass.dll + + + False + Libraries\Rocket.API.dll + + + False + Libraries\Rocket.Core.dll + + + False + Libraries\Rocket.Unturned.dll + + + + + + + + + False + Libraries\UnityEngine.dll + + + + + + + + + + + + \ No newline at end of file diff --git a/BreakAndEnter.sln b/BreakAndEnter.sln new file mode 100644 index 0000000..fad1105 --- /dev/null +++ b/BreakAndEnter.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BreakAndEnter", "BreakAndEnter.csproj", "{315C09F9-9709-4CF9-AD2B-AED6C198CA68}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {315C09F9-9709-4CF9-AD2B-AED6C198CA68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {315C09F9-9709-4CF9-AD2B-AED6C198CA68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {315C09F9-9709-4CF9-AD2B-AED6C198CA68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {315C09F9-9709-4CF9-AD2B-AED6C198CA68}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FD01AEB5-2C6B-4383-B451-DC19884E77F2} + EndGlobalSection +EndGlobal diff --git a/CommandDestroy.cs b/CommandDestroy.cs new file mode 100644 index 0000000..3ab7bcc --- /dev/null +++ b/CommandDestroy.cs @@ -0,0 +1,88 @@ +using Rocket.API; +using Rocket.Unturned.Chat; +using Rocket.Unturned.Player; +using SDG.Framework.Utilities; +using SDG.Unturned; +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace ExtraConcentratedJuice.BreakAndEnter +{ + public class CommandDestroy : IRocketCommand + { + #region Properties + public AllowedCaller AllowedCaller => AllowedCaller.Player; + + public string Name => "destroy"; + + public string Help => "Destroys the barricade or structure that you are looking at."; + + public string Syntax => "/destroy"; + + public List Aliases => new List(); + + public List Permissions => new List { "breakandenter.destroy" }; + #endregion + + public void Execute(IRocketPlayer caller, string[] args) + { + Player player = ((UnturnedPlayer)caller).Player; + PlayerLook look = player.look; + + if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE | RayMasks.STRUCTURE)) + { + Interactable2SalvageBarricade barri = hit.transform.GetComponent(); + Interactable2SalvageStructure struc = hit.transform.GetComponent(); + + if (barri != null) + { + BarricadeManager.tryGetInfo(barri.root, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region); + + region.barricades.RemoveAt(index); + + BarricadeManager manager = (BarricadeManager)typeof(BarricadeManager).GetField("manager", BindingFlags.NonPublic | + BindingFlags.Static).GetValue(null); + + manager.channel.send("tellTakeBarricade", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] + { + x, + y, + plant, + index + }); + + UnturnedChat.Say(caller, Util.Translate("barricade_removed")); + } + else if (struc != null) + { + StructureManager.tryGetInfo(struc.transform, out byte x, out byte y, out ushort index, out StructureRegion region); + + region.structures.RemoveAt(index); + + StructureManager manager = (StructureManager)typeof(StructureManager).GetField("manager", BindingFlags.NonPublic | + BindingFlags.Static).GetValue(null); + + manager.channel.send("tellTakeStructure", ESteamCall.ALL, x, y, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] + { + x, + y, + index, + (region.drops[index].model.position - player.transform.position).normalized * 100f + }); + + UnturnedChat.Say(caller, Util.Translate("structure_removed")); + } + else + { + UnturnedChat.Say(caller, Util.Translate("invalid_destroy")); + } + } + else + { + UnturnedChat.Say(caller, Util.Translate("no_object")); + } + } + } +} \ No newline at end of file diff --git a/CommandDoor.cs b/CommandDoor.cs new file mode 100644 index 0000000..079820b --- /dev/null +++ b/CommandDoor.cs @@ -0,0 +1,74 @@ +using Rocket.API; +using Rocket.Core.Logging; +using Rocket.Unturned.Chat; +using Rocket.Unturned.Effects; +using Rocket.Unturned.Player; +using SDG.Framework.Utilities; +using SDG.Unturned; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEngine; + +namespace ExtraConcentratedJuice.BreakAndEnter +{ + public class CommandDoor : IRocketCommand + { + #region Properties + public AllowedCaller AllowedCaller => AllowedCaller.Player; + + public string Name => "door"; + + public string Help => "Forces the door that you are looking at to open or close."; + + public string Syntax => "/door"; + + public List Aliases => new List(); + + public List Permissions => new List { "breakandenter.door" }; + #endregion + + public void Execute(IRocketPlayer caller, string[] args) + { + PlayerLook look = ((UnturnedPlayer)caller).Player.look; + + if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE)) + { + InteractableDoorHinge hinge = hit.transform.GetComponent(); + + if (hinge != null) + { + InteractableDoor door = hinge.door; + bool open = !door.isOpen; + + BarricadeManager.tryGetInfo(door.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region); + + BarricadeManager manager = (BarricadeManager)typeof(BarricadeManager).GetField("manager", BindingFlags.NonPublic | + BindingFlags.Static).GetValue(null); + + door.updateToggle(open); + + manager.channel.send("tellToggleDoor", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] + { + x, + y, + plant, + index, + open + }); + + UnturnedChat.Say(caller, Util.Translate("door_toggle", open ? "opened" : "closed")); + } + else + { + UnturnedChat.Say(caller, Util.Translate("invalid_door")); + } + } + else + { + UnturnedChat.Say(caller, Util.Translate("no_object")); + } + } + } +} \ No newline at end of file diff --git a/CommandStorage.cs b/CommandStorage.cs new file mode 100644 index 0000000..d74ec67 --- /dev/null +++ b/CommandStorage.cs @@ -0,0 +1,61 @@ +using Rocket.API; +using Rocket.Unturned.Chat; +using Rocket.Unturned.Player; +using SDG.Framework.Utilities; +using SDG.Unturned; +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace ExtraConcentratedJuice.BreakAndEnter +{ + public class CommandStorage : IRocketCommand + { + #region Properties + public AllowedCaller AllowedCaller => AllowedCaller.Player; + + public string Name => "storage"; + + public string Help => "Lets you view the contents of the storage unit that you are looking at."; + + public string Syntax => "/storage"; + + public List Aliases => new List(); + + public List Permissions => new List { "breakandenter.storage" }; + #endregion + + public void Execute(IRocketPlayer caller, string[] args) + { + Player player = ((UnturnedPlayer)caller).Player; + PlayerLook look = player.look; + + if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE)) + { + InteractableStorage storage = hit.transform.GetComponent(); + + if (storage != null) + { + storage.isOpen = true; + storage.opener = player; + player.inventory.isStoring = true; + player.inventory.isStorageTrunk = false; + player.inventory.storage = storage; + player.inventory.updateItems(PlayerInventory.STORAGE, storage.items); + player.inventory.sendStorage(); + + UnturnedChat.Say(caller, Util.Translate("storage_open")); + } + else + { + UnturnedChat.Say(caller, Util.Translate("invalid_storage")); + } + } + else + { + UnturnedChat.Say(caller, Util.Translate("no_object")); + } + } + } +} \ No newline at end of file diff --git a/Libraries/Assembly-CSharp-firstpass.dll b/Libraries/Assembly-CSharp-firstpass.dll new file mode 100644 index 0000000..e7dabad Binary files /dev/null and b/Libraries/Assembly-CSharp-firstpass.dll differ diff --git a/Libraries/Assembly-CSharp.dll b/Libraries/Assembly-CSharp.dll new file mode 100644 index 0000000..0869007 Binary files /dev/null and b/Libraries/Assembly-CSharp.dll differ diff --git a/Libraries/Rocket.API.dll b/Libraries/Rocket.API.dll new file mode 100644 index 0000000..e273f32 Binary files /dev/null and b/Libraries/Rocket.API.dll differ diff --git a/Libraries/Rocket.Core.dll b/Libraries/Rocket.Core.dll new file mode 100644 index 0000000..c008dc6 Binary files /dev/null and b/Libraries/Rocket.Core.dll differ diff --git a/Libraries/Rocket.Unturned.dll b/Libraries/Rocket.Unturned.dll new file mode 100644 index 0000000..9c74167 Binary files /dev/null and b/Libraries/Rocket.Unturned.dll differ diff --git a/Libraries/UnityEngine.dll b/Libraries/UnityEngine.dll new file mode 100644 index 0000000..8c37a18 Binary files /dev/null and b/Libraries/UnityEngine.dll differ diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c330cd4 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BreakAndEnter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("BreakAndEnter")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("315c09f9-9709-4cf9-ad2b-aed6c198ca68")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Util.cs b/Util.cs new file mode 100644 index 0000000..021f120 --- /dev/null +++ b/Util.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ExtraConcentratedJuice.BreakAndEnter +{ + public static class Util + { + public static string Translate(string TranslationKey, params object[] Placeholders) => + BreakAndEnter.instance.Translations.Instance.Translate(TranslationKey, Placeholders); + } +}