Exemplo n.º 1
0
            private static IEnumerator FishJump(FishingSystem_t instance)
            {
                for (; ;)
                {
                    Fish_t fish = (Fish_t)instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(instance);

                    flatPos = Vector3.MoveTowards(flatPos, Module <Player> .Self.actor.gamePos, settings.JumpSpeed);

                    Vector3 playerPos = Module <Player> .Self.actor.gamePos;

                    float travelled = Vector3.Distance(flatPos, origPos);
                    float total     = Vector3.Distance(playerPos, origPos);

                    float height = (float)Math.Sin(travelled * Math.PI / total) * settings.JumpHeight;

                    try
                    {
                        fish.gameObject.transform.position = new Vector3(flatPos.x, flatPos.y + height, flatPos.z);
                    }
                    catch
                    {
                        break;
                    }


                    if (Vector3.Distance(Module <Player> .Self.actor.gamePos, fish.gameObject.transform.position) < settings.JumpSpeed * 20)
                    {
                        Module <Player> .Self.actor.TryDoAction(ACType.Animation, ACTAnimationPara.Construct("Throw_2", null, null, false));
                    }

                    if (Vector3.Distance(Module <Player> .Self.actor.gamePos, fish.gameObject.transform.position) < settings.JumpSpeed)
                    {
                        typeof(FishingSystem_t).GetMethod("FishingEnd", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(instance, new object[] { true, false });
                        break;
                    }
                    yield return(null);
                }
            }
Exemplo n.º 2
0
        private static void OnWakeUp(object[] obj)
        {
            if (!enabled)
            {
                return;
            }

            if (Module <GlobleBlackBoard> .Self.HasInfo("pennyleave"))
            {
                if (!Module <GlobleBlackBoard> .Self.HasInfo("pennycomebackagain"))
                {
                    Module <GlobleBlackBoard> .Self.SetInfo("pennycomebackagain", "1");

                    Module <FavorManager> .Self.GainFavorValue(PennyID, -1, 600);
                }

                Vector3 position = new Vector3(225.5f, 48.0f, -94.5f);
                Vector3 rot      = new Vector3(0f, -90f, 0f);
                Actor   actor    = StoryHelper.GetActor(PennyID, string.Empty);

                //Module<SceneItemManager>.Self.CreateWithSceneFlag((SceneItemType)0, 168510, "Mission/Mission_pennyshow", "Main", "show_taizi", "0", false, AssetType.Mission);

                if (actor == null)
                {
                    actor = Module <NpcRepository> .Self.CreateNpc(4000141);
                }
                if (actor != null)
                {
                    actor.ClearActionQueue();
                    actor.DoCommand(ACType.Transfer, ACTransferPara.Construct("Main", position, rot));
                    actor.gamePos = position;
                    //actor.SetAiActive(true);
                    actor.DoCommand(ACType.Animation, ACTAnimationPara.Construct("AlwaysGuitar", null, null, false));
                    //actor.SetBehaviorState(BehaveState.Default);
                }
            }
        }
Exemplo n.º 3
0
        private static void TimerCallback(object state)
        {
            double currentTime = Module <TimeManager> .Self.TotalSecond / Module <TimeManager> .Self.TimeScale;

            foreach (KeyValuePair <int, double> k in kissingSpouses)
            {
                if (k.Value + 6 < currentTime)
                {
                    Actor a = ActorMgr.Self.Get(k.Key);
                    if (a != null)
                    {
                        ResetOneSpouseAnimation(a);
                    }
                }
            }

            if (!enabled || !settings.SpousesKiss || Module <ScenarioModule> .Self.CurrentScenarioName == "Main" || Module <ScenarioModule> .Self.CurrentScenarioName == "food")
            {
                return;
            }

            double nextKissTime = lastKiss + settings.MinKissingInterval;

            if (currentTime < nextKissTime)
            {
                return;
            }

            List <FavorObject> spouseList  = GetSpouses();
            List <Actor>       aSpouseList = new List <Actor>();

            aSpouseList.Add(Module <Player> .Self.actor);

            foreach (FavorObject f in spouseList)
            {
                Actor a = ActorMgr.Self.Get(f.ID);
                if (a == null)
                {
                    continue;
                }

                if (a.InActiveScene)
                {
                    aSpouseList.Add(a);
                }
            }

            int n = aSpouseList.Count;

            while (n > 1)
            {
                n--;
                int   k     = rand.Next(n + 1);
                Actor value = aSpouseList[k];
                aSpouseList[k] = aSpouseList[n];
                aSpouseList[n] = value;
            }

            foreach (Actor a in aSpouseList)
            {
                if (currentTime < nextKissTime)
                {
                    break;
                }

                if (!a.CanInteract || a.InBattle || !a.Visible || a.IsActionRunning(ACType.Sleep) || a.IsActionRunning(ACType.Sit) || a.IsActionRunning(ACType.Conversation) || a.IsActionRunning(ACType.Interact) || kissingSpouses.ContainsKey(a.InstanceId) || Module <EGMgr> .Self.IsEngagementEvent(a.InstanceId) || a.OnBus || a.IsInteractive())
                {
                    continue;
                }
                Vector3 pos1 = a.gamePos;
                foreach (Actor ao in aSpouseList)
                {
                    if (ao.InstanceId == a.InstanceId || !ao.CanInteract || ao.InBattle || !ao.Visible || ao.IsActionRunning(ACType.Sleep) || ao.IsActionRunning(ACType.Sit) || ao.IsActionRunning(ACType.Conversation) || ao.IsActionRunning(ACType.Interact) || kissingSpouses.ContainsKey(ao.InstanceId) || Module <EGMgr> .Self.IsEngagementEvent(ao.InstanceId) || ao.OnBus || ao.IsInteractive())
                    {
                        continue;
                    }
                    Vector3 pos2 = ao.gamePos;
                    float   dist = Vector3.Distance(pos1, pos2);

                    if (dist < settings.MaxKissingDistance)
                    {
                        int maxR   = Math.Max(50 - Math.Max(((int)Math.Round(currentTime - nextKissTime) - settings.MinKissingInterval), 0), 2);
                        int chance = new IntR(1, maxR).GetValue(rand);

                        if (chance != 1)
                        {
                            continue;
                        }

                        float _radiusSelf = a.GetActorRadius();
                        float _radiusTar  = ao.GetActorRadius();
                        float num         = (Module <NpcRepository> .Self.GetNpcGender(a.InstanceId) != Gender.Male) ? .17f : .19f;
                        if (a.InstanceId == Module <Player> .Self.actor.InstanceId || ao.InstanceId == Module <Player> .Self.actor.InstanceId)
                        {
                            num = (Module <Player> .Self.GetGender() != Gender.Male) ? -0.05f : -0.03f;
                        }
                        float _dis = _radiusSelf + _radiusTar + num;

                        Vector3 _tarDir = ao.gamePos - a.gamePos;
                        _tarDir.y = 0f;
                        Vector3 tarPos;
                        if (Module <ScenarioModule> .Self.CurrentScenarioName == "Main")
                        {
                            Util.TryGetGroundPosition(out tarPos, a.gamePos, _tarDir, _dis, 3f, 3f, true, 0.1f, _radiusTar, 36);
                        }
                        else
                        {
                            Util.TryGetGroundPosition(out tarPos, a.gamePos, _tarDir, _dis, 2f, 2f, true, 0.1f, _radiusTar, 36);
                        }

                        float y = Mathf.Max(a.gamePos.y, tarPos.y);

                        Vector3 apos = a.gamePos;
                        Vector3 arot = a.gameRot.eulerAngles;

                        Vector3 _sefPos = a.gamePos;
                        _sefPos.y = y;
                        Vector3 _tarPos = tarPos;
                        _tarPos.y = y;
                        Vector3 _sefRot = Quaternion.LookRotation(_tarPos - _sefPos, Vector3.up).eulerAngles;
                        Vector3 _tarRot = Quaternion.LookRotation(_sefPos - _tarPos, Vector3.up).eulerAngles;
                        Vector3 vector  = (_sefPos + _tarPos) * 0.5f;
                        if (a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, _sefPos, _sefRot)))
                        {
                            if (ao.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, _tarPos, _tarRot)))
                            {
                                a.StopAction(ACType.Animation, false);
                                if (a.TryDoAction(ACType.Animation, ACTAnimationPara.Construct(animName, null, null, true)))
                                {
                                    ao.StopAction(ACType.Animation, false);
                                    if (ao.TryDoAction(ACType.Animation, ACTAnimationPara.Construct(animName, null, null, true)))
                                    {
                                        kissLocations.Add(ao.gamePos - a.gamePos);     // add location for audio

                                        kissingSpouses.Add(a.InstanceId, currentTime); // for resetting animations
                                        kissingSpouses.Add(ao.InstanceId, currentTime);

                                        lastKiss = currentTime; // reset timer for kissing

                                        // start animating
                                        a.AddGravityEffector(turnOffGravity);
                                        a.StartInteraction(FullBodyBipedEffector.LeftHand, ao.GetInteractionObject(iKName), true);
                                        a.StartInteraction(FullBodyBipedEffector.RightHand, ao.GetInteractionObject(iKName), true);

                                        ao.AddGravityEffector(turnOffGravity);
                                        ao.StartInteraction(FullBodyBipedEffector.LeftHand, a.GetInteractionObject(iKName), true);
                                        ao.StartInteraction(FullBodyBipedEffector.RightHand, a.GetInteractionObject(iKName), true);

                                        break;
                                    }
                                    else
                                    {
                                        ResetOneSpouseAnimation(a);
                                        a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, apos, arot));
                                    }
                                }
                            }
                            else
                            {
                                a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, apos, arot));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
            static bool Prefix(FishingSystem_t __instance, FishInfo ___fishInfo, Transform ___shoal, IFishingMan ___fishingMan, ref MoveArea ___area, FishingInfo ___fishingAreaInfo, float ___fishSpeedBaseFactor, float ___fishDashBaseFactor, float ___fishWaitBaseFactor, FishingUI_t ___hud)
            {
                if (!enabled)
                {
                    if (origBaitID != -1)
                    {
                        OtherConfig.Self.BaitID = origBaitID;
                    }
                    return(true);
                }
                Dbgl("Wait for fish");

                if (OtherConfig.Self.BaitID != -1)
                {
                    origBaitID = OtherConfig.Self.BaitID;
                    OtherConfig.Self.BaitID = -1;
                }

                Fish_t fish = null;

                if (string.IsNullOrEmpty(___fishInfo.fishPrefabPath))
                {
                    UnityEngine.Debug.LogError("fishPrefabPath = is null!");
                }
                else
                {
                    GameObject original = Singleton <ResMgr> .Instance.LoadSync <GameObject>(___fishInfo.fishPrefabPath, false, false);

                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(original, ___fishInfo.FishBornTrans.position, Quaternion.identity);
                    gameObject.transform.parent     = ___shoal;
                    gameObject.transform.localScale = Vector3.one;
                    gameObject.SetActive(true);
                    fish = gameObject.GetComponent <Fish_t>();
                }
                if (fish != null)
                {
                    Vector3 vector = ___fishInfo.FishBornTrans.position - ___fishingMan.Pos;
                    ___area               = new MoveArea();
                    ___area.angle         = ___fishingAreaInfo.angleLimit / 2f;
                    ___area.dir           = vector.normalized;
                    ___area.fishingManPos = ___fishingMan.Pos;
                    ___fishInfo.GenPowerFactor(fish.PowerValue);
                    ___fishInfo.GenSpeedFactor(fish.SpeedValue, ___fishSpeedBaseFactor);
                    ___fishInfo.GenAngerFactor(fish.AngerValue, ___fishDashBaseFactor);
                    ___fishInfo.GenTenacityFactor(fish.TenacityValue);
                    ___fishInfo.SetBaseWaitTime(___fishWaitBaseFactor);
                    fish.SetFishInfo(___fishInfo);
                }

                if (settings.PlayHereFishy && fishyClip != null)
                {
                    PlayClip(fishyClip, settings.HereFishyVolume, false);
                }

                Singleton <TaskRunner> .Self.RunDelayTask(fishyClip.length, true, delegate
                {
                    if (___hud == null)
                    {
                        return;
                    }

                    if (fish != null)
                    {
                        if (settings.PlayWee && weeClip != null)
                        {
                            PlayClip(weeClip, settings.WeeVolume, true, fish.transform);
                        }
                        __instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, fish);
                        origPos = (__instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance) as Fish_t).gameObject.transform.position;
                        flatPos = origPos;
                        Singleton <TaskRunner> .Self.StartCoroutine(FishJump(__instance));
                    }
                    else
                    {
                        Module <Player> .Self.actor.TryDoAction(ACType.Animation, ACTAnimationPara.Construct("Throw_2", null, null, false));

                        typeof(FishingSystem_t).GetMethod("FishingEnd", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true, false });
                    }
                    //__instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, __instance.GetType().GetMethod("CreateFish", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[0]));
                    //typeof(FishingSystem_t).GetMethod("FishingBegin", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
                });

                return(false);
            }
Exemplo n.º 5
0
        public static void DoInteract(Actor a, Actor ao, int anim)
        {
            if ((!teeterGameRunning && !CanInteract(a, ao)) || (anim == 1 && Module <ActorMgr> .Self.GetActorInfo(ao.TmpltId).modelType == "Npc_Little"))
            {
                return;
            }

            string animName = Interacts[anim];

            Dbgl($"DoInteract: animName {animName} modelType {Module<ActorMgr>.Self.GetActorInfo(a.TmpltId).modelType} {Module<ActorMgr>.Self.GetActorInfo(ao.TmpltId).modelType}");
            if (Module <ActorMgr> .Self.GetActorInfo(ao.TmpltId).modelType == "0")
            {
                animName = CheckPet(ao, animName);
                Dbgl($"pet anim: {animName}");
            }

            bool   isTall    = animName == "Interact_Kiss" && (Module <ActorMgr> .Self.GetActorInfo(a.TmpltId).modelType == "Npc_Tall" || Module <ActorMgr> .Self.GetActorInfo(ao.TmpltId).modelType == "Npc_Tall");
            string mAnimName = animName;

            if (isTall)
            {
                mAnimName += "_Tall";
            }


            Vector3 pos1 = a.gamePos;
            Vector3 pos2 = ao.gamePos;

            float dist = Vector3.Distance(pos1, pos2);

            float _radiusSelf = a.GetActorRadius();
            float _radiusTar  = ao.GetActorRadius(); //0.25, 0.28 if tall

            float num = GetDistance(ao, animName);

            float _dis = _radiusSelf + _radiusTar + num;

            Vector3 _tarDir = ao.gamePos - a.gamePos;

            _tarDir.y = 0f;
            Vector3 tarPos;

            if (Module <ScenarioModule> .Self.CurrentScenarioName == "Main")
            {
                Util.TryGetGroundPosition(out tarPos, a.gamePos, _tarDir, _dis, 3f, 3f, true, 0.1f, _radiusTar, 36);
            }
            else
            {
                Util.TryGetGroundPosition(out tarPos, a.gamePos, _tarDir, _dis, 2f, 2f, true, 0.1f, _radiusTar, 36);
            }

            float y = Mathf.Max(a.gamePos.y, tarPos.y);

            Vector3 apos = a.gamePos;
            Vector3 arot = a.gameRot.eulerAngles;

            Vector3 aopos = ao.gamePos;
            Vector3 aorot = ao.gameRot.eulerAngles;

            Vector3 _sefPos = a.gamePos;

            _sefPos.y = y;
            Vector3 _tarPos = tarPos;

            _tarPos.y = y;
            Vector3 _sefRot = Quaternion.LookRotation(_tarPos - _sefPos, Vector3.up).eulerAngles;
            Vector3 _tarRot = Quaternion.LookRotation(_sefPos - _tarPos, Vector3.up).eulerAngles;
            Vector3 vector  = (_sefPos + _tarPos) * 0.5f;

            if (a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, _sefPos, _sefRot)))
            {
                if (ao.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, _tarPos, _tarRot)))
                {
                    a.StopAction(ACType.Animation, false);
                    if (a.TryDoAction(ACType.Animation, ACTAnimationPara.Construct(mAnimName, null, null, true)))
                    {
                        ao.StopAction(ACType.Animation, false);
                        if (ao.TryDoAction(ACType.Animation, ACTAnimationPara.Construct(mAnimName, null, EndAnimation, true)))
                        {
                            actorPairs.Add(new AnimationPair(animName, a, ao));
                            a.SetHoldingObjVisible(false);
                            ao.SetHoldingObjVisible(false);

                            isInteracting = true;

                            if (animName == "Hug")
                            {
                                Dbgl("started hugging");
                                isHugging = true;
                                hugTargets.Add(a);
                                hugTargets.Add(ao);
                                targetTime = settings.HugTime;
                            }

                            // start animating
                            a.AddGravityEffector(turnOffGravity);
                            a.StartInteraction(FullBodyBipedEffector.LeftHand, ao.GetInteractionObject(iKNames[animName]), true);
                            a.StartInteraction(FullBodyBipedEffector.RightHand, ao.GetInteractionObject(iKNames[animName]), true);

                            ao.AddGravityEffector(turnOffGravity);
                            ao.StartInteraction(FullBodyBipedEffector.LeftHand, a.GetInteractionObject(iKNames[animName]), true);
                            ao.StartInteraction(FullBodyBipedEffector.RightHand, a.GetInteractionObject(iKNames[animName]), true);

                            return;
                        }
                        else
                        {
                            if (actorPairs.Count > 0)
                            {
                                actorPairs.RemoveAt(actorPairs.Count - 1);
                            }
                            ResetOneAnimation(a);
                            a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, apos, arot));
                            ao.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, aopos, aorot));
                        }
                    }
                }
                else
                {
                    if (actorPairs.Count > 0)
                    {
                        actorPairs.RemoveAt(actorPairs.Count - 1);
                    }
                    a.TryDoAction(ACType.Transfer, ACTransferPara.Construct(string.Empty, apos, arot));
                }
            }
        }