Esempio n. 1
0
            static bool Prefix(HornGadget __instance, LocalPlayerControlledCar carLogicLocal, InputStates inputStates, float dt)
            {
                var  playerEvents = __instance.GetType().GetField("playerEvents_", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) as PlayerEvents;
                bool isPressed_   = inputStates.GetState(InputAction.Horn).isPressed_;
                bool isReleased_  = inputStates.GetState(InputAction.Horn).isReleased_;

                if (isPressed_)
                {
                    Entry.buttonDownTimer_ += dt;
                }

                if (Entry.buttonReleasedSinceLastHornTriggered_ && (Entry.buttonDownTimer_ >= __instance.maxButtonDownTime_ || isReleased_))
                {
                    float percent = Mathf.InverseLerp(0f, __instance.maxButtonDownTime_, Entry.buttonDownTimer_);
                    if (Entry.buttonDownTimer_ >= __instance.maxButtonDownTime_)
                    {
                        percent = stupidBubble;
                    }
                    else
                    {
                        percent *= multiplier;
                    }
                    Entry.buttonReleasedSinceLastHornTriggered_ = false;
                    Vector3 vector = __instance.transform.position;
                    vector += __instance.transform.lossyScale.z * __instance.bubbleOffset_;
                    playerEvents.Broadcast <Horn.Data>(new Horn.Data(percent, vector));
                }
                if (isReleased_)
                {
                    Entry.buttonReleasedSinceLastHornTriggered_ = true;
                    Entry.buttonDownTimer_ = 0f;
                }
                return(false);
            }