コード例 #1
0
        public static void UpdateControllers()
        {
            foreach (StatsController controller in controllersQueue)
            {
                if (CustomBase.IsInstance() && CustomBase.Instance.chaCtrl == controller.ChaControl)
                {
                    controllers.Add(controller);
                }
                else
                {
                    foreach (KeyValuePair <int, AgentActor> agent in Manager.Map.Instance.AgentTable)
                    {
                        if (agent.Value.ChaControl == controller.ChaControl)
                        {
                            controller.id    = agent.Key;
                            controller.agent = agent.Value;

                            controllers.Add(controller);
                            break;
                        }
                    }
                }
            }

            controllersQueue.Clear();

            foreach (StatsController controller in controllersDump)
            {
                controllers.Remove(controller);
            }

            controllersDump.Clear();
        }
コード例 #2
0
 private static void Reload(ChaControl __instance)
 {
     if (CustomBase.IsInstance())
     {
         __instance.StartCoroutine(SliderUnlocker.ResetAllSliders());
     }
 }
コード例 #3
0
        internal void SetPlayerClothesToAutomatic()
        {
            Assert.IsNotNull(this);
            if (Game.IsInstance())
            {
                Game.Instance.SafeProc(i => i.Player.SafeProc(p => p.changeClothesType = -1));
            }

            if (CustomBase.IsInstance())
            {
                CustomBase.Instance.SafeProc(i => i.autoClothesState = true);
            }
        }
コード例 #4
0
        protected override void OnReload(GameMode currentGameMode, bool maintainState)
        {
            if (CustomBase.IsInstance() &&
                CustomBase.Instance.chaCtrl == ChaControl)
            {
                CustomCharaWindow[] customCharaWindows =
                    FindObjectsOfType <CustomCharaWindow>();

                if (customCharaWindows != null && customCharaWindows.Length >= 2)
                {
                    var toggles = new HarmonyLib.Traverse(customCharaWindows[1])
                                  .Field("tglLoadOption")
                                  .GetValue <Toggle[]>();

                    if (toggles != null &&
                        toggles.Length >= 5 &&
                        !toggles[4].isOn)
                    {
                        return;
                    }
                }
            }

            PluginData data = GetExtendedData();

            if (data != null)
            {
                Dictionary <int, float> newLockedStats;
                Dictionary <int, float> newLockedDesires;
                Dictionary <int, int>   newLockedFlavors;

                try
                {
                    newLockedStats = LZ4MessagePackSerializer
                                     .Deserialize <Dictionary <int, float> >((byte[])data.data["lockedStats"]);
                    newLockedDesires = LZ4MessagePackSerializer
                                       .Deserialize <Dictionary <int, float> >((byte[])data.data["lockedDesires"]);
                    newLockedFlavors = LZ4MessagePackSerializer
                                       .Deserialize <Dictionary <int, int> >((byte[])data.data["lockedFlavors"]);
                }
                catch (Exception err)
                {
                    Debug.Log($"[Agent Trainer] Failed to load extended data.\n{err}");
                    return;
                }

                lockedStats   = newLockedStats;
                lockedDesires = newLockedDesires;
                lockedFlavors = newLockedFlavors;
            }
        }
コード例 #5
0
ファイル: Plugin.GUI.cs プロジェクト: guanziang/AgentTrainer
        void Draw_Agents()
        {
            GUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            {
                GUILayout.Label("Agents", sectionLabelStyle);

                foreach (StatsController controller in controllers)
                {
                    if (controller.ChaControl == null)
                    {
                        if (this.controller == controller)
                        {
                            this.controller = null;
                        }

                        controllersDump.Add(controller);
                        continue;
                    }

                    string label;

                    if (CustomBase.IsInstance() &&
                        CustomBase.Instance.chaCtrl == controller.ChaControl)
                    {
                        label = "[New Agent]";
                    }
                    else if (controller.agent != null)
                    {
                        label = $"[{controller.id}]: {controller.agent.CharaName}";
                    }
                    else
                    {
                        label = $"[?]: {controller.ChaControl.chaFile.charaFileName}";
                    }

                    GUIStyle style =
                        this.controller == controller ? selectedButtonStyle : GUI.skin.button;

                    if (GUILayout.Button(label, style, GUILayout.Width(AGENTS_WIDTH)))
                    {
                        this.controller = controller;
                    }
                }
            }
            GUILayout.EndVertical();
        }
