Update Info.cs
This commit is contained in:
parent
11a11f8097
commit
1d5e1b03c8
1 changed files with 44 additions and 41 deletions
|
|
@ -17,59 +17,62 @@ 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)
|
||||||
List<SculptysInfo> reply = new List<SculptysInfo>();
|
|
||||||
foreach (KeyValuePair<uint, Primitive> Obj in objects_copy)
|
|
||||||
{
|
|
||||||
if (Obj.Value.Sculpt != null)
|
|
||||||
{
|
{
|
||||||
if (PrimType.Sculpt.Equals(Obj.Value.Type) == true)
|
sculpts.Add(Obj.Key, Obj.Value);
|
||||||
{
|
|
||||||
Vector3 pos = Obj.Value.Position;
|
|
||||||
string name = "?";
|
|
||||||
if (Obj.Value.NameValues != null)
|
|
||||||
{
|
|
||||||
name = Obj.Value.NameValues[0].Value.ToString();
|
|
||||||
}
|
|
||||||
UUID key = Obj.Value.ID;
|
|
||||||
UUID owner = Obj.Value.OwnerID;
|
|
||||||
bool asLink = false;
|
|
||||||
if (Obj.Value.ParentID > 0)
|
|
||||||
{
|
|
||||||
if(mapLocalID.ContainsKey(Obj.Value.ParentID) == true)
|
|
||||||
{
|
|
||||||
Primitive wip = objects_copy[mapLocalID[Obj.Value.ParentID]];
|
|
||||||
pos = wip.Position;
|
|
||||||
asLink = true;
|
|
||||||
owner = wip.OwnerID;
|
|
||||||
if (wip.NameValues != null)
|
|
||||||
{
|
|
||||||
name = wip.NameValues[0].Value.ToString();
|
|
||||||
}
|
|
||||||
key = wip.ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SculptysInfo A = new SculptysInfo();
|
|
||||||
A.isLinked = asLink.ToString();
|
|
||||||
A.name = name.ToString();
|
|
||||||
A.owner = owner.ToString();
|
|
||||||
A.uuid = key.ToString();
|
|
||||||
A.pos = pos.ToString();
|
|
||||||
reply.Add(A);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BasicReply(JsonConvert.SerializeObject(reply), "ListSculptys");
|
List<SculptysInfo> reply = new List<SculptysInfo>();
|
||||||
|
foreach (KeyValuePair<uint, Primitive> Obj in sculpts)
|
||||||
|
{
|
||||||
|
Vector3 pos = Obj.Value.Position;
|
||||||
|
string name = "?";
|
||||||
|
if (Obj.Value.NameValues != null)
|
||||||
|
{
|
||||||
|
name = Obj.Value.NameValues[0].Value.ToString();
|
||||||
|
}
|
||||||
|
UUID key = Obj.Value.ID;
|
||||||
|
UUID owner = Obj.Value.OwnerID;
|
||||||
|
bool asLink = false;
|
||||||
|
if (Obj.Value.ParentID > 0)
|
||||||
|
{
|
||||||
|
if(mapLocalID.ContainsKey(Obj.Value.ParentID) == true)
|
||||||
|
{
|
||||||
|
Primitive wip = objects_copy[mapLocalID[Obj.Value.ParentID]];
|
||||||
|
pos = wip.Position;
|
||||||
|
asLink = true;
|
||||||
|
owner = wip.OwnerID;
|
||||||
|
if (wip.NameValues != null)
|
||||||
|
{
|
||||||
|
name = wip.NameValues[0].Value.ToString();
|
||||||
|
}
|
||||||
|
key = wip.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SculptysInfo A = new SculptysInfo();
|
||||||
|
A.isLinked = asLink.ToString();
|
||||||
|
A.name = name.ToString();
|
||||||
|
A.owner = owner.ToString();
|
||||||
|
A.uuid = key.ToString();
|
||||||
|
A.pos = pos.ToString();
|
||||||
|
reply.Add(A);
|
||||||
|
}
|
||||||
|
if (reply.Count == 0)
|
||||||
|
{
|
||||||
|
return Failure("No objects found", "ListSculptys");
|
||||||
|
}
|
||||||
|
return BasicReply(JsonConvert.SerializeObject(reply), "ListSculptys",new string[] { });
|
||||||
}
|
}
|
||||||
|
|
||||||
[About("Fetchs the current bot")]
|
[About("Fetchs the current bot")]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue