Ejemplo n.º 1
0
        private bool CanShow()
        {
            if (_chaCtrl == null)
            {
                return(false);
            }
            if (!_chaCtrl.visibleAll)
            {
                return(false);
            }

            if (MakerAPI.InsideMaker && !MakerAPI.IsInterfaceVisible())
            {
                return(false);
            }

            if (SceneApi.GetAddSceneName() == "Config")
            {
                return(false);
            }
            if (SceneApi.GetIsOverlap())
            {
                return(false);
            }
            if (SceneApi.GetIsNowLoadingFade())
            {
                return(false);
            }

            return(true);
        }
        protected override void OnReload(GameMode currentGameMode, bool maintainState)
        {
            var a = GetExtendedData();
            var b = GetBodyExtData();
            var c = GetParameterExtData();
            var d = GetFaceExtData();

            KoikatuAPI.Assert((a == null && b == null && c == null && d == null) || (a != null && b != null && c != null && d != null), "ext data not lining up");
            if (a != null)
            {
                KoikatuAPI.Assert(b != null, "b != null");
                KoikatuAPI.Assert(c != null, "c != null");
                KoikatuAPI.Assert(d != null, "d != null");
                var newId = a.data["id"] as string;
                KoikatuAPI.Assert(newId == b?.data["id"] as string, "a.data[\"id\"] == b.data[\"id\"]");
                KoikatuAPI.Assert(newId == c?.data["id"] as string, "a.data[\"id\"] == c.data[\"id\"]");
                KoikatuAPI.Assert(newId == d?.data["id"] as string, "a.data[\"id\"] == d.data[\"id\"]");
                Console.WriteLine($"ID get from ext data - {newId}  |  Old ID - {id}  |  Chara - {ChaControl.name}");
                id = newId;
            }
            if (id == null)
            {
                id = $"{No++} - {SceneApi.GetLoadSceneName()} - {SceneApi.GetAddSceneName()}";
                Console.WriteLine($"New ID assigned - {id}  |  Chara - {ChaControl.name} | {ChaFileControl.parameter.fullname}");
                SetParameterExtData(new PluginData()
                {
                    data = new Dictionary <string, object> {
                        { "id", id }
                    }
                });
                SetBodyExtData(new PluginData()
                {
                    data = new Dictionary <string, object> {
                        { "id", id }
                    }
                });
                SetFaceExtData(new PluginData()
                {
                    data = new Dictionary <string, object> {
                        { "id", id }
                    }
                });
                SetExtendedData(new PluginData()
                {
                    data = new Dictionary <string, object> {
                        { "id", id }
                    }
                });
            }

            KoikatuAPI.Logger.LogWarning($"event:OnReload  chara:{ChaControl.name}  currentGameMode:{currentGameMode}  maintainState:{maintainState}");
        }
Ejemplo n.º 3
0
        private void Update()
        {
            if (_hSceneHeroines != null)
            {
                if (SceneApi.GetIsNowLoadingFade())
                {
                    return;
                }

                var speed = _hFlag.IsSonyu() && _hFlag.speedCalc > 0.7f
                    ? (_hFlag.speedCalc - 0.7f) * 3.3f
                    : (_hFlag.speedItem > 1.4f ? 0.33f : 0);
                if (speed > 0)
                {
                    var id          = _hFlag.GetLeadingHeroineId();
                    var heroineInfo = _hSceneHeroines[id];
                    heroineInfo.TotalRoughTime += Time.deltaTime;

                    if (heroineInfo.CrestType == CrestType.suffer && !_hFlag.lockGugeFemale)
                    {
                        _hFlag.gaugeFemale += speed * Time.deltaTime * 2;
                    }
                }
            }
            else if (_existingControllers != null)
            {
                for (var i = 0; i < _existingControllers.Count; i++)
                {
                    var controller = _existingControllers[i];
                    if (controller.CurrentCrest == CrestType.mantraction)
                    {
                        if (SceneApi.GetIsNowLoadingFade())
                        {
                            return;
                        }

                        var actScene = GetActionScene();
                        if (actScene == null)
                        {
                            return;
                        }
                        var player = actScene.Player;
                        if (player == null)
                        {
                            continue;
                        }

                        // Stop the crest from activating outsied of when player runs around
                        // needed because if the code below activates during an adv scene or some other inopportune times it will softlock the game
                        if (player.isActionNow)
                        {
                            return;
                        }
#if KKS
                        if (Game.IsRegulate(true))
                        {
                            return;
                        }
                        if (actScene.regulate != 0 || (actScene.AdvScene != null && actScene.AdvScene.gameObject.activeSelf) || TalkScene.isPaly)
                        {
                            return;
                        }
#elif KK
                        if (Game.instance.IsRegulate(true))
                        {
                            return;
                        }
#endif

                        var heroine = controller.Heroine;
                        if (heroine == null)
                        {
                            continue;
                        }

                        var npc = heroine.GetNPC();
                        if (player.mapNo == npc.mapNo)
                        {
                            var cooldownTimeLeft = AdvanceAndGetActionCooldown(heroine);
                            if (cooldownTimeLeft <= 0)
                            {
                                if (Vector3.Distance(player.position, npc.position) > 3)
                                {
                                    LewdCrestXPlugin.Logger.LogInfo("Chasing player because of mantraction crest: " + controller.Heroine.charFile?.parameter?.fullname);
                                    npc.ItemClear();
                                    npc.AI.ChaseAction();
                                    // Need to replace this from the default chase id because that disables the talk to bubble
                                    // This action is triggered when character approaches player
                                    // 28 - wanting to talk to player. If too annoying might want to replace with actions in range 10 - 16, maybe randomized
                                    npc.AI.actResult.value.actionNo = 28;

                                    SetActionCooldown(heroine, 10);
                                }
                            }
                        }
                    }
                }
            }
        }