Exemplo n.º 1
0
 public BotObjectAction(SimAvatar who, SimObjectUsage whattarget)
     : base(whattarget.ToString())
 {
     TheBot = who;
     //TypeUsage = whattarget.Usage;
     TargetUse = whattarget;// new SimObjectUsage(what, target);
 }
 public BotObjectAction(SimAvatar who, SimObjectUsage whattarget)
     : base(whattarget.ToString())
 {
     TheBot = who;
     //TypeUsage = whattarget.Usage;
     TargetUse = whattarget;// new SimObjectUsage(what, target);
 }
        public virtual void InvokeBotSideEffect(SimAvatar TheBot)
        {
            Debug(TheBot, ToString());
            //User.ApplyUpdate(use, simObject);
            BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];

            if (CurrentNeeds == null)
            {
                TheBot["CurrentNeeds"] = CurrentNeeds = new BotNeeds(90.0f);
            }
            BotNeeds needsBefore = CurrentNeeds.Copy();
            BotNeeds update      = Target.Affordances.GetActualUpdate(TypeUsage.UsageName);

            //TODO rate interaction and update TheBot.Assumptions
            CurrentNeeds.AddFrom(update);
            CurrentNeeds.SetRange(0.0F, 100.0F);
            BotNeeds difNeeds = CurrentNeeds.Minus(needsBefore);

            Debug(TheBot, TheBot + " " + ToString() + "\n\t " +
                  TheBot.DistanceVectorString(Target)
                  + "=> " + difNeeds.ShowNonZeroNeeds());
            if (TheBot is SimActor)
            {
                ((SimActor)TheBot).ExecuteLisp(this, TypeUsage);
            }
            Thread.Sleep(TypeUsage.totalTimeMS);
        }
Exemplo n.º 4
0
        public override void Avatars_OnAvatarProperties(object sender, AvatarPropertiesReplyEventArgs e)
        {
            SimAvatar A = DeclareAvatarProfile(e.AvatarID);

            if (!MaintainAvatarMetaData)
            {
                return;
            }
            A.ProfileProperties = e.Properties;
            UUID propertiesPartner = e.Properties.Partner;

            if (propertiesPartner != UUID.Zero)
            {
                SimAvatarImpl AA = DeclareAvatarProfile(propertiesPartner);
                //if (AA.GetName() == null)
                //{
                //    String s = GetUserName(propertiesPartner);
                //    AA.AspectName = s;
                //}
            }
            if (e.Properties.ProfileImage != UUID.Zero)
            {
                // RequestAsset(properties.ProfileImage, AssetType.Texture, true);
            }
            //TODO SendNewEvent("On-Avatar-Properties", GetAvatar(avatarID, null), properties);
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            //   base.acceptInput(verb, args);

            BotClient      Client  = TheBotClient;
            string         subject = String.Join(" ", args);
            OutputDelegate wtoList = (f, a) => AppendResults("events", string.Format(f, a));

            if (subject.Length == 0)
            {
                return(Success(DebugInfo(TheSimAvatar, wtoList)));
            }

            float range;
            int   blanks    = 0;
            int   nonblanks = 0;

            if (float.TryParse(subject, out range))
            {
                SimAvatar simAva = WorldSystem.TheSimAvatar;
                if (simAva != null)
                {
                    List <SimObject> objs = ((SimObjectImpl)simAva).GetNearByObjects((double)range, false);
                    if (objs.Count > 0)
                    {
                        foreach (SimObject o in objs)
                        {
                            if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                            {
                                blanks++;
                                if (!(o is SimAvatar))
                                {
                                    continue;
                                }
                            }
                            string s = DebugInfo(o, wtoList);
                            WriteLine(s);
                            nonblanks++;
                        }
                    }
                }
            }
            else
            {
                int argsUsed = 0;
                var PS       = WorldSystem.GetPrimitives(Parser.SplitOff(args, argsUsed), out argsUsed);
                foreach (SimObject o in PS)
                {
                    string s = DebugInfo(o, wtoList);
                    WriteLine(s);
                    if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                    {
                        blanks++;
                        continue;
                    }
                    nonblanks++;
                }
            }
            return(Success("simEventComplete blanks=" + blanks + " nonblanks=" + nonblanks));
        }
Exemplo n.º 6
0
 public BotSocialAction(SimAvatar who, SimTypeUsage what, SimAvatar target)
     : base(what.UsageName + " " + target)
 {
     TheBot = (SimControllableAvatar) who;
     TypeUsage = what;
     Victem = target;
     CurrentTopic = null;
     TimeRemaining = rand.Next(1, 3); // one to tree cycles
 }
 public BotSocialAction(SimAvatar who, SimTypeUsage what, SimAvatar target)
     : base(what.UsageName + " " + target)
 {
     TheBot        = (SimControllableAvatar)who;
     TypeUsage     = what;
     Victem        = target;
     CurrentTopic  = null;
     TimeRemaining = rand.Next(1, 3); // one to tree cycles
 }
