Exemple #1
0
 public bool SortSubmergedObjects(IItemOfInterest seeker, double interestInterval, out SubmergedObject subjergedObject)
 {
     subjergedObject = null;
     for (int i = SubmergedObjects.LastIndex(); i >= 0; i--)
     {
         SubmergedObject subObj = SubmergedObjects [i];
         if (subObj == null || subObj.Target == null || subObj.Target.Destroyed || (subObj.Target.IOIType == ItemOfInterestType.WorldItem && subObj.Target.worlditem.Is <WaterTrap> ()))
         {
             SubmergedObjects.RemoveAt(i);
         }
         else
         {
             subObj.Seeker = seeker;
             if (subObj.Target.IOIType == ItemOfInterestType.Scenery)
             {
                 //it's probably a fish or something
                 //there's a very low probability that we care
                 if (UnityEngine.Random.value < 0.0005f)
                 {
                     subObj.IsOfInterest = true;
                 }
                 else
                 {
                     subObj.IsOfInterest = false;
                     SubmergedObjects.RemoveAt(i);
                 }
             }
             else if (subObj.HasExitedWater && (WorldClock.AdjustedRealTime - subObj.TimeExitedWater) > interestInterval)
             {
                 //just in case we're already targeting a submerged object
                 subObj.IsOfInterest = false;
                 SubmergedObjects.RemoveAt(i);
             }
             else if (subObj.Target.IOIType == ItemOfInterestType.Player && subObj.Target.player.IsDead)
             {
                 subObj.IsOfInterest = false;
                 SubmergedObjects.RemoveAt(i);
             }
             else if (subObj.Target.Position.y > Biomes.Get.TideWaterElevation)
             {
                 //if the target's position is higher than the water position then it can't be underwater
                 subObj.IsOfInterest = true;
                 SubmergedObjects.RemoveAt(i);
             }
             else
             {
                 subObj.IsOfInterest = true;
             }
         }
     }
     if (SubmergedObjects.Count > 0)
     {
         SubmergedObjects.Sort();
         if (SubmergedObjects [0].IsOfInterest)
         {
             subjergedObject = SubmergedObjects [0];
         }
     }
     return(subjergedObject != null);
 }
Exemple #2
0
        public void OnItemOfInterestExitWater()
        {
            IItemOfInterest target = SubmergeTrigger.LastExitedItemOfInterest;

            for (int i = SubmergedObjects.Count - 1; i >= 0; i--)
            {
                if (SubmergedObjects [i].Target == target)
                {
                    SubmergedObjects [i].TimeExitedWater = (float)WorldClock.AdjustedRealTime;
                    SubmergedObjects.RemoveAt(i);
                    break;
                }
            }
        }