Ejemplo n.º 1
0
        public ListAsSet <SimObject> GetPrimitiveFromList(string[] args, out int argsUsed, List <string> missingOK)
        {
            ListAsSet <SimObject> allTargets = new ListAsSet <SimObject>();

            args = (string[])args.Clone();
            int argsUsedTotal = 0;

            while (args.Length > 0)
            {
                int argsUsed0;
                List <SimObject> PS = GetSingleArg(args, out argsUsed0);
                if (argsUsed0 == 0)
                {
                    missingOK.Add(args[0]);
                    argsUsed0 = 1;
                }
                if (argsUsed0 == 0)
                {
                    throw new ParserFilterFormatException("Cant GetSingleArg: ", args, 0);
                }
                argsUsedTotal += argsUsed0;
                if (PS != null)
                {
                    allTargets.AddRange(PS);
                }
                args = Parser.SplitOff(args, argsUsed0);
            }
            argsUsed = argsUsedTotal;
            if (allTargets.Count == 0)
            {
                return(null);
            }
            return(allTargets);
        }
Ejemplo n.º 2
0
 public SimAvatarImpl(UUID id, WorldObjects objectSystem, Simulator sim)
     : base(id, objectSystem, sim)
 {
     Affordances.ObjectType.SuperType.Add(SimTypeSystem.GetObjectType("Avatar"));
     _knownTypeUsages = new ListAsSet <SimTypeUsage>();
     WorldSystem.AddAvatar(this, id);
 }
        public List <BotAction> GetPossibleActions(double maxXYDistance, double maxZDist)
        {
            ListAsSet <SimObject> KnownObjects = Actor.GetKnownObjects();

            double           myZ        = Actor.GlobalPosition.Z;
            List <SimObject> useObjects = new List <SimObject>();

            foreach (SimObject O in KnownObjects.CopyOf())
            {
                if (!O.IsRegionAttached)
                {
                    continue;
                }
                if (O.Distance(Actor) > maxXYDistance)
                {
                    continue;
                }
                if (Math.Abs(O.GlobalPosition.Z - myZ) > maxZDist)
                {
                    continue;
                }
                useObjects.Add(O);
            }
            // useObjects.Sort(Actor.CompareDistance);


            List <SimTypeUsage> KnownTypeUsages = new List <SimTypeUsage>(Actor.KnownTypeUsages);

            KnownTypeUsages.Sort(CompareUsage);


            List <BotAction> KnownBotAcions = new List <BotAction>();

            lock (KnownTypeUsages)
                foreach (SimTypeUsage use in KnownTypeUsages)
                {
                    lock (useObjects) foreach (SimObject obj in useObjects)
                        {
                            if (CurrentAction != null)
                            {
                                if (obj != CurrentAction.Target)
                                {
                                    continue;
                                }
                            }
                            if (obj.Affordances.GetTypeUsages().Contains(use))
                            {
                                KnownBotAcions.Add(new BotObjectAction(Actor, new SimObjectUsage(use, obj)));
                            }
                        }
                }
            return(KnownBotAcions);
        }
Ejemplo n.º 4
0
        public ListAsSet <Abortable> AllTaskQueues()
        {
            ListAsSet <Abortable> all = ClientManager.AllTaskQueues();

            foreach (var tq in TaskQueueHandler.TaskQueueHandlers)
            {
                if (tq.Owner == this)
                {
                    all.Add(tq);
                }
            }
            all.AddRange(botCommandThreads);
            return(all);
        }
Ejemplo n.º 5
0
        public ListAsSet <SimObject> GetRelations(ICollection re)
        {
            var more = new ListAsSet <SimObject>();

            foreach (var OP in re)
            {
                SimObject O = AsSimObject(OP);
                if (O == null)
                {
                    continue;
                }
                more.Add(O);
                AsPrimitives(more, O.Children);
                SimObject P = O.Parent;
                if (P != O)
                {
                    AsPrimitives(more, P.Children);
                }
            }
            return(more);
        }
