Ejemplo n.º 1
0
        public static bool OnCaughtObject(AnglerfishController __instance,
                                          OWRigidbody caughtBody)
        {
            var qsbAngler = __instance.GetWorldObject <QSBAngler>();

            if (__instance._currentState == AnglerfishController.AnglerState.Consuming)
            {
                if (!qsbAngler.TargetTransform.CompareTag("Player") && caughtBody.CompareTag("Player"))
                {
                    Locator.GetDeathManager().KillPlayer(DeathType.Digestion);
                }

                return(false);
            }

            if (caughtBody.CompareTag("Player") || caughtBody.CompareTag("Ship"))
            {
                qsbAngler.TargetTransform    = caughtBody.transform;
                __instance._consumeStartTime = Time.time;
                __instance.ChangeState(AnglerfishController.AnglerState.Consuming);
                qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static bool OnSectorOccupantRemoved(AnglerfishController __instance,
                                                   SectorDetector sectorDetector)
        {
            var qsbAngler = __instance.GetWorldObject <QSBAngler>();

            if (qsbAngler.TargetTransform != null && sectorDetector.GetAttachedOWRigidbody().transform == qsbAngler.TargetTransform)
            {
                qsbAngler.TargetTransform = null;
                __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static bool OnClosestAudibleNoise(AnglerfishController __instance,
                                                 NoiseMaker noiseMaker)
        {
            var qsbAngler = __instance.GetWorldObject <QSBAngler>();

            if (__instance._currentState is AnglerfishController.AnglerState.Consuming or AnglerfishController.AnglerState.Stunned)
            {
                return(false);
            }

            if ((noiseMaker.GetNoiseOrigin() - __instance.transform.position).sqrMagnitude < __instance._pursueDistance * __instance._pursueDistance)
            {
                if (qsbAngler.TargetTransform != noiseMaker.GetAttachedBody().transform)
                {
                    qsbAngler.TargetTransform = noiseMaker.GetAttachedBody().transform;
                    if (__instance._currentState != AnglerfishController.AnglerState.Chasing)
                    {
                        __instance.ChangeState(AnglerfishController.AnglerState.Chasing);
                    }

                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                    return(false);
                }
            }
            else if (__instance._currentState is AnglerfishController.AnglerState.Lurking or AnglerfishController.AnglerState.Investigating)
            {
                __instance._localDisturbancePos = __instance._brambleBody.transform.InverseTransformPoint(noiseMaker.GetNoiseOrigin());
                if (__instance._currentState != AnglerfishController.AnglerState.Investigating)
                {
                    __instance.ChangeState(AnglerfishController.AnglerState.Investigating);
                }

                qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
            }

            return(false);
        }
Ejemplo n.º 4
0
        public static bool OnImpact(AnglerfishController __instance,
                                    ImpactData impact)
        {
            var qsbAngler = __instance.GetWorldObject <QSBAngler>();

            var attachedOWRigidbody = impact.otherCollider.GetAttachedOWRigidbody();

            if ((attachedOWRigidbody.CompareTag("Player") || attachedOWRigidbody.CompareTag("Ship")) &&
                __instance._currentState != AnglerfishController.AnglerState.Consuming &&
                __instance._currentState != AnglerfishController.AnglerState.Stunned)
            {
                qsbAngler.TargetTransform = attachedOWRigidbody.transform;
                __instance.ChangeState(AnglerfishController.AnglerState.Chasing);
                qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                return(false);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static bool UpdateState(AnglerfishController __instance)
        {
            if (!QSBWorldSync.AllObjectsReady)
            {
                return(true);
            }

            var qsbAngler = __instance.GetWorldObject <QSBAngler>();

            switch (__instance._currentState)
            {
            case AnglerfishController.AnglerState.Investigating:
                if ((__instance._brambleBody.transform.TransformPoint(__instance._localDisturbancePos) - __instance._anglerBody.GetPosition()).sqrMagnitude < __instance._arrivalDistance * __instance._arrivalDistance)
                {
                    __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                    return(false);
                }

                break;

            case AnglerfishController.AnglerState.Chasing:
                if (qsbAngler.TargetTransform == null)
                {
                    __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                    return(false);
                }

                if ((qsbAngler.TargetTransform.position - __instance._anglerBody.GetPosition()).sqrMagnitude > __instance._escapeDistance * __instance._escapeDistance)
                {
                    qsbAngler.TargetTransform = null;
                    __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                    return(false);
                }

                break;

            case AnglerfishController.AnglerState.Consuming:
                if (!__instance._consumeComplete)
                {
                    if (qsbAngler.TargetTransform == null)
                    {
                        __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                        qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                        return(false);
                    }

                    var num = Time.time - __instance._consumeStartTime;
                    if (qsbAngler.TargetTransform.CompareTag("Player") && num > __instance._consumeDeathDelay)
                    {
                        Locator.GetDeathManager().KillPlayer(DeathType.Digestion);
                        __instance._consumeComplete = true;
                        return(false);
                    }

                    if (qsbAngler.TargetTransform.CompareTag("Ship"))
                    {
                        if (num > __instance._consumeShipCrushDelay)
                        {
                            qsbAngler.TargetTransform.GetComponentInChildren <ShipDamageController>().TriggerSystemFailure();
                        }

                        if (num > __instance._consumeDeathDelay)
                        {
                            if (PlayerState.IsInsideShip())
                            {
                                Locator.GetDeathManager().KillPlayer(DeathType.Digestion);
                            }

                            __instance._consumeComplete = true;
                            return(false);
                        }
                    }
                }
                else
                {
                    qsbAngler.TargetTransform = null;
                    __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                }

                break;

            case AnglerfishController.AnglerState.Stunned:
                __instance._stunTimer -= Time.deltaTime;
                if (__instance._stunTimer <= 0f)
                {
                    if (qsbAngler.TargetTransform != null)
                    {
                        __instance.ChangeState(AnglerfishController.AnglerState.Chasing);
                        qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                        return(false);
                    }

                    __instance.ChangeState(AnglerfishController.AnglerState.Lurking);
                    qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler));
                }

                break;

            default:
                return(false);
            }

            return(false);
        }