Exemplo n.º 8
0
 public FollowerAction(SimAvatar impl, SimPosition position)
     : base(impl,position)
 {
     TheBot = (SimControllableAvatar)impl; 
     maxDistance = 3;// position.GetSizeDistance();
     Target = position;
     FollowThread = new Thread(FollowLoop);
     FollowThread.Name = DebugName;
 }
 private void Debug(SimAvatar TheBot, string theBotDebug)
 {
     TheBot.Debug(theBotDebug);
     //Radegast.RadegastInstance C = TheBot.GetGridClient().TheRadegastInstance;
     //if (C != null)
     //{
     //    C.TabConsole.DisplayNotificationInChat(theBotDebug);
     //}
 }
Exemplo n.º 10
0
 public FollowerAction(SimAvatar impl, SimPosition position)
     : base(impl, position)
 {
     TheBot            = (SimControllableAvatar)impl;
     maxDistance       = 3;// position.GetSizeDistance();
     Target            = position;
     FollowThread      = new Thread(FollowLoop);
     FollowThread.Name = DebugName;
 }
Exemplo n.º 11
0
        public override void Avatars_OnAvatarInterests(object sender, AvatarInterestsReplyEventArgs e)
        {
            SimAvatar A = DeclareAvatarProfile(e.AvatarID);

            if (!MaintainAvatarMetaData)
            {
                return;
            }
            A.AvatarInterests = e.Interests;
        }
Exemplo n.º 12
0
        public override void Avatars_OnAvatarGroups(object sender, AvatarGroupsReplyEventArgs e)
        {
            SimAvatar A = DeclareAvatarProfile(e.AvatarID);

            A.AddGoupRoles(e.Groups);
            foreach (AvatarGroup grp in e.Groups)
            {
                AddGroup2Key(grp.GroupName, grp.GroupID);
                //TODO SendNewEvent("On-Avatar-Properties", GetAvatar(avatarID, null), grp);
            }
        }
Exemplo n.º 13
0
 public FlyToAction(SimAvatar impl, SimPosition position)
     : base(impl, position)
 {
     // set in base
     //TheBot = impl;
     //Target = position;
     maxDistance       = position.GetSizeDistance();
     FollowThread      = new Thread(FollowLoop);
     FollowThread.Name = ToString();
     callback          = Objects_OnObjectUpdated;
 }
Exemplo n.º 14
0
        public static Texture2D GenHeadTex(VMAvatar ava)
        {
            var m_Head = new SimAvatar(ava.Avatar); //talk about confusing...

            m_Head.StripAllButHead();


            var HeadCamera = new BasicCamera(GameFacade.GraphicsDevice, new Vector3(0.0f, 7.0f, -17.0f), Vector3.Zero, Vector3.Up);

            var pos2 = m_Head.Skeleton.GetBone("HEAD").AbsolutePosition;

            pos2.Y += 0.1f;
            HeadCamera.Position         = new Vector3(0, pos2.Y, 12.5f);
            HeadCamera.FOV              = (float)Math.PI / 3f;
            HeadCamera.Target           = pos2;
            HeadCamera.ProjectionOrigin = new Vector2(74 / 2, 74 / 2);

            var HeadScene = new _3DTargetScene(GameFacade.GraphicsDevice, HeadCamera, new Point(74, 74), (GlobalSettings.Default.AntiAlias > 0) ? 8 : 0);

            HeadScene.ID = "UIPieMenuHead";

            m_Head.Scene = HeadScene;
            m_Head.Scale = new Vector3(1f);

            HeadCamera.Zoom = 13f;

            //rotate camera, similar to pie menu

            double xdir = Math.Atan(50 / 100.0);
            double ydir = Math.Atan(-50 / 100.0);

            Vector3 off = new Vector3(0, 0, 13.5f);
            Matrix  mat = Microsoft.Xna.Framework.Matrix.CreateRotationY((float)xdir) * Microsoft.Xna.Framework.Matrix.CreateRotationX((float)ydir);

            HeadCamera.Position = new Vector3(0, pos2.Y, 0) + Vector3.Transform(off, mat);

            if (ava.IsPet)
            {
                HeadCamera.Zoom *= 1.5f;
            }
            //end rotate camera

            HeadScene.Initialize(GameFacade.Scenes);
            HeadScene.Add(m_Head);

            HeadScene.Draw(GameFacade.GraphicsDevice);
            var copy = TextureUtils.CopyAccelerated(GameFacade.GraphicsDevice, HeadScene.Target);

            HeadScene.Dispose();
            return(copy);
        }
