Example #1
0
        public void Aging()
        {
            BotNeeds CurrentNeeds = this.CurrentNeeds;

            // Initially randomize
            foreach (FieldInfo c in CurrentNeeds.GetType().GetFields())
            {
                if (c.FieldType == typeof(float))
                {
                    CurrentNeeds.SetValue(c, CurrentNeeds, MyRandom.Next(100));
                }
            }

            BotNeeds OneMinute = SimTypeSystem.GetObjectType("OnMinuteTimer").GetUsageActual("OnMinuteTimer");

            while (true)
            {
                Actor.ScanNewObjects(2, Actor.SightRange, false);
                CurrentNeeds.AddFrom(OneMinute);
                CurrentNeeds.SetRange(0.0F, 100.0F);
                //SimPosition to = WorldObjects.Master.m_TheSimAvatar;
                //if (to != null)
                //{
                //    Console.WriteLine("Aging: " + this + " " + to.DistanceVectorString(this));
                //}
                Thread.Sleep(60000); ///  one minute

                ///  Debug(CurrentNeeds.ToString());
            }
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string to_op   = args.GetString("verb");
            string objname = args.GetString("target");

            if (objname == "")
            {
                return(Failure("$bot don't know what object to use."));
            }
            if (to_op == "")
            {
                SimObject objToUse;
                if (WorldSystem.tryGetPrim(objname, out objToUse))
                {
                    if ((BotNeeds)TheSimAvatar["CurrentNeeds"] == null)
                    {
                        TheSimAvatar["CurrentNeeds"] = new BotNeeds(90.0f);
                    }
                    SimTypeUsage usage = objToUse.Affordances.GetBestUse((BotNeeds)TheSimAvatar["CurrentNeeds"]);
                    if (usage == null)
                    {
                        //usage = new MoveToLocation(TheSimAvatar, objToUse);
                        return(Failure("$bot don't have a use for " + objToUse + " yet."));
                    }
                    TheSimAvatar.Do(usage, objToUse);
                    return(Success("used " + objToUse));
                }
                return(Failure("$bot don't know what to do with " + objname));
            }
            WriteLine("Trying to (" + to_op + ") with (" + objname + ")");
            TheBotClient.UseInventoryItem(to_op, objname);
            return(Success("completed to (" + to_op + ") with (" + objname + ")"));
        }
 public ParrotAction(SimActor a)
     : base(String.Format("AvatarThinkerThread for {0}", a))
 {
     Actor = a;
     Actor["CurrentNeeds"] = new BotNeeds(90.0f);
     avatarHeartbeatThread = new Thread(Aging)
     {
         Name     = String.Format("AvatarHeartbeatThread for {0}", Actor),
         Priority = ThreadPriority.Lowest
     };
     avatarHeartbeatThread.Start();
 }
        public void Aging()
        {
            BotNeeds OneMinute = SimTypeSystem.GetObjectType("OnMinuteTimer").GetUsageActual("OnMinuteTimer");

            while (true)
            {
                Actor.ScanNewObjects(2, Actor.SightRange, false);
                CurrentNeeds.AddFrom(OneMinute);
                CurrentNeeds.SetRange(0.0F, 100.0F);
                //SimPosition to = WorldObjects.Master.m_TheSimAvatar;
                //if (to != null)
                //{
                //    Console.WriteLine("Aging: " + this + " " + to.DistanceVectorString(this));
                //}
                Thread.Sleep(60000); ///  one minute

                ///  Debug(CurrentNeeds.ToString());
            }
        }