Ejemplo n.º 6
0
        public SimObject GetNextInterestingObject()
        {
            SimObject mostInteresting = null;

            if (InterestingObjects.Count < 2)
            {
                InterestingObjects = Actor.GetKnownObjects();
                lock (InterestingObjects) InterestingObjects.Remove(Actor);
            }
            int count = InterestingObjects.Count - 2;

            foreach (BotMentalAspect cAspect in InterestingObjects)
            {
                if (cAspect is SimObject)
                {
                    if (mostInteresting == null)
                    {
                        mostInteresting = (SimObject)cAspect;
                        ///  break;
                    }
                    else
                    {
                        mostInteresting = (SimObject)CompareTwo(mostInteresting, cAspect);
                    }
                    count--;
                    if (count < 0)
                    {
                        break;
                    }
                }
            }
            lock (InterestingObjects)
            {
                InterestingObjects.Remove(mostInteresting);
                InterestingObjects.Add(mostInteresting);
            }
            return(mostInteresting);
        }
Ejemplo n.º 7
0
 public SimAvatarImpl(UUID id, WorldObjects objectSystem, Simulator sim)
     : base(id, objectSystem, sim)
 {
     Affordances.ObjectType.SuperType.Add(SimTypeSystem.GetObjectType("Avatar"));
     _knownTypeUsages = new ListAsSet<SimTypeUsage>();
     WorldSystem.AddAvatar(this, id);
 }
Ejemplo n.º 8
0
 public ListAsSet<Abortable> AllTaskQueues()
 {
     var all = new ListAsSet<Abortable>();
     foreach (var tq in TaskQueueHandler.TaskQueueHandlers)
     {
         if (tq.Owner == null) all.Add(tq);
     }
     return all;
 }
Ejemplo n.º 9
0
 public SimObject GetNextInterestingObject()
 {
     SimObject mostInteresting = null;
     if (InterestingObjects.Count < 2)
     {
         InterestingObjects = Actor.GetKnownObjects();
         lock (InterestingObjects) InterestingObjects.Remove(Actor);
     }
     int count = InterestingObjects.Count - 2;
     foreach (BotMentalAspect cAspect in InterestingObjects)
     {
         if (cAspect is SimObject)
         {
             if (mostInteresting == null)
             {
                 mostInteresting = (SimObject)cAspect;
                 ///  break;
             }
             else
             {
                 mostInteresting = (SimObject)CompareTwo(mostInteresting, cAspect);
             }
             count--;
             if (count < 0) break;
         }
     }
     lock (InterestingObjects)
     {
         InterestingObjects.Remove(mostInteresting);
         InterestingObjects.Add(mostInteresting);
     }
     return mostInteresting;
 }
Ejemplo n.º 10
0
        public override CmdResult ExecuteRequest(CmdRequest argsI)
        {
            ListAsSet <SimPosition> objs = TheSimAvatar.GetSelectedObjects();

            if (argsI.Length == 0)
            {
                foreach (var o in objs)
                {
                    WriteLine(" " + o);
                }
                return(SuccessOrFailure());
            }
            if (argsI.ContainsFlag("--clear"))
            {
                objs.Clear();
                bool was = TheSimAvatar.SelectedBeam;
                TheSimAvatar.SelectedBeam = !was;
                TheSimAvatar.SelectedBeam = was;
            }
            var args = argsI.GetProperty("targets");

            {
                int  used   = 0;
                bool remove = false;
                while (used < args.Length)
                {
                    args = Parser.SplitOff(args, used);
                    string s = args[0];
                    if (s.StartsWith("-"))
                    {
                        remove = true;
                        s      = s.Substring(1);
                    }
                    if (s.StartsWith("+"))
                    {
                        remove = false;
                        s      = s.Substring(1);
                    }
                    if (s.Length < 0)
                    {
                        used = 1;
                        continue;
                    }
                    args[0] = s;
                    List <SimObject> PS = WorldSystem.GetPrimitives(args, out used);
                    foreach (var P in PS)
                    {
                        if (P == null)
                        {
                            WriteLine("Cannot find " + s);
                            used = 1;
                            continue;
                        }
                        if (remove)
                        {
                            WriteLine("Removing " + P);
                            TheSimAvatar.SelectedRemove(P);
                        }
                        else
                        {
                            WriteLine("Adding " + P);
                            TheSimAvatar.SelectedAdd(P);
                        }
                    }
                    if (used == 0)
                    {
                        break;
                    }
                }
            }
            return(Success("selected objects count=" + objs.Count));
        }