Exemplo n.º 15
0
        public void SetAvatarType(STR data)
        {
            if (data == null)
            {
                AvatarType = VMAvatarType.Adult;
            }
            else
            {
                var type = data.GetString(0);
                if (type == "adult")
                {
                    AvatarType = VMAvatarType.Adult;
                }
                else if (type == "child")
                {
                    AvatarType = VMAvatarType.Child;
                }
                else if (type == "cat")
                {
                    AvatarType = VMAvatarType.Cat;
                }
                else if (type == "dog")
                {
                    AvatarType = VMAvatarType.Dog;
                }
            }

            Avatar = new SimAvatar(FSO.Content.Content.Get().AvatarSkeletons.Get(data.GetString(0) + ".skel"));
            if (UseWorld)
            {
                switch (AvatarType)
                {
                case VMAvatarType.Adult:
                    Avatar.Head      = FSO.Content.Content.Get().AvatarOutfits.Get(0x000003a00000000D); //default to bob newbie, why not
                    Avatar.Body      = FSO.Content.Content.Get().AvatarOutfits.Get("mab002_slob.oft");
                    Avatar.Handgroup = Avatar.Body;
                    break;

                case VMAvatarType.Cat:
                    Avatar.Body = FSO.Content.Content.Get().AvatarOutfits.Get("uaa002cat_calico.oft");
                    break;

                case VMAvatarType.Dog:
                    Avatar.Body = FSO.Content.Content.Get().AvatarOutfits.Get("uaa012dog_scottish.oft");     //;)
                    break;

                case VMAvatarType.Child:
                    break;
                }
            }
        }
Exemplo n.º 16
0
        public void SetAvatarType(STR data)
        {
            if (data == null)
            {
                AvatarType = VMAvatarType.Adult;
            }
            else
            {
                var type = data.GetString(0);
                if (type == "adult")
                {
                    AvatarType = VMAvatarType.Adult;
                }
                else if (type == "child")
                {
                    AvatarType = VMAvatarType.Child;
                }
                else if (type == "cat")
                {
                    AvatarType = VMAvatarType.Cat;
                }
                else if (type == "dog")
                {
                    AvatarType = VMAvatarType.Dog;
                }
            }



            switch (AvatarType)
            {
            case VMAvatarType.Adult:
                Avatar           = new SimAvatar(FSO.Content.Content.Get().AvatarSkeletons.Get("adult.skel"));
                Avatar.Head      = FSO.Content.Content.Get().AvatarOutfits.Get(SetAvatarRandomOutfit(1));
                Avatar.Body      = FSO.Content.Content.Get().AvatarOutfits.Get(SetAvatarRandomOutfit(0));
                Avatar.Handgroup = Avatar.Body;

                break;

            case VMAvatarType.Cat:
                var skel = FSO.Content.Content.Get().AvatarSkeletons.Get("cat.skel");
                Avatar      = new SimAvatar(skel);
                Avatar.Body = FSO.Content.Content.Get().AvatarOutfits.Get("uaa002cat_calico.oft");
                break;

            case VMAvatarType.Dog:
                Avatar      = new SimAvatar(FSO.Content.Content.Get().AvatarSkeletons.Get("dog.skel"));
                Avatar.Body = FSO.Content.Content.Get().AvatarOutfits.Get("uaa012dog_scottish.oft");     //;)
                break;
            }
        }
Exemplo n.º 17
0
        public void SetAvatarType(STR data)
        {
            if (data == null)
            {
                AvatarType = VMAvatarType.Adult;
            }
            else
            {
                var type = data.GetString(0);
                if (type == "adult")
                {
                    AvatarType = VMAvatarType.Adult;
                }
                else if (type == "child")
                {
                    AvatarType = VMAvatarType.Child;
                }
                else if (type == "cat")
                {
                    AvatarType = VMAvatarType.Cat;
                }
                else if (type == "dog")
                {
                    AvatarType = VMAvatarType.Dog;
                }
            }

            switch (AvatarType)
            {
            case VMAvatarType.Adult:
                Avatar           = new SimAvatar(TSO.Content.Content.Get().AvatarSkeletons.Get("adult.skel"));
                Avatar.Head      = TSO.Content.Content.Get().AvatarOutfits.Get("mah010_baldbeard01.oft"); //default to bob newbie, why not
                Avatar.Body      = TSO.Content.Content.Get().AvatarOutfits.Get("mab002_slob.oft");
                Avatar.Handgroup = Avatar.Body;
                break;

            case VMAvatarType.Cat:
                var skel = TSO.Content.Content.Get().AvatarSkeletons.Get("cat.skel");
                Avatar      = new SimAvatar(skel);
                Avatar.Body = TSO.Content.Content.Get().AvatarOutfits.Get("uaa002cat_calico.oft");
                break;

            case VMAvatarType.Dog:
                Avatar      = new SimAvatar(TSO.Content.Content.Get().AvatarSkeletons.Get("dog.skel"));
                Avatar.Body = TSO.Content.Content.Get().AvatarOutfits.Get("uaa012dog_scottish.oft");     //;)
                break;
            }
        }
Exemplo n.º 18
0
 public void Avatars_OnAvatarAnimation(object sender, AvatarAnimationEventArgs e)
 {
     if (!MaintainAnims)
     {
         return;
     }
     EventQueue.Enqueue(() =>
     {
         SimAvatar avatar = (SimAvatar)CreateSimAvatar(e.AvatarID, this, null);
         if (avatar == null)
         {
             return;
         }
         if (UseEventSource(avatar))
         {
             avatar.OnAvatarAnimations(e.Animations);
         }
     });
 }
