public override void InvokeReal()
        {
            SimActor TheBot = (SimActor)this.TheBot;

            TimeRemaining = rand.Next(1, 3); // one to tree cycles
            while (TimeRemaining-- > 0)
            {
                String use = TypeUsage.UsageName;
                TheBot.Approach(Victem, 5);
                TheBot.Debug(ToString());
                CurrentTopic = TheBot.LastAction;
                TheBot.TalkTo(Victem, CurrentTopic);
                Thread.Sleep(8000);
                //User.ApplyUpdate(use, simObject);
            }
            BotNeeds CurrentNeeds = (BotNeeds)TheBot["CurrentNeeds"];
            BotNeeds needsBefore  = CurrentNeeds.Copy();
            BotNeeds simNeeds     = TypeUsage.ChangeActual;

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

            TheBot.Debug(ToString() + " => " + difNeeds.ShowNonZeroNeeds());
        }
 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();
 }
Exemplo n.º 3
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            SimActor sitter = WorldSystem.TheSimAvatar;

            if (!sitter.IsSitting)
            {
                AddSuccess("$bot is already standing.");
            }
            else
            {
                sitter.StandUp();
                AddSuccess("Standing up.");
                ;
            }
            Client.Self.Stand();
            return(SuccessOrFailure());
        }
Exemplo n.º 4
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string verb = args.CmdName;
            // base.acceptInput(verb, args);
            UUID     primID       = UUID.Zero;
            SimActor TheSimAvatar = this.TheSimAvatar;

            if (verb == "stop-following")
            {
                // SimPosition ap = TheSimAvatar.ApproachPosition;
                if (TheSimAvatar.CurrentAction is MoveToLocation)
                {
                    TheSimAvatar.CurrentAction = null;
                }
                TheSimAvatar.SetMoveTarget(null, 10);
                TheSimAvatar.StopMoving();
            }
            SimPosition position;

            if (!args.TryGetValue("target", out position))
            {
                return(Failure("$bot don't know who " + args.GetString("target") + " is."));
            }
            {
                if (position != null)
                {
                    String str = "" + Client + " start to follow " + position + ".";
                    WriteLine(str);
                    // The thread that accepts the Client and awaits messages
                    TheSimAvatar.CurrentAction = new FollowerAction(TheSimAvatar, position);
                    return(Success("$bot started following " + position));
                }
            }
            {
                return(Success("$bot ApproachPosition: " + TheSimAvatar.CurrentAction));
            }
        }
Exemplo n.º 5
0
 public SimParrotActor(SimActor a) : base(String.Format("AvatarParrot for {0}", a))
 {
     ObservedActor = a;
 }
Exemplo n.º 6
0
 public void SetSimAvatar(SimActor simAvatar)
 {
     TheSimAvatar = (SimAvatarClient)simAvatar;
 }
