From efe66731d563fecc4502219fab280fe338ba11de Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:01:26 +0100 Subject: [PATCH] UpdateListOfParcels, GetParcelListSnapshots, GetListOfParcels --- SecondBotEvents/Commands/ParcelCommands.cs | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs index b2244de..8abaa98 100644 --- a/SecondBotEvents/Commands/ParcelCommands.cs +++ b/SecondBotEvents/Commands/ParcelCommands.cs @@ -1,14 +1,33 @@ using Newtonsoft.Json; using OpenMetaverse; using SecondBotEvents.Services; +using Swan; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using static OpenMetaverse.DirectoryManager; using static OpenMetaverse.ParcelManager; namespace SecondBotEvents.Commands { + public class parcelPacketReply + { + public List groupuuids = new List(); + public List parcels = new List(); + } + public class parcelPacketData + { + public int area; + public int groupindex; + public string name; + public int maxprims; + public int currentprims; + public string startbox; + public string endbox; + public byte[] bitmap; + } + [ClassInfo("Control the land under our feet")] public partial class ParcelCommands : CommandsAPI { @@ -16,6 +35,54 @@ namespace SecondBotEvents.Commands { } + [About("Requests the bot update its list of parcels ready for other commands")] + [ReturnHints("ok")] + public object UpdateListOfParcels() + { + GetClient().Parcels.RequestAllSimParcels(GetClient().Network.CurrentSim); + return BasicReply("ok"); + } + [About("Requests a packet blob for the parcels snapshot data")] + [ReturnHints("json encoded object")] + public object GetParcelListSnapshots() + { + Dictionary reply = new Dictionary(); + List Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList(); + foreach (Parcel A in Parcels) + { + reply.Add(A.Name, A.SnapshotID.ToString()); + } + return BasicReply(JsonConvert.SerializeObject(reply)); + } + + [About("Requests a packet blob for the parcels in the current sim\n call UpdateListOfParcels first to update list before calling")] + [ReturnHints("json encoded object")] + public object GetListOfParcels() + { + parcelPacketReply reply = new parcelPacketReply(); + List Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList(); + foreach (Parcel A in Parcels) + { + int index = reply.groupuuids.IndexOf(A.GroupID.ToString()); + if (index == -1) + { + reply.groupuuids.Add(A.GroupID.ToString()); + index = reply.groupuuids.IndexOf(A.GroupID.ToString()); + } + parcelPacketData R = new parcelPacketData(); + R.groupindex = index; + R.area = A.Area; + R.startbox = A.AABBMin.ToString(); + R.endbox = A.AABBMax.ToString(); + R.currentprims = A.TotalPrims; + R.maxprims = A.MaxPrims; + R.name = A.Name; + R.bitmap = A.Bitmap; + reply.parcels.Add(R); + } + return BasicReply(JsonConvert.SerializeObject(reply)); + } + [About("Sets the current parcel for sale Also marks the parcel for sale")] [ReturnHints("ok")] [ReturnHintsFailure("Error not in a sim")]