Exemplo n.º 19
0
        public bool tryGetAvatar(string name, out SimAvatar avatar)
        {
            avatar = null;
            SimObject prim;

            string[] splitted = Parser.ParseArguments(name);
            int      argsUsed;

            if (!tryGetPrim(splitted, out prim, out argsUsed))
            {
                return(false);
            }
            if (prim is SimAvatar)
            {
                avatar = (SimAvatar)prim;
                return(true);
            }
            return(false);
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
            }
            int argsUsed;

            foreach (var p in WorldSystem.GetPrimitives(args, out argsUsed))
            {
                if (p is SimAvatar)
                {
                    SimAvatar a = (SimAvatar)p;
                    AddSuccess("Showing " + a);
                    TheBotClient.InvokeGUI(() =>
                                           new Radegast.frmProfile(TheBotClient.TheRadegastInstance, a.GetName(), a.ID).Show());
                }
            }
            return(SuccessOrFailure());
        }
Exemplo n.º 21
0
 public MoveToLocation(SimAvatar impl, SimPosition position)
     : base("MoveTo " + impl + " -> " + impl.DistanceVectorString(position))
 {
     TheBot = (SimControllableAvatar)impl; 
     Target = position;
 }
Exemplo n.º 22
0
 public CommandAction(SimAvatar impl, String command)
     : base("ExecuteCommand " + impl + " -> " + command)
 {
     TheBot       = impl;
     this.command = command;
 }
        private SimObject GetSource(Simulator sim, UUID sourceID, SimObject source, ref object s, PCode isAvatar)
        {
            if (source != null)
            {
                s = source;
                return(source);
            }
            source = GetSimObjectFromUUID(sourceID);
            if (source != null)
            {
                s = source;
                return(source);
            }
            //TODO can we ever find a Primitive we hadnt yet interned?!
            Primitive sp = null;// GetPrimitive(sourceID, null);

            if (sp != null)
            {
                source = GetSimObject(sp);
            }
            else
            {
                if (sim != null && !RequestParcelObjects)
                {
                    RequestParcelObjects = true;
                    client.Parcels.RequestAllSimParcels(sim, false, 250);
                    client.Grid.RequestMapItems(sim.Handle, GridItemType.AgentLocations, GridLayerType.Objects);
                }
                switch (isAvatar)
                {
                case PCode.Tree:
                case PCode.Grass:
                case PCode.NewTree:
                case PCode.Prim:
                    if (!CogbotHelpers.IsNullOrZero(sourceID))
                    {
                        source = CreateSimObject(sourceID, this, null);
                    }
                    break;

                case PCode.Avatar:
                    DeclareAvatar(sourceID);
                    break;

                case PCode.None:
                case PCode.ParticleSystem:
                    SourceDetect(sourceID);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("isAvatar hint = " + isAvatar);
                }
                // client.Self.RequestSit(sourceID,Vector3.Zero);
                //  client.Directory.
            }

            if (source != null)
            {
                s = source;
            }
            else
            {
                lock (AvatarRegion)
                    if (AvatarRegion.ContainsKey(sourceID))
                    {
                        Debug("found it!");
                    }
                    else
                    {
                        lock (Name2Key)
                        {
                            foreach (KeyValuePair <string, UUID> key in Name2Key)
                            {
                                string name = key.Key;
                                if (name.StartsWith("("))
                                {
                                }
                                if (key.Value == sourceID)
                                {
                                    var list = SimAccounts.CopyOf();
                                    foreach (SimAvatar set in list)
                                    {
                                        if (set.ID == sourceID)
                                        {
                                            s = source = set;
                                            return(source);
                                        }
                                    }
                                    foreach (SimAvatar set in list)
                                    {
                                        string n = set.GetName();
                                        if (n != null && n.Equals(name))
                                        {
                                            s = source = set;
                                            return(source);
                                        }
                                    }
                                    Debug("No avatar object for " + name);
                                    SimAvatar impl = CreateSimAvatar(key.Value, this, sim);
                                    impl.AspectName = name;
                                    s = source = impl;
                                    return(source);
                                }
                            }
                        }
                    }
            }
            if (isAvatar == PCode.Prim)
            {
                SimObject impl = CreateSimObject(sourceID, this, sim);
                s = source = impl;
                return(source);
            }
            if (s == null)
            {
                s = sourceID;
            }
            return(source);
        }
