From 4676aea0595af68b8e8d28f5ae8dd2aa88406cd6 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:07:24 +0100 Subject: [PATCH] add GetObjectsInParcel --- SecondBotEvents/Commands/ParcelCommands.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs index cab9019..46709c7 100644 --- a/SecondBotEvents/Commands/ParcelCommands.cs +++ b/SecondBotEvents/Commands/ParcelCommands.cs @@ -1073,6 +1073,43 @@ namespace SecondBotEvents.Commands return BasicReply("ok", [objectuuid]); } + [About("Returns all objects in the current parcel")] + [ReturnHints("json object with all objects in the parcel")] + [ReturnHintsFailure("Error not in a sim")] + [ReturnHintsFailure("Parcel data not ready")] + [ReturnHintsFailure("No objects found in the parcel")] + [CmdTypeGet()] + public object GetObjectsInParcel() + { + KeyValuePair tests = SetupCurrentParcel(); + if (tests.Key == false) + { + return Failure(tests.Value); + } + List objects = []; + Dictionary objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy(); + foreach (KeyValuePair Obj in objects_copy) + { + if (Obj.Value.ParentID == 0) + { + if(Obj.Value.Position is Vector3 position) + { + if (position.X < targetparcel.AABBMax.X && position.X > targetparcel.AABBMin.X && + position.Y < targetparcel.AABBMax.Y && position.Y > targetparcel.AABBMin.Y && + position.Z < targetparcel.AABBMax.Z && position.Z > targetparcel.AABBMin.Z) + { + objects.Add(Obj.Value); + } + } + } + } + if(objects.Count == 0) + { + return Failure("No objects found in the parcel"); + } + return BasicReply(JsonConvert.SerializeObject(objects)); + } + [About("Updates the current parcels media settings \n" + "MediaAutoScale=Bool (True|False)\n" + "MediaLoop=Bool (True|False)\n" +