Exemplo n.º 7
0
        public DefaultWorldGroupProvider(WorldObjects objects)
        {
            world = objects;
            AddObjectGroup("selected", "set of currently selected objects", () =>
            {
                SimActor avatar = this.avatar;
                if (avatar == null)
                {
                    return(null);
                }
                return(avatar.GetSelectedObjects());
            });
            AddObjectGroup("none", "empty list", () => new List <SimObject>());
            AddObjectGroup("assets", "known assets", () => WorldObjects.SimRootObjects.CopyOf());
            AddObjectGroup("objects", "known sim root objects", () =>
                           WorldObjects.SimRootObjects.CopyOf());
            AddObjectGroup("caller", "current command caller", () =>
            {
                UUID callerID = BotClient.SessionToCallerId(
                    objects.client.CurrentCommand.
                    CurrentRequest.CallerAgent);
                if (callerID == UUID.Zero)
                {
                    return(null);
                }
                var o =
                    WorldObjects.GetSimObjectFromUUID(callerID);
                if (o == null)
                {
                    return(null);
                }
                return(SingleNameValue.AsCollection(o));
            });
            AddObjectGroup("prims", "all prims (attached and otherwise and avatars etc)",
                           () => WorldObjects.SimObjects.CopyOf());
            AddObjectGroup("childprims", "known childs rez in world not attachments",
                           () => WorldObjects.SimChildObjects.CopyOf());
            AddObjectGroup("attachments", "known attacments (everyones)",
                           () => WorldObjects.SimAttachmentObjects.CopyOf());
            // all known accounts
            AddObjectGroup("accounts", "known accounts", () => WorldObjects.SimAccounts.CopyOf());
            // all known avatars
            AddObjectGroup("avatars", "known avatars", () => WorldObjects.SimAvatars.CopyOf());
            // this bot's master(s)
            AddObjectGroup("master", "known masters", () =>
            {
                var v = new List <object>();
                if (objects.client.MasterKey != UUID.Zero)
                {
                    v.Add(objects.CreateSimAvatar(
                              objects.client.MasterKey, objects, null));
                }
                else
                {
                    v.Add(objects.client.MasterName);
                }
                return(v);
            });
            // the current bot
            AddObjectGroup("self", "the robot's avatar", () =>
            {
                SimActor avatar = this.avatar;
                if (avatar == null)
                {
                    return(null);
                }
                var v = new List <SimObject> {
                    avatar
                };
                return(v);
            });
            AddObjectGroup("nearest", "nearest root prim", () =>
            {
                var sortme = WorldObjects.SimRootObjects.CopyOf();
                if (sortme.Count == 0)
                {
                    return(null);
                }
                sortme.Sort(this.avatar.CompareDistance);
                var v = new List <SimObject> {
                    sortme[0]
                };
                return(v);
            });
            AddObjectGroup("regionprims",
                           "list of all av's, attachments, and objects in this region used in 'moveprim $regionprims <0,0,-1>'",
                           () =>
            {
                List <SimObject> here = new List <SimObject>();
                SimActor avatar       = this.avatar;
                if (avatar == null)
                {
                    return(null);
                }
                ulong areg = avatar.RegionHandle;
                foreach (SimObject o in WorldObjects.SimObjects.CopyOf())
                {
                    if (o.RegionHandle == areg)
                    {
                        here.Add(o);
                    }
                }
                return(here);
            });
            AddObjectGroup("allprims", "list of all av's, attachments, and objects known to system",
                           () => WorldObjects.SimObjects.CopyOf());

            AddObjectGroup("selfknownprims",
                           "list of all objects that have an affordance or makes sense for the bot to know about",
                           () =>
            {
                SimActor avatar = this.avatar;
                if (avatar == null)
                {
                    return(null);
                }
                return(avatar.GetKnownObjects());
            });
            // the 'current object' - the current object is determined in a complex way
            // but is generally the last object acted upon by the av. it's only allowed to be changed every 30 sec
            // and might be overwritten by aiml.
            // the intent is to support the notion of a pronoun 'it'
            // if the bot's head is free (not being animated) it will look at target
            AddObjectGroup("lasteventprim", "the 'current object' - the current object is determined in a complex way",
                           () =>
            {
                SimActor avatar = this.avatar;
                if (avatar == null)
                {
                    return(null);
                }
                var v = new List <SimPosition>();
                var a = avatar.CurrentAction;
                if (a != null && a.Target != null)
                {
                    v.Add(a.Target);
                    return(v);
                }
                SimPosition p = null;                    // avatar.ApproachPosition;
                if (p != null)
                {
                    v.Add(p);
                    return(v);
                }
                var r = GetTargetInEvent(v, avatar);
                if (r != null)
                {
                    return(r);
                }
                if (objects.client.MasterKey != UUID.Zero)
                {
                    var master = WorldObjects.GetSimObjectFromUUID(objects.client.MasterKey);
                    if (master != null)
                    {
                        return(GetTargetInEvent(v, master));
                    }
                }
                return(null);
            });
        }