Exemplo n.º 24
0
        public static Texture2D GenHeadTex(Outfit headOft, string name)
        {
            var      skels = Content.Content.Get().AvatarSkeletons;
            Skeleton skel  = null;
            bool     pet   = false;

            if (name.StartsWith("uaa"))
            {
                //pet
                if (name.Contains("cat"))
                {
                    skel = skels.Get("cat.skel");
                }
                else
                {
                    skel = skels.Get("dog.skel");
                }
                pet = true;
            }
            else
            {
                skel = skels.Get("adult.skel");
            }

            var m_Head = new SimAvatar(skel);

            m_Head.Head = headOft;
            m_Head.ReloadSkeleton();
            //m_Head.StripAllButHead();

            var HeadCamera = new BasicCamera(GameFacade.GraphicsDevice, new Vector3(0.0f, 7.0f, -17.0f), Vector3.Zero, Vector3.Up);

            var pos2 = m_Head.Skeleton.GetBone("HEAD").AbsolutePosition;

            pos2.Y += (pet)?((name.Contains("dog"))?0.16f:0.1f):0.12f;
            HeadCamera.Position = new Vector3(0, pos2.Y, 12.5f);
            //HeadCamera.FOV = (float)Math.PI / 3f;
            HeadCamera.Target           = pos2;
            HeadCamera.ProjectionOrigin = new Vector2(66 / 2, 66 / 2);

            var HeadScene = new _3DTargetScene(GameFacade.GraphicsDevice, HeadCamera, new Point(66, 66), 0);// (GlobalSettings.Default.AntiAlias) ? 8 : 0);

            HeadScene.ID = "UIPieMenuHead";
            //HeadScene.ClearColor = new Color(49, 65, 88);

            m_Head.Scene = HeadScene;
            m_Head.Scale = new Vector3(1f);

            HeadCamera.Zoom = 19.5f;

            //rotate camera, similar to pie menu

            double xdir = 0; //Math.Atan(0);
            double ydir = 0; //Math.Atan(0);

            Vector3 off = new Vector3(0, 0, 13.5f);
            Matrix  mat = Microsoft.Xna.Framework.Matrix.CreateRotationY((float)xdir) * Microsoft.Xna.Framework.Matrix.CreateRotationX((float)ydir);

            HeadCamera.Position = new Vector3(0, pos2.Y, 0) + Vector3.Transform(off, mat);

            if (pet)
            {
                HeadCamera.Zoom *= 1.3f;
            }
            //end rotate camera

            HeadScene.Initialize(GameFacade.Scenes);
            HeadScene.Add(m_Head);

            HeadScene.Draw(GameFacade.GraphicsDevice);
            return(Common.Utils.TextureUtils.Decimate(HeadScene.Target, GameFacade.GraphicsDevice, 2, true));
        }
Exemplo n.º 25
0
        public override void Friends_OnFriendFound(object sender, FriendFoundReplyEventArgs e)
        {
            SimAvatar A = DeclareAvatarProfile(e.AgentID);

            A.UpdatePosition(e.RegionHandle, e.Location);
        }
Exemplo n.º 26
0
        public UIPieMenu(List <VMPieMenuInteraction> pie, VMEntity obj, VMEntity caller, UILotControl parent)
        {
            if (FSOEnvironment.UIZoomFactor > 1.33f)
            {
                ScaleX = ScaleY = FSOEnvironment.UIZoomFactor * 0.75f;
            }
            TrueScale        = ScaleX * FSOEnvironment.DPIScaleFactor;
            m_PieButtons     = new List <UIButton>();
            this.m_Obj       = obj;
            this.m_Caller    = caller;
            this.m_Parent    = parent;
            this.ButtonStyle = new TextStyle
            {
                Font          = GameFacade.MainFont,
                Size          = 12,
                Color         = new Color(0xA5, 0xC3, 0xD6),
                SelectedColor = new Color(0x00, 0xFF, 0xFF),
                CursorColor   = new Color(255, 255, 255)
            };

            m_Bg = new UIImage(TextureGenerator.GetPieBG(GameFacade.GraphicsDevice));
            m_Bg.SetSize(0, 0); //is scaled up later
            this.AddAt(0, m_Bg);

            m_PieTree = new UIPieMenuItem()
            {
                Category = true
            };

            for (int i = 0; i < pie.Count; i++)
            {
                string[] depth = (pie[i].Name == null)?new string[] { "???" } :pie[i].Name.Split('/');

                var category = m_PieTree;                  //set category to root
                for (int j = 0; j < depth.Length - 1; j++) //iterate through categories
                {
                    if (category.Children.ContainsKey(depth[j]))
                    {
                        category = category.Children[depth[j]];
                    }
                    else
                    {
                        var newCat = new UIPieMenuItem()
                        {
                            Category = true,
                            Name     = depth[j],
                            Parent   = category
                        };
                        category.Children.Add(depth[j], newCat);
                        category = newCat;
                    }
                }
                //we are in the category, put the interaction in here;

                var item = new UIPieMenuItem()
                {
                    Category = false,
                    Name     = depth[depth.Length - 1],
                    ID       = pie[i].ID,
                    Param0   = pie[i].Param0
                };
                if (!category.Children.ContainsKey(item.Name))
                {
                    category.Children.Add(item.Name, item);
                }
            }

            m_CurrentItem = m_PieTree;
            m_PieButtons  = new List <UIButton>();
            RenderMenu();

            VMAvatar Avatar = (VMAvatar)caller;

            m_Head = new SimAvatar(Avatar.Avatar); //talk about confusing...
            m_Head.StripAllButHead();

            initSimHead();
        }
        private void acceptInput0(string verb, string[] argstokens, OutputDelegate WriteLine)
        {
            //   base.acceptInput(verb, args);

            BotClient Client = TheBotClient;

            if (!Client.IsLoggedInAndReady)
            {
                WriteLine("Not yet logged in");
                return;
            }

            double range;

            if (argstokens.Length > 0 && double.TryParse(argstokens[0], out range))
            {
                SimAvatar simAva = WorldSystem.TheSimAvatar;
                if (simAva != null)
                {
                    List <SimObject> objs = ((SimObjectImpl)simAva).GetNearByObjects(range, false);
                    if (objs.Count > 0)
                    {
                        foreach (SimObject o in objs)
                        {
                            WriteLine(WorldSystem.describePrim(o.Prim, false));
                        }
                        return;
                    }
                    WriteLine("looked at range " + range + " and saw " + objs.Count);
                }
                WriteLine("We have no body yet");
            }
            else
            {
                {
                    {
                        int found = 0;
                        int argsUsed;

                        if (argstokens.Length == 0)
                        {
                            argstokens = Parser.ParseArguments(DefaultLookString);
                        }
                        List <SimObject> PS       = WorldSystem.GetPrimitives(argstokens, out argsUsed);
                        bool             detailed = true;
                        if (!IsEmpty(PS))
                        {
                            if (PS.Count > 1)
                            {
                                detailed = false;
                            }
                            foreach (var prim in PS)
                            {
                                found++;
                                if (!prim.HasPrim)
                                {
                                    WriteLine("" + prim);
                                    continue;
                                }
                                if (prim is SimAvatar)
                                {
                                    WriteLine(WorldSystem.describeAvatar((Avatar)prim.Prim));
                                }
                                else
                                {
                                    WriteLine(WorldSystem.describePrim(prim.Prim, detailed));
                                }
                                //if (found > 30) break;
                            }
                        }
                        if (found == 0)
                        {
                            WriteLine("I don't know about " + Parser.Rejoin(argstokens, 0) + ".");
                        }
                        WriteLine("PS.Count==" + PS.Count);
                    }
                }
            }
        }
