Update Info.cs

This commit is contained in:
Madpeter 2021-11-14 20:22:24 +00:00
parent 11a11f8097
commit 1d5e1b03c8

View file

@ -17,23 +17,24 @@ namespace BetterSecondBot.HttpService
public HTTP_Info(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { } public HTTP_Info(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
[About("Lists objects that are sculpty type in the current sim that the bot can see")] [About("Lists objects that are sculpty type in the current sim that the bot can see")]
[ReturnHints("A json object of [UUID=Pos]")] [ReturnHints("A json object")]
[Route(HttpVerbs.Get, "/ListSculptys/{token}")] [Route(HttpVerbs.Get, "/ListSculptys/{token}")]
public object ListSculptys(string token) public object ListSculptys(string token)
{ {
Dictionary<uint, Primitive> objects_copy = bot.GetClient.Network.CurrentSim.ObjectsPrimitives.Copy(); Dictionary<uint, Primitive> objects_copy = bot.GetClient.Network.CurrentSim.ObjectsPrimitives.Copy();
Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>(); Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>();
Dictionary<uint, Primitive> sculpts = new Dictionary<uint, Primitive>();
foreach (KeyValuePair<uint, Primitive> Obj in objects_copy) foreach (KeyValuePair<uint, Primitive> Obj in objects_copy)
{ {
mapLocalID.Add(Obj.Value.LocalID, Obj.Key); mapLocalID.Add(Obj.Value.LocalID, Obj.Key);
if (PrimType.Sculpt.Equals(Obj.Value.Type) == true)
{
sculpts.Add(Obj.Key, Obj.Value);
}
} }
List<SculptysInfo> reply = new List<SculptysInfo>(); List<SculptysInfo> reply = new List<SculptysInfo>();
foreach (KeyValuePair<uint, Primitive> Obj in objects_copy) foreach (KeyValuePair<uint, Primitive> Obj in sculpts)
{
if (Obj.Value.Sculpt != null)
{
if (PrimType.Sculpt.Equals(Obj.Value.Type) == true)
{ {
Vector3 pos = Obj.Value.Position; Vector3 pos = Obj.Value.Position;
string name = "?"; string name = "?";
@ -67,9 +68,11 @@ namespace BetterSecondBot.HttpService
A.pos = pos.ToString(); A.pos = pos.ToString();
reply.Add(A); reply.Add(A);
} }
if (reply.Count == 0)
{
return Failure("No objects found", "ListSculptys");
} }
} return BasicReply(JsonConvert.SerializeObject(reply), "ListSculptys",new string[] { });
return BasicReply(JsonConvert.SerializeObject(reply), "ListSculptys");
} }
[About("Fetchs the current bot")] [About("Fetchs the current bot")]