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());
        }
예제 #2
0
        public void DoBestUse(SimObject someObject)
        {
            if (someObject == null)
            {
                return;
            }
            SimTypeUsage use = someObject.Affordances.GetBestUse(CurrentNeeds);

            if (use == null)
            {
                double closeness = Actor.Approach(someObject, someObject.GetSizeDistance() + 1);
                //AgentManager ClientSelf = Client.Self;
                Actor.Touch(someObject);
                if (closeness < 3)
                {
                    Actor.SitOn(someObject);
                }
                return;
            }
            Actor.Do(use, someObject);
            return;
        }
예제 #3
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);
            }
        }