Exemplo n.º 8
0
    protected override void Update()
    {
//Debug.LogWarning("Time.deltaTime:"+Time.deltaTime+";_30FPSdeltaTime:"+_30FPSdeltaTime);



        ProcessGameCommands();


        Escape = Input.GetKey(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyUp(KeyCode.Escape);
        foreach (var command in AllCommands)
        {
            UpdateCommandState(command);
        }
        Enabled.PAUSE[0] = (bool)Enabled.PAUSE[0] || Escape || !Focus;
        if ((bool)Enabled.PAUSE[0] != (bool)Enabled.PAUSE[1])
        {
            if ((bool)Enabled.PAUSE[0])
            {
                Cursor.visible   = true;
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
            }
        }
        Enabled.MOUSE_ROTATION_DELTA_X[1] = Enabled.MOUSE_ROTATION_DELTA_X[0]; Enabled.MOUSE_ROTATION_DELTA_X[0] = Commands.ROTATION_SENSITIVITY_X * Input.GetAxis("Mouse X");
        Enabled.MOUSE_ROTATION_DELTA_Y[1] = Enabled.MOUSE_ROTATION_DELTA_Y[0]; Enabled.MOUSE_ROTATION_DELTA_Y[0] = Commands.ROTATION_SENSITIVITY_Y * Input.GetAxis("Mouse Y");


//if(CamControlled==null){
//}else if(CamFollowing is SimActor followed&&followed!=CamControlled){
//}
//if(CamControlled==null){
//if(CamFollowing!=null&&CamFollowing is SimActor followed){
//}else if(CamFollowables.Count>0){
//}
//}


        if (!(bool)Enabled.PAUSE[0])
        {
            if ((bool)Enabled.SWITCH_CAMERA_MODE[0] != (bool)Enabled.SWITCH_CAMERA_MODE[1])
            {
                if ((bool)Enabled.SWITCH_CAMERA_MODE[0])
                {
                    if (CamFollowables.Count > 0)
                    {
                        CamFollowing = CamFollowables.First.Value; CamFollowables.RemoveFirst(); CamFollowables.AddLast(CamFollowing.CamFollowableNode);
                        CamFollowing.BeingCamFollowed = true;
                        Lerp = false;
                        if (LOG && LOG_LEVEL <= 1)
                        {
                            Debug.Log("camera is now following " + CamFollowing.ObjName + "; CamFollowables.Count:" + CamFollowables.Count);
                        }
                    }
                }
                else
                {
                    if (CamFollowing != null)
                    {
                        CamFollowing.BeingCamFollowed = false;
                    }
                    CamFollowing = null;
                    Lerp         = true;
                }


                if (!(CamFollowing is SimActor followed))
                {
                    Debug.LogWarning("followed is invalid to be cam controlled character");
                    CamControlled = null;
                }
                else if (followed != CamControlled)
                {
                    Debug.LogWarning("set followed[" + followed + "] as new cam controlled character");
                    CamControlled = followed;
                }
            }


            if (CamControlled == null && !(CamFollowing is SimActor))
            {
                foreach (var followable in CamFollowables)
                {
                    if (followable is SimActor actor)
                    {
                        Debug.LogWarning("validate cam controlled:set actor[" + actor + "] as new cam controlled character");
                        CamControlled = actor;


                        break;
                    }
                }
            }
//if(CamControlled==null&&CamFollowing==null){
//                    Debug.LogWarning("get new cam controlled character");
//if(CamFollowables.Count>0){
//foreach(var followable in CamFollowables){
//if(followable is SimActor actor){



//}
//}
//}
//}


            if (CamFollowing == null)
            {
                #region FORWARD BACKWARD
                if ((bool)Enabled.FORWARD [0])
                {
                    inputMoveSpeed.z += InputMoveAcceleration.z;
                }
                if ((bool)Enabled.BACKWARD[0])
                {
                    inputMoveSpeed.z -= InputMoveAcceleration.z;
                }
                if (!(bool)Enabled.FORWARD[0] && !(bool)Enabled.BACKWARD[0])
                {
                    inputMoveSpeed.z = 0;
                }
                if (inputMoveSpeed.z > InputMaxMoveSpeed.z)
                {
                    inputMoveSpeed.z = InputMaxMoveSpeed.z;
                }
                if (-inputMoveSpeed.z > InputMaxMoveSpeed.z)
                {
                    inputMoveSpeed.z = -InputMaxMoveSpeed.z;
                }
                #endregion
                #region RIGHT LEFT
                if ((bool)Enabled.RIGHT   [0])
                {
                    inputMoveSpeed.x += InputMoveAcceleration.x;
                }
                if ((bool)Enabled.LEFT    [0])
                {
                    inputMoveSpeed.x -= InputMoveAcceleration.x;
                }
                if (!(bool)Enabled.RIGHT[0] && !(bool)Enabled.LEFT[0])
                {
                    inputMoveSpeed.x = 0;
                }
                if (inputMoveSpeed.x > InputMaxMoveSpeed.x)
                {
                    inputMoveSpeed.x = InputMaxMoveSpeed.x;
                }
                if (-inputMoveSpeed.x > InputMaxMoveSpeed.x)
                {
                    inputMoveSpeed.x = -InputMaxMoveSpeed.x;
                }
                #endregion
                #region ROTATE
                inputViewRotationEuler.x += -Enabled.MOUSE_ROTATION_DELTA_Y[0] * InputViewRotationIncreaseSpeed;
                inputViewRotationEuler.y += Enabled.MOUSE_ROTATION_DELTA_X[0] * InputViewRotationIncreaseSpeed;
                inputViewRotationEuler.x  = inputViewRotationEuler.x % 360;
                inputViewRotationEuler.y  = inputViewRotationEuler.y % 360;
                #endregion
            }
            else
            {
                inputMoveSpeed = Vector3.zero;
                tgtRot         = Quaternion.LookRotation(CamFollowing.CamLookAtForward, CamFollowing.CamLookAtUp).eulerAngles; tgtPos = CamFollowing.CamPosition;
            }
        }
Exemplo n.º 9
0
        public void InvokeReal(SimActor TheBot)
        {
   
            String use = TypeUsage.UsageName;

            // Create the Side-Effect closure
            ThreadStart closure = new ThreadStart(delegate()
                                                      {
                                                          InvokeBotSideEffect(TheBot);
                                                      });

            SimAssetStore simAssetSystem = SimAssetStore.TheStore;
            bool animFound = TypeUsage.UseSit;
            // IF UseAnim was specified
            if (!String.IsNullOrEmpty(TypeUsage.UseAnim))
            {
                UUID animID = simAssetSystem.GetAssetUUID(TypeUsage.UseAnim, AssetType.Animation);
                if (animID != UUID.Zero)
                {
                    closure = TheBot.WithAnim(animID, closure);
                    animFound = true;
                }
            }
            // else
            if (!animFound)
            {
                //ELSE look for Verb coverage for an anim
                UUID animID = simAssetSystem.GetAssetUUID(use, AssetType.Animation);
                if (animID != UUID.Zero)
                    closure = TheBot.WithAnim(animID, closure);
            }

            // Surround with tough/grab if needed
            if (use == "touch" || use == "grab" || TypeUsage.UseGrab)
                closure = TheBot.WithGrabAt(Target, closure);

            // Surround with Sit if needed
            if (use == "sit" || TypeUsage.UseSit)
                closure = TheBot.WithSitOn(Target, closure);


            // Approach Target
            try
            {
                double maximumDistance = TypeUsage.maximumDistance + Target.GetSizeDistance();
                double howClose = TheBot.Approach(Target, maximumDistance - 0.5);
                ((SimAvatarImpl)TheBot).ApproachVector3D = Target.GlobalPosition;
                TheBot.TurnToward(Target);
                if (howClose > maximumDistance + 1)
                {
                    Debug(TheBot, "Too far away " + howClose + " from " + this);
                    return;
                }
                Target.PathFinding.MakeEnterable(TheBot);
                closure.Invoke();
                //if (Target == TheBot.ApproachPosition)
               // {
                 //   ((SimAvatarImpl) TheBot).ApproachPosition = null;
                 //   TheBot.StopMoving();
                //}
            }
            finally
            {
                Target.PathFinding.RestoreEnterable(TheBot);
            }
        }
        public void InvokeReal(SimActor TheBot)
        {
            String use = TypeUsage.UsageName;

            // Create the Side-Effect closure
            ThreadStart closure = new ThreadStart(delegate()
            {
                InvokeBotSideEffect(TheBot);
            });

            SimAssetStore simAssetSystem = SimAssetStore.TheStore;
            bool          animFound      = TypeUsage.UseSit;

            // IF UseAnim was specified
            if (!String.IsNullOrEmpty(TypeUsage.UseAnim))
            {
                UUID animID = simAssetSystem.GetAssetUUID(TypeUsage.UseAnim, AssetType.Animation);
                if (animID != UUID.Zero)
                {
                    closure   = TheBot.WithAnim(animID, closure);
                    animFound = true;
                }
            }
            // else
            if (!animFound)
            {
                //ELSE look for Verb coverage for an anim
                UUID animID = simAssetSystem.GetAssetUUID(use, AssetType.Animation);
                if (animID != UUID.Zero)
                {
                    closure = TheBot.WithAnim(animID, closure);
                }
            }

            // Surround with tough/grab if needed
            if (use == "touch" || use == "grab" || TypeUsage.UseGrab)
            {
                closure = TheBot.WithGrabAt(Target, closure);
            }

            // Surround with Sit if needed
            if (use == "sit" || TypeUsage.UseSit)
            {
                closure = TheBot.WithSitOn(Target, closure);
            }


            // Approach Target
            try
            {
                double maximumDistance = TypeUsage.maximumDistance + Target.GetSizeDistance();
                double howClose        = TheBot.Approach(Target, maximumDistance - 0.5);
                ((SimAvatarImpl)TheBot).ApproachVector3D = Target.GlobalPosition;
                TheBot.TurnToward(Target);
                if (howClose > maximumDistance + 1)
                {
                    Debug(TheBot, "Too far away " + howClose + " from " + this);
                    return;
                }
                Target.PathFinding.MakeEnterable(TheBot);
                closure.Invoke();
                //if (Target == TheBot.ApproachPosition)
                // {
                //   ((SimAvatarImpl) TheBot).ApproachPosition = null;
                //   TheBot.StopMoving();
                //}
            }
            finally
            {
                Target.PathFinding.RestoreEnterable(TheBot);
            }
        }
Exemplo n.º 11
0
 public SimParrotActor(SimActor a) : base(String.Format("AvatarParrot for {0}", a))
 {
     ObservedActor = a;
 }
Exemplo n.º 12
0
 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();
 }