Пример #1
0
        private void OnStuck()
        {
            stuckatMs = entity.World.ElapsedMilliseconds;
            nowStuck  = true;

            FailedAttempt attempt = null;

            failedSeekTargets.TryGetValue(target, out attempt);
            if (attempt == null)
            {
                failedSeekTargets[target] = attempt = new FailedAttempt();
            }

            attempt.Count++;
            attempt.LastTryMs = world.ElapsedMilliseconds;
        }
Пример #2
0
        void onBadTarget()
        {
            IAnimalNest newTarget = null;

            if (attemptLayEggTotalHours >= 0 && entity.World.Calendar.TotalHours - attemptLayEggTotalHours > 12)
            {
                LayEggOnGround();
            }
            else
            {
                if (rand.NextDouble() > 0.4)
                {
                    // Look for another nearby henbox
                    newTarget = FindPOI(18) as IAnimalNest;
                }
            }

            FailedAttempt attempt = null;

            failedSeekTargets.TryGetValue(targetPoi, out attempt);
            if (attempt == null)
            {
                failedSeekTargets[targetPoi] = attempt = new FailedAttempt();
            }

            attempt.Count++;
            attempt.LastTryMs = world.ElapsedMilliseconds;

            if (newTarget != null)
            {
                targetPoi  = newTarget;
                nowStuck   = false;
                sitTimeNow = 0;
                laid       = false;
                pathTraverser.NavigateTo_Async(targetPoi.Position, moveSpeed, MinDistanceToTarget() - 0.1f, OnGoalReached, OnStuck, null, 1000, 1);
                sitAnimStarted = false;
            }
        }