public override bool Run() { bool result = false; IPond nearestWater = GetNearestWater(Actor.Position, float.MaxValue); if (nearestWater == null) { return(false); } ulong notUsed = 10u; // Not used by the method. I don't know what it was supposed to be. if (!DrinkFromPondHelper.RouteToDrinkLocation(nearestWater.RepresentativePondPosition(), Actor, GameObjectHitType.WaterPond, notUsed)) { return(false); } mossBall = GlobalFunctions.CreateObjectOutOfWorld("petToyBallFoil", ProductVersion.EP5); //bool isChaining = Actor.CurrentInteraction is ITendGarden; mossBall.SetColorTint(74, 93, 35, 0); // RGB value for Dark Moss Green mossBall.AddToWorld(); mossBall.SetPosition(Actor.Position); CarryUtils.Acquire(Actor, mossBall); EnterCarry(Actor, mossBall); CarryUtils.Request(Actor, "PickUp"); CarryUtils.Request(Actor, "Carry"); //if (!PetCarrySystem.PickUpWithoutRouting(Actor, mossBall as IPetCarryable)) // { // return false; // } EnterStateMachine("DrinkFromPond", "Enter", "x"); AnimateSim("Loop"); AnimateSim("Loop"); AnimateSim("Exit"); if (Target.RouteSimToMeAndCheckInUse(Actor) && WaterTestDisregardGardeningSkill(Target, Actor)) { ConfigureInteraction(); //TryConfigureTendGardenInteraction(Actor.CurrentInteraction); result = DoWater(); } CarryUtils.Request(Actor, "PutDown"); CarryUtils.ExitCarry(Actor); mossBall.Destroy(); //if (IsChainingPermitted(flag)) //{ // IgnorePlants.Add(Target); // if (flag2) // { // PushNextInteractionInChain(Singleton, WaterTest, Target.LotCurrent); // } // else // { // PushNextInteractionInChain(Singleton, WaterTestDisregardGardeningSkill, Target.LotCurrent); // } //} return(result); }
public static IPond GetNearestWater(Vector3 starting_point, float max_distance) { IPond result = null; float nearest_distance = max_distance; IPond[] ponds = Sims3.Gameplay.Queries.GetObjects <IPond>(); foreach (IPond DHMOLocation in ponds) { float pond_distance = (starting_point - ((GameObject)DHMOLocation).Position).LengthSqr(); if (pond_distance < nearest_distance) { result = DHMOLocation; nearest_distance = pond_distance; } } return(result); }