Exemplo n.º 28
0
 public virtual void InvokeBotSideEffect(SimAvatar TheBot)
 {
     Debug(TheBot, ToString());
     //User.ApplyUpdate(use, simObject);
     BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];
     if (CurrentNeeds == null)
     {
         TheBot["CurrentNeeds"] = CurrentNeeds = new BotNeeds(90.0f);   
     }                
     BotNeeds needsBefore = CurrentNeeds.Copy();
     BotNeeds update = Target.Affordances.GetActualUpdate(TypeUsage.UsageName);
     //TODO rate interaction and update TheBot.Assumptions
     CurrentNeeds.AddFrom(update);
     CurrentNeeds.SetRange(0.0F, 100.0F);
     BotNeeds difNeeds = CurrentNeeds.Minus(needsBefore);
     Debug(TheBot,TheBot + " " + ToString() + "\n\t " +
                  TheBot.DistanceVectorString(Target)
                  + "=> " + difNeeds.ShowNonZeroNeeds());
     if (TheBot is SimActor) ((SimActor)TheBot).ExecuteLisp(this, TypeUsage);
     Thread.Sleep(TypeUsage.totalTimeMS);
 }
Exemplo n.º 29
0
 private void Debug(SimAvatar TheBot,string theBotDebug)
 {
     TheBot.Debug(theBotDebug);
     //Radegast.RadegastInstance C = TheBot.GetGridClient().TheRadegastInstance;
     //if (C != null)
     //{
     //    C.TabConsole.DisplayNotificationInChat(theBotDebug);
     //}
 }
 public LispCodeAction(SimAvatar impl, object command)
     : base("ExecuteCommand " + impl + " -> " + command)
 {
     TheBot       = (SimControllableAvatar)impl;
     this.command = command;
 }