コード例 #6
0
            internal static void ToggleOnPointerClickPrefix(Toggle __instance,
                                                            ref PointerEventData eventData, out Toggle __state)
            {
                __state = null;
                try
                {
                    Logger.DebugLogDebug(nameof(ToggleOnPointerClickPrefix));
                    if (!Enabled.Value ||
                        eventData.button != PointerEventData.InputButton.Right ||
                        __instance == null || __instance.name.IsNullOrEmpty() ||
                        !__instance.name.StartsWith(TogglePrefix))
                    {
                        return;
                    }

                    // everything after this point will fire the default left-click event
                    eventData.button = PointerEventData.InputButton.Left;


                    if (__instance.name == AutoToggleName)
                    {
                        return;
                    }

                    var autoEnabled = (CustomBase.IsInstance() && CustomBase.Instance.autoClothesState) ||
                                      (Game.IsInstance() && Game.Instance.Player.changeClothesType < 0);

                    if (!autoEnabled)
                    {
                        return;
                    }

                    Toggle autoToggle = null;
                    __instance.group.SafeProc(g =>
                                              autoToggle = g.ActiveToggles().FirstOrDefault(t => t.name == AutoToggleName));
                    __state = autoToggle;
                }

                catch (Exception err)
                {
                    Logger.LogException(err, nameof(ToggleOnPointerClickPrefix));
                }
            }
コード例 #7
0
        public static ChaFileAccessory.PartsInfo GetPartsInfo(int index)
        {
            if (!CustomBase.IsInstance())
            {
                throw new InvalidOperationException("Can only call GetPartsInfo when inside Chara Maker");
            }
            var control = CustomBase.instance.chaCtrl;

            if (control == null)
            {
                throw new InvalidOperationException("Chara Maker Not Ready");
            }
            var parts = control.nowCoordinate.accessory.parts;

            if (parts.Length <= index)
            {
                return(new ChaFileAccessory.PartsInfo());
            }
            return(parts[index]);
        }
コード例 #8
0
        internal void SetPlayerClothesToAutomatic()
        {
            if (Game.IsInstance())
            {
                var player = Singleton <Game> .Instance.Player;
                if (player != null)
                {
                    player.changeClothesType = -1;
                }
            }

            if (CustomBase.IsInstance())
            {
                var customBase = Singleton <CustomBase> .Instance;
                if (customBase != null)
                {
                    customBase.autoClothesState = true;
                }
            }
        }
コード例 #9
0
            internal static void ToggleOnPointerClickPrefix(Toggle __instance,
                                                            ref PointerEventData eventData, out Toggle __state)
            {
                Logger.DebugLogDebug("ToggleOnPointerClickPrefix");
                __state = null;
                if (!Enabled.Value ||
                    eventData.button != PointerEventData.InputButton.Right ||
                    __instance == null || __instance.name == null || !__instance.name.StartsWith(TogglePrefix))
                {
                    return;
                }

                // everything after this point will fire the default left-click event
                eventData.button = PointerEventData.InputButton.Left;


                if (__instance.name == AutoToggleName)
                {
                    return;
                }

                var autoEnabled = (CustomBase.IsInstance() &&
                                   Singleton <CustomBase> .Instance.autoClothesState) ||
                                  (Game.IsInstance() &&
                                   Singleton <Game> .Instance.Player.changeClothesType < 0);

                if (!autoEnabled)
                {
                    return;
                }

                var togglesField = Traverse.Create(__instance.group).Field("m_Toggles");

                __state = togglesField.FieldExists()
                    ? togglesField.GetValue <List <Toggle> >().FirstOrDefault(t => t.name == AutoToggleName)
                    : null;
            }