Ejemplo n.º 1
0
        public static bool doAnimateSpecialMove_Prefix(MeleeWeapon __instance, Farmer ___lastUser)
        {
            context.Monitor.Log($"Special move for {__instance.Name}, id {__instance.InitialParentTileIndex}");

            if (context.Config.RequireModKey && !context.Helper.Input.IsDown(context.Config.ModKey))
            {
                return(true);
            }

            ModEntry.advancedWeaponAnimating = ModEntry.GetAdvancedWeapon(__instance, ___lastUser);

            if (ModEntry.weaponAnimationFrame > -1 || ModEntry.advancedWeaponAnimating == null || !ModEntry.advancedWeaponAnimating.frames.Any())
            {
                return(true);
            }

            if (___lastUser == null || ___lastUser.CurrentTool != __instance)
            {
                return(false);
            }

            context.Monitor.Log($"Animating {__instance.DisplayName}");

            if (___lastUser.isEmoteAnimating)
            {
                ___lastUser.EndEmoteAnimation();
            }
            ModEntry.weaponStartFacingDirection = ___lastUser.getFacingDirection();
            ModEntry.weaponAnimationFrame       = 0;
            ModEntry.weaponAnimating            = __instance;
            return(false);
        }
        /// <summary>
        ///     A method called via Harmony before <see cref="Farmer.performSickAnimation" />.
        ///     It replaces the original method, so we can invoke a callback when the animation ends
        ///     (see <see cref="OnFinishSickAnim" />).
        /// </summary>
        /// <param name="__instance">The farmer instance.</param>
        /// <returns>
        ///     Returns <see langword="false"/> so this method replaces the original method.
        /// </returns>
        private static bool BeforePerformSickAnimation(Farmer __instance)
        {
            if (__instance.isEmoteAnimating)
            {
                __instance.EndEmoteAnimation();
            }

            __instance.isEating = false;

            FarmerData farmerData = FarmerPatcher.FarmersData.GetOrCreateValue(__instance);

            farmerData.IsBeingSick = true;

            __instance.FarmerSprite.animateOnce(224, 350f, 4, FarmerPatcher.OnFinishSickAnim);
            __instance.doEmote(12);

            return(false);
        }