Exemplo n.º 31
0
 public FlyToAction(SimAvatar impl, SimPosition position)
     : base(impl, position)
 {
     // set in base
     //TheBot = impl;
     //Target = position;
     maxDistance = position.GetSizeDistance();
     FollowThread = new Thread(FollowLoop);
     FollowThread.Name = ToString();
     callback = Objects_OnObjectUpdated;
 }
        static public string argString(object arg)
        {
            if (arg == null)
            {
                return("NIL");
            }
            Type type = arg.GetType();

            if (arg is BotClient)
            {
                arg = ((BotClient)arg).GetAvatar();
                if (arg is BotClient)
                {
                    return(((BotClient)arg).ToString());
                }
            }
            if (arg is WorldObjects)
            {
                arg = ((WorldObjects)arg).TheSimAvatar;
            }
            if (arg is Simulator)
            {
                Simulator sim = (Simulator)arg;
                uint      globalX, globalY;
                Utils.LongToUInts(sim.Handle, out globalX, out globalY);
                return("'(simulator " + argString(sim.Name) + " " + globalX / 256 + " " + globalY / 256 + " " +
                       argString(sim.IPEndPoint.ToString()) + ")");
            }
            if (arg is Avatar)
            {
                Avatar prim = (Avatar)arg;
                arg = "'(SimAvatarFn "; //+ argString(prim.ID.ToString());
                if (prim.Name != null)
                {
                    arg = arg + " " + argString(prim.Name);
                }
                return(arg + ")");
            }

            if ((arg is AssetAnimation) || (arg is AssetTexture) || (arg is AssetSound))
            {
                Asset prim = (Asset)arg;
                arg = SimAssetStore.GetSimAsset(prim);
            }

            if (arg is SimAsset)
            {
                SimAsset  prim  = (SimAsset)arg;
                AssetType tyepe = prim.AssetType;
                arg = "'(Sim" + tyepe + "Fn "; //+ argString(prim.ID.ToString());
                if (prim.Name != null)
                {
                    arg = arg + " " + argString(prim.Name);
                }
                return(arg + ")");
            }

            if (arg is Primitive)
            {
                Primitive prim = (Primitive)arg;
                arg = "'(SimObjectFn  " + argString(prim.ID.ToString());
                if (prim.Properties != null)
                {
                    arg = arg + " " + argString(prim.Properties.Name);
                }
                return(arg + ")");
            }
            if (arg is SimAvatar)
            {
                SimAvatar prim = (SimAvatar)arg;
                arg = "'(SimAvatarFn  " + argString(prim.GetName());
                return(arg + ")");
            }
            if (arg is SimObject)
            {
                SimObject prim = (SimObject)arg;
                arg = "'(SimObjectFn  " + argString(prim.ID.ToString());
                string name = prim.GetName();
                if (!string.IsNullOrEmpty(name))
                {
                    arg = arg + " #|" + argString(name) + "|# ";
                }
                return(arg + ")");
            }
            if (type.IsEnum)
            {
                return(argString(arg.ToString()));
            }
            //InternalDictionary
            if (arg is IList)
            {
                String dictname = "'(list " + type.Name;
                IList  list     = (IList)arg;
                foreach (object key in list)
                {
                    dictname += " " + argString(key);
                }
                return(dictname + ")");
            }

            if (arg is Parcel)
            {
                String dictname = "'(parcel";
                Parcel list     = (Parcel)arg;
                dictname += " " + argString(list.SnapshotID.ToString());
                dictname += " " + argString(list.Name);
                return(dictname + ")");
            }
            if (arg is Group)
            {
                String dictname = "'(Group";
                Group  list     = (Group)arg;
                dictname += " " + argString(list.Name);
                return(dictname + ")");
            }
            if (arg is IDictionary)
            {
                String      dictname = "'(dict " + type.Name;
                IDictionary dict0    = (IDictionary)arg;
                IDictionary dict     = dict0;
                lock (dict.SyncRoot)
                {
                    foreach (object key in dict.Keys)
                    {
                        Object o = dict[key];
                        dictname += " " + argString(key) + "=" + argString(o);
                    }
                    return(dictname + ")");
                }
            }

            //if (arg is Quaternion)
            //{
            //    Quaternion quat = (Quaternion)arg;
            //    quat.Normalize();
            //    arg = WorldSystem.QuatToRotation(quat);
            //}

            if (arg is Quaternion)
            {
                Quaternion vect = (Quaternion)arg;
                return("'(Quaternion " + vect.X + " " + vect.Y + " " + vect.Z + " " + vect.W + ")");
            }

            if (arg is UUID)
            {
                //   if (true) return argString(arg.ToString());
                object found = WorldObjects.GridMaster.GetObject((UUID)arg);
                if (found == null || found is UUID)
                {
                    return(argString(arg.ToString()));
                }
                return(argString(found));
            }

            if (arg is Vector3)
            {
                Vector3 vect = (Vector3)arg;
                return("'(Vector3 " + vect.X + " " + vect.Y + " " + vect.Z + ")");
            }

            if (arg is Vector2)
            {
                Vector2 vect = (Vector2)arg;
                return("'(Vector2 " + vect.X + " " + vect.Y + ")");
            }

            if (arg is Vector3d)
            {
                Vector3d vect = (Vector3d)arg;
                return("'(Vector3d " + vect.X + " " + vect.Y + " " + vect.Z + ")");
            }

            if (type.IsArray)
            {
                Array a = (Array)arg;
                return("#{/*" + type + "*/" + argsListString(a) + "}");
            }
            if (arg is String)
            {
                return("\"" + arg.ToString().Replace("\"", "\\\"") + "\"");
            }
            if (type.Namespace.StartsWith("System"))
            {
                return("" + arg);
            }
            if (arg is IEnumerable)
            {
                IEnumerable a = (IEnumerable)arg;
                return("'(/*" + type + "*/" + argsListString(a) + ")");
            }
            if (type.IsValueType)
            {
                String tostr = "{" + arg + "";
                foreach (FieldInfo fi in type.GetFields())
                {
                    if (!fi.IsStatic)
                    {
                        tostr += ",";
                        tostr += fi.Name + "=";
                        tostr += argString(fi.GetValue(arg));
                    }
                }
                return(argString(tostr + "}"));
            }
            if (!type.IsValueType)
            {
                String tostr = "{" + arg + "";
                foreach (FieldInfo fi in type.GetFields())
                {
                    if (!fi.IsStatic)
                    {
                        tostr += ",";
                        tostr += fi.Name + "=";
                        tostr += fi.GetValue(arg);
                    }
                }
                return(argString(tostr + "}"));
            }
            return("" + arg);
        }
Exemplo n.º 33
0
 internal void AddAvatar(SimAvatar neu, UUID uuid)
 {
     var from = WorldObjects.SimAccounts;
     SimAvatar old = null;
     bool sameAvatar = false;
     bool downGrade = false;
     bool upGrade = false;
     foreach (SimAvatar avatar in from)
     {
         if (avatar.ID == uuid)
         {
             old = avatar;
             if (!ReferenceEquals(avatar, neu))
             {
                 if (old is SimAvatarClient && neu is SimAvatarClient)
                 {
                     throw new NotSupportedException("two Clients!");
                 }
                 if (old is SimAvatarClient && neu is SimAvatar)
                 {
                     downGrade = true;
                 }
                 if (old is SimAvatar && neu is SimAvatarClient)
                 {
                     upGrade = true;
                 }
             } else
             {
                 sameAvatar = true;
             }
         }
     }
     if (downGrade)
     {
         throw new NotSupportedException("downGrade!");
     }
     if (upGrade)
     {
         if (!ReferenceEquals(old.theAvatar,neu.theAvatar))
         {
             throw new NotSupportedException("theAvatar for upgrade is schizoid!");   
         }
         SimObjects.Remove(old);
         SimAccounts.Remove(old);
         SimAvatars.Remove(old);
     }
     if (!sameAvatar)
     {
         SimObjects.AddTo(neu);
         SimAccounts.Add((SimAvatar)neu);
         if (neu.HasPrim) SimAvatars.Add((SimAvatar)neu);
         RegisterUUID(uuid, neu);
         RequestAvatarMetadata(uuid);
     }
     //client.Avatars.RequestAvatarPicks(uuid);
 }
 public MoveToLocation(SimAvatar impl, SimPosition position)
     : base("MoveTo " + impl + " -> " + impl.DistanceVectorString(position))
 {
     TheBot = (SimControllableAvatar)impl;
     Target = position;
 }
Exemplo n.º 35
0
 public CommandAction(SimAvatar impl, String command)
     : base("ExecuteCommand " + impl + " -> " + command)
 {
     TheBot = impl;
     this.command = command;
 }
Exemplo n.º 36
0
        public UIPieMenu(List <VMPieMenuInteraction> pie, VMEntity obj, VMEntity caller, UILotControl parent)
        {
            if (FSOEnvironment.UIZoomFactor > 1.33f)
            {
                ScaleX = ScaleY = FSOEnvironment.UIZoomFactor * 0.75f;
            }
            TrueScale        = ScaleX * FSOEnvironment.DPIScaleFactor;
            m_PieButtons     = new List <UIButton>();
            this.m_Obj       = obj;
            this.m_Caller    = caller;
            this.m_Parent    = parent;
            this.ButtonStyle = new TextStyle
            {
                Font          = GameFacade.MainFont,
                VFont         = GameFacade.VectorFont,
                Size          = 12,
                Color         = new Color(0xA5, 0xC3, 0xD6),
                SelectedColor = new Color(0x00, 0xFF, 0xFF),
                CursorColor   = new Color(255, 255, 255)
            };

            HighlightStyle       = ButtonStyle.Clone();
            HighlightStyle.Color = Color.Yellow;

            lerpSpeed = 0.125f * (60.0f / FSOEnvironment.RefreshRate);
            m_Bg      = new UIImage(TextureGenerator.GetPieBG(GameFacade.GraphicsDevice));
            m_Bg.SetSize(0, 0); //is scaled up later
            this.AddAt(0, m_Bg);

            m_PieTree = new UIPieMenuItem()
            {
                Category = true
            };

            for (int i = 0; i < pie.Count; i++)
            {
                string[] depth = (pie[i].Name == null)?new string[] { "???" } :pie[i].Name.Split('/');

                var category = m_PieTree;                  //set category to root
                for (int j = 0; j < depth.Length - 1; j++) //iterate through categories
                {
                    if (category.ChildrenByName.ContainsKey(depth[j]))
                    {
                        category = category.ChildrenByName[depth[j]];
                    }
                    else
                    {
                        var newCat = new UIPieMenuItem()
                        {
                            Category = true,
                            Name     = depth[j],
                            Parent   = category
                        };
                        category.Children.Add(newCat);
                        category.ChildrenByName[depth[j]] = newCat;
                        category = newCat;
                    }
                }
                //we are in the category, put the interaction in here;

                var name     = depth[depth.Length - 1];
                var semiInd  = name.LastIndexOf(';');
                int colorMod = 0;
                if (semiInd > -1)
                {
                    int.TryParse(name.Substring(semiInd + 1), out colorMod);
                    name = name.Substring(0, semiInd);
                }

                var item = new UIPieMenuItem()
                {
                    Category = false,
                    Name     = name,
                    ColorMod = colorMod,
                    ID       = pie[i].ID,
                    Param0   = pie[i].Param0,
                    Global   = pie[i].Global
                };
                category.Children.Add(item);
                category.ChildrenByName[item.Name] = item;
            }

            m_CurrentItem = m_PieTree;
            m_PieButtons  = new List <UIButton>();
            RenderMenu();

            VMAvatar Avatar = (VMAvatar)caller;

            m_Head = new SimAvatar(Avatar.Avatar); //talk about confusing...
            m_Head.StripAllButHead();

            initSimHead();
        }
Exemplo n.º 37
0
 public LispCodeAction(SimAvatar impl, object command)
     : base("ExecuteCommand " + impl + " -> " + command)
 {
     TheBot = (SimControllableAvatar)impl;
     this.command = command;
 }