Esempio n. 1
0
            protected override void OnReload(GameMode currentGameMode)
            {
                Logger.Log(DebugLogLevel, "[OnReload] Fired!!");
                TriggerEnabled = false;
                ResetCharaTriggerInfo();

                PluginData ExtendedData = GetExtendedData();

                if (ExtendedData != null && ExtendedData.data.TryGetValue("CharaTriggerInfo", out var loadedCharaTriggerInfo) && loadedCharaTriggerInfo != null)
                {
                    if (MakerAPI.InsideMaker)
                    {
                        CharacterLoadFlags LoadFlags = MakerAPI.GetCharacterLoadFlags();
                        if (((bool)LoadFlags?.Clothes) || (LoadFlags == null))
                        {
                            CharaTriggerInfo = MessagePackSerializer.Deserialize <List <OutfitTriggerInfo> >((byte[])loadedCharaTriggerInfo);
                        }
                    }
                    else
                    {
                        CharaTriggerInfo = MessagePackSerializer.Deserialize <List <OutfitTriggerInfo> >((byte[])loadedCharaTriggerInfo);
                    }

                    Logger.Log(DebugLogLevel, $"[OnReload][{ChaControl.chaFile.parameter?.fullname}] CharaTriggerInfo loaded from extdata");
                }
                InitCurOutfitTriggerInfo();

                base.OnReload(currentGameMode);
            }
Esempio n. 2
0
        protected override void OnReload(GameMode currentGameMode, bool maintainState)
        {
            if (maintainState)
            {
                return;
            }

            if (StudioAPI.InsideStudio && ChaControl.fileStatus.coordinateType >= ChaControl.chaFile.coordinate.Length)
            {
                var ociChar = ChaControl.GetOCIChar();
                ociChar.SetCoordinateInfo(0);
            }

            var loadFlags = MakerAPI.GetCharacterLoadFlags();

            if (loadFlags == null || loadFlags.Clothes)
            {
                CoordinateNames.Clear();

                var data = GetExtendedData();
                if (data != null)
                {
                    if (data.data.TryGetValue(nameof(CoordinateNames), out var loadedCoordinateNames) && loadedCoordinateNames != null)
                    {
                        CoordinateNames = MessagePackSerializer.Deserialize <Dictionary <int, string> >((byte[])loadedCoordinateNames);
                    }
                }
            }
        }
            protected override void OnReload(GameMode currentGameMode)
            {
                var  flags       = MakerAPI.GetCharacterLoadFlags();
                bool clothesFlag = false;

                if (flags == null || (flags != null && flags.Clothes))
                {
                    clothesFlag = true;
                }
                bool bodyFlag = false;

                if (flags == null || (flags != null && flags.Body))
                {
                    bodyFlag = true;
                }

                if (bodyFlag)
                {
                    BaseData          = new BodyData(ChaControl.fileBody);
                    CurrentPushupData = new BodyData(ChaControl.fileBody);
                }

                if (clothesFlag)
                {
                    //Load the data only if clothes is checked to be loaded
                    BraDataDictionary = new Dictionary <int, ClothData>();
                    TopDataDictionary = new Dictionary <int, ClothData>();

                    var data = GetExtendedData();
                    if (data != null && data.data.TryGetValue(PushupConstants.Pushup_BraData, out var loadedBraData) && loadedBraData != null)
                    {
                        BraDataDictionary = MessagePackSerializer.Deserialize <Dictionary <int, ClothData> >((byte[])loadedBraData);
                    }

                    if (data != null && data.data.TryGetValue(PushupConstants.Pushup_TopData, out var loadedTopData) && loadedTopData != null)
                    {
                        TopDataDictionary = MessagePackSerializer.Deserialize <Dictionary <int, ClothData> >((byte[])loadedTopData);
                    }

                    //Reset advanced mode stuff and disable it when not loading the body in character maker
                    if (!bodyFlag)
                    {
                        foreach (var clothData in BraDataDictionary.Values)
                        {
                            BaseData.CopyTo(clothData);
                            clothData.UseAdvanced = false;
                        }
                        foreach (var clothData in TopDataDictionary.Values)
                        {
                            BaseData.CopyTo(clothData);
                            clothData.UseAdvanced = false;
                        }
                    }
                }

                RecalculateBody();
                base.OnReload(currentGameMode);
            }
Esempio n. 4
0
        protected override void OnReload(GameMode currentGameMode)
        {
            // Parameters are false by default in class chara maker, so we need to load them the 1st time to not lose progress
            // !MakerAPI.InsideAndLoaded is true when the initial card is being loaded into maker so we can use that
            if (!MakerAPI.InsideAndLoaded || MakerAPI.GetCharacterLoadFlags()?.Parameters != false)
            {
                ReadData();

                GetComponent <BoneController>().AddBoneEffect(_boneEffect);
            }
        }
Esempio n. 5
0
            protected override void OnReload(GameMode currentGameMode, bool maintainState)
            {
                if (MakerAPI.InsideAndLoaded && !MakerAPI.GetCharacterLoadFlags().Clothes)
                {
                    return;
                }

                RendererPropertyList.Clear();
                MaterialFloatPropertyList.Clear();
                MaterialColorPropertyList.Clear();

                var data = GetExtendedData();

                if (data == null)
                {
                    return;
                }

                CharacterLoading = true;

                if (data.data.TryGetValue(nameof(RendererPropertyList), out var rendererProperties) && rendererProperties != null)
                {
                    var loadedRendererProperties = MessagePackSerializer.Deserialize <List <RendererProperty> >((byte[])rendererProperties);

                    foreach (var loadedRendererProperty in loadedRendererProperties)
                    {
                        RendererPropertyList.Add(new RendererProperty(loadedRendererProperty.ObjectType, loadedRendererProperty.CoordinateIndex, loadedRendererProperty.Slot, loadedRendererProperty.RendererName, loadedRendererProperty.Property, loadedRendererProperty.Value, loadedRendererProperty.ValueOriginal));
                    }
                }

                if (data.data.TryGetValue(nameof(MaterialFloatPropertyList), out var materialFloatProperties) && materialFloatProperties != null)
                {
                    var loadedMaterialFloatProperties = MessagePackSerializer.Deserialize <List <MaterialFloatProperty> >((byte[])materialFloatProperties);

                    foreach (var loadedMaterialFloatProperty in loadedMaterialFloatProperties)
                    {
                        MaterialFloatPropertyList.Add(new MaterialFloatProperty(loadedMaterialFloatProperty.ObjectType, loadedMaterialFloatProperty.CoordinateIndex, loadedMaterialFloatProperty.Slot, loadedMaterialFloatProperty.MaterialName, loadedMaterialFloatProperty.Property, loadedMaterialFloatProperty.Value, loadedMaterialFloatProperty.ValueOriginal));
                    }
                }

                if (data.data.TryGetValue(nameof(MaterialColorPropertyList), out var materialColorProperties) && materialColorProperties != null)
                {
                    var loadedColorProperties = MessagePackSerializer.Deserialize <List <MaterialColorProperty> >((byte[])materialColorProperties);

                    foreach (var loadedMaterialColorProperty in loadedColorProperties)
                    {
                        MaterialColorPropertyList.Add(new MaterialColorProperty(loadedMaterialColorProperty.ObjectType, loadedMaterialColorProperty.CoordinateIndex, loadedMaterialColorProperty.Slot, loadedMaterialColorProperty.MaterialName, loadedMaterialColorProperty.Property, loadedMaterialColorProperty.Value, loadedMaterialColorProperty.ValueOriginal));
                    }
                }

                ChaControl.StartCoroutine(LoadData(true, true, true));
                ChaControl.StartCoroutine(ResetEvents());
            }
Esempio n. 6
0
        protected override void OnReload(GameMode currentGameMode)
        {
            var loadFlags = MakerAPI.GetCharacterLoadFlags();

            if (loadFlags == null || loadFlags.Clothes)
            {
                AccessoryDynamicBoneData.Clear();
                var data = GetExtendedData();
                if (data?.data != null)
                {
                    if (data.data.TryGetValue(nameof(AccessoryDynamicBoneData), out var loadedAccessoryDynamicBoneData) && loadedAccessoryDynamicBoneData != null)
                    {
                        AccessoryDynamicBoneData = MessagePackSerializer.Deserialize <List <DynamicBoneData> >((byte[])loadedAccessoryDynamicBoneData);
                    }
                }
            }
            StartCoroutine(ApplyData());

            base.OnReload(currentGameMode);
        }
        protected override void OnReload(GameMode currentGameMode, bool maintainState)
        {
            var loadFlags = MakerAPI.GetCharacterLoadFlags();

            if (loadFlags == null || loadFlags.Parameters)
            {
                ProfileText = null;

                var data = GetExtendedData();
                if (data != null && data.data.TryGetValue(nameof(ProfileText), out var loadedProfileText))
                {
                    ProfileText = loadedProfileText?.ToString();
                }

                if (MakerAPI.InsideMaker && Profile.ProfileTextbox != null)
                {
                    Profile.ProfileTextbox.Value = ProfileText ?? "";
                }
            }
        }
            protected override void OnReload(GameMode currentGameMode)
            {
                var flags = MakerAPI.GetCharacterLoadFlags();

                // If majority of the parts were loaded then use authors of the other card, else keep current
                if (ReplacedParts(flags) > 3)
                {
                    // Flags is null when starting maker and loading chika, our otside maker. Do NOT add the unknown author tag in these cases or cards based on chika would have it too
                    _previousAuthors = flags == null ? null : new[] { "[Unknown]" };
                }

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.data.TryGetValue(AuthorsKey, out var arr) && arr is byte[] strArr)
                    {
                        _previousAuthors = MessagePack.LZ4MessagePackSerializer.Deserialize <string[]>(strArr);
                    }
                }
            }
Esempio n. 9
0
        protected override void OnReload(GameMode currentGameMode, bool maintainState)
        {
            Dictionary <string, object> data = GetExtendedData()?.data;

            foreach (string prefix in prefixKeys)
            {
                foreach (string boolKey in boolKeys)
                {
                    string key = prefix + boolKey;
                    data.TryGetValue(key, out bool value, boolDefaults[key]);
                    boolData[key] = value;
                }

                foreach (string floatKey in floatKeys)
                {
                    string key = prefix + floatKey;
                    data.TryGetValue(key, out float value, floatDefaults[key]);
                    floatData[key] = value;
                }
            }

            if (!MakerAPI.InsideMaker)
            {
                return;
            }

            CharacterLoadFlags flags = MakerAPI.GetCharacterLoadFlags();

            if (flags != null && !flags.Body)
            {
                return;
            }

            if (MakerAPI.GetCharacterControl() != ChaControl)
            {
                return;
            }

            HS2_BoobSettings.MakerAPI_Update(this);
        }
Esempio n. 10
0
            /// <summary>
            /// Wait one frame for accessories to load and then load the data.
            /// </summary>
            private IEnumerator LoadData()
            {
                ReloadingChara = true;
                yield return(null);

                if (MakerAPI.InsideAndLoaded && !MakerAPI.GetCharacterLoadFlags().Clothes)
                {
                    yield break;
                }

                HairAccessories.Clear();

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.data.TryGetValue("HairAccessories", out var loadedHairAccessories) && loadedHairAccessories != null)
                    {
                        HairAccessories = MessagePackSerializer.Deserialize <Dictionary <int, Dictionary <int, HairAccessoryInfo> > >((byte[])loadedHairAccessories);
                    }
                }

                if (MakerAPI.InsideAndLoaded)
                {
                    if (InitHairAccessoryInfo(AccessoriesApi.SelectedMakerAccSlot))
                    {
                        //switching to a hair accessory that previously had no data. Meaning this card was made before this plugin. ColorMatch and HairGloss should be off.
                        SetColorMatch(false);
                        SetHairGloss(false);
                    }

                    InitCurrentSlot(this);
                }

                UpdateAccessories();
                ReloadingChara = false;
            }
Esempio n. 11
0
            protected override void OnReload(GameMode currentGameMode)
            {
                bool hasSavedBaseData = false;
                var  flags            = MakerAPI.GetCharacterLoadFlags();
                bool clothesFlag      = false;

                if (flags == null || flags.Clothes)
                {
                    clothesFlag = true;
                }
                bool bodyFlag = false;

                if (flags == null || flags.Body)
                {
                    bodyFlag = true;
                }

                if (bodyFlag)
                {
                    BaseData       = new BodyData(ChaControl.fileBody);
                    LoadedBaseData = new BodyData(ChaControl.fileBody);
                    BaseData.CopyTo(LoadedBaseData);
                    CurrentPushupData = new BodyData(ChaControl.fileBody);
                }

                if (clothesFlag)
                {
                    //Load the data only if clothes is checked to be loaded
                    BraDataDictionary = new Dictionary <int, ClothData>();
                    TopDataDictionary = new Dictionary <int, ClothData>();

                    var data = GetExtendedData();
                    if (data != null && data.data.TryGetValue(PushupConstants.Pushup_BraData, out var loadedBraData) && loadedBraData != null)
                    {
                        BraDataDictionary = MessagePackSerializer.Deserialize <Dictionary <int, ClothData> >((byte[])loadedBraData);
                    }

                    if (data != null && data.data.TryGetValue(PushupConstants.Pushup_TopData, out var loadedTopData) && loadedTopData != null)
                    {
                        TopDataDictionary = MessagePackSerializer.Deserialize <Dictionary <int, ClothData> >((byte[])loadedTopData);
                    }

                    if (data != null && data.data.TryGetValue(PushupConstants.Pushup_BodyData, out var loadedBodyData) && loadedBodyData != null)
                    {
                        hasSavedBaseData = true;
                        LoadedBaseData   = MessagePackSerializer.Deserialize <BodyData>((byte[])loadedBodyData);
                    }

                    //Reset advanced mode stuff and disable it when not loading the body in character maker
                    if (!bodyFlag)
                    {
                        foreach (var clothData in BraDataDictionary.Values)
                        {
                            BaseData.CopyTo(clothData);
                            clothData.UseAdvanced = false;
                        }
                        foreach (var clothData in TopDataDictionary.Values)
                        {
                            BaseData.CopyTo(clothData);
                            clothData.UseAdvanced = false;
                        }
                    }
                    if (!hasSavedBaseData)
                    {
                        if (data?.data != null)
                        {
                            data.data.Add(PushupConstants.Pushup_BodyData, MessagePackSerializer.Serialize(BaseData));
                            SetExtendedData(data);
                        }
                    }
                }

                //Apply the saved data to the base body data since it sometimes gets overwritten in the main game
                if (KoikatuAPI.GetCurrentGameMode() == GameMode.MainGame)
                {
                    LoadedBaseData.CopyTo(BaseData);
                }

                RecalculateBody();
                base.OnReload(currentGameMode);
            }
            protected override void OnReload(GameMode currentGameMode, bool maintainState)
            {
                BodyGUID     = null;
                PenisGUID    = null;
                BallsGUID    = null;
                DisplayPenis = ChaControl.sex == 0;
                DisplayBalls = ChaControl.sex == 0 ? true : DefaultFemaleDisplayBalls.Value;

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.version == 1)
                    {
                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                        if (data.data.TryGetValue("UncensorGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            string UncensorGUID = loadedUncensorGUID.ToString();
                            if (!UncensorGUID.IsNullOrWhiteSpace() && MigrationDictionary.TryGetValue(UncensorGUID, out MigrationData migrationData))
                            {
                                BodyGUID  = migrationData.BodyGUID;
                                PenisGUID = migrationData.PenisGUID;
                                BallsGUID = migrationData.BallsGUID;
                                if (PenisGUID != null)
                                {
                                    DisplayPenis = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (data.data.TryGetValue("BodyGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            BodyGUID = loadedUncensorGUID.ToString();
                        }

                        if (data.data.TryGetValue("PenisGUID", out var loadedPenisGUID) && loadedPenisGUID != null)
                        {
                            PenisGUID = loadedPenisGUID.ToString();
                        }

                        if (data.data.TryGetValue("BallsGUID", out var loadedBallsGUID) && loadedBallsGUID != null)
                        {
                            BallsGUID = loadedBallsGUID.ToString();
                        }

                        if (data.data.TryGetValue("DisplayPenis", out var loadedDisplayPenis))
                        {
                            DisplayPenis = (bool)loadedDisplayPenis;
                        }

                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                    }
                }

                if (BodyGUID.IsNullOrWhiteSpace())
                {
                    BodyGUID = null;
                }
                if (PenisGUID.IsNullOrWhiteSpace())
                {
                    PenisGUID = null;
                }
                if (BallsGUID.IsNullOrWhiteSpace())
                {
                    BallsGUID = null;
                }

                if (MakerAPI.InsideAndLoaded)
                {
                    if (MakerAPI.GetCharacterLoadFlags().Body)
                    {
                        if (MakerAPI.GetMakerBase().chaCtrl == ChaControl)
                        {
                            //Update the UI to match the loaded character
                            if (BodyGUID == null || BodyList.IndexOf(BodyGUID) == -1)
                            {
                                //The loaded uncensor isn't on the list, possibly due to being forbidden
                                BodyDropdown.SetValue(0, false);
                                BodyGUID = null;
                            }
                            else
                            {
                                BodyDropdown.SetValue(BodyList.IndexOf(BodyGUID), false);
                            }

                            if (PenisGUID == null || PenisList.IndexOf(PenisGUID) == -1)
                            {
#if KK
                                PenisDropdown.SetValue(DisplayPenis ? 0 : 1, false);
#elif EC
                                PenisDropdown.SetValue(0, false);
#endif
                                PenisGUID = null;
                            }
                            else
                            {
                                PenisDropdown.SetValue(PenisList.IndexOf(PenisGUID), false);
                            }

                            if (BallsGUID == null || BallsList.IndexOf(BallsGUID) == -1)
                            {
                                BallsDropdown.SetValue(DisplayBalls ? 0 : 1, false);
                                BallsGUID = null;
                            }
                            else
                            {
                                BallsDropdown.SetValue(BallsList.IndexOf(BallsGUID), false);
                            }
                        }
                    }
                    else
                    {
                        //Set the uncensor stuff to whatever is set in the maker
                        BodyGUID = BodyDropdown.Value == 0 ? null : BodyList[BodyDropdown.Value];
#if KK
                        PenisGUID    = PenisDropdown.Value == 0 || PenisDropdown.Value == 1 ? null : PenisList[PenisDropdown.Value];
                        DisplayPenis = PenisDropdown.Value == 1 ? false : true;
#elif EC
                        PenisGUID = PenisDropdown.Value == 0 ? null : PenisList[PenisDropdown.Value];
#endif
                        BallsGUID    = BallsDropdown.Value == 0 || BallsDropdown.Value == 1 ? null : BallsList[BallsDropdown.Value];
                        DisplayBalls = BallsDropdown.Value == 1 ? false : true;
                    }
                }

#if KK
                //Correct characters if genderbender is not permitted, except in Studio where it may be required for scene compatibility
                if (GenderBender.Value == false && !StudioAPI.InsideStudio)
                {
                    DisplayPenis = ChaControl.sex == 0;
                    DisplayBalls = ChaControl.sex == 0;
                }
#endif

                //Update the uncensor on every load or reload
                UpdateUncensor();
            }
            protected override void OnReload(GameMode currentGameMode)
            {
                BodyGUID     = null;
                PenisGUID    = null;
                BallsGUID    = null;
                DisplayPenis = ChaControl.sex == 0;
                DisplayBalls = ChaControl.sex == 0;

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.version == 1)
                    {
                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                        if (data.data.TryGetValue("UncensorGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            string UncensorGUID = loadedUncensorGUID.ToString();
                            if (!UncensorGUID.IsNullOrWhiteSpace() && MigrationDictionary.TryGetValue(UncensorGUID, out MigrationData migrationData))
                            {
                                BodyGUID  = migrationData.BodyGUID;
                                PenisGUID = migrationData.PenisGUID;
                                BallsGUID = migrationData.BallsGUID;
                                if (PenisGUID != null)
                                {
                                    DisplayPenis = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (data.data.TryGetValue("BodyGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            BodyGUID = loadedUncensorGUID.ToString();
                        }

                        if (data.data.TryGetValue("PenisGUID", out var loadedPenisGUID) && loadedPenisGUID != null)
                        {
                            PenisGUID = loadedPenisGUID.ToString();
                        }

                        if (data.data.TryGetValue("BallsGUID", out var loadedBallsGUID) && loadedBallsGUID != null)
                        {
                            BallsGUID = loadedBallsGUID.ToString();
                        }

                        if (data.data.TryGetValue("DisplayPenis", out var loadedDisplayPenis))
                        {
                            DisplayPenis = (bool)loadedDisplayPenis;
                        }

                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                    }
                }

                if (BodyGUID.IsNullOrWhiteSpace())
                {
                    BodyGUID = null;
                }
                if (PenisGUID.IsNullOrWhiteSpace())
                {
                    PenisGUID = null;
                }
                if (BallsGUID.IsNullOrWhiteSpace())
                {
                    BallsGUID = null;
                }

                if (MakerAPI.InsideAndLoaded)
                {
                    DoDropdownEvents = false;
                    if (MakerAPI.GetCharacterLoadFlags().Body)
                    {
                        if (MakerAPI.GetMakerBase().chaCtrl == ChaControl)
                        {
                            //Update the UI to match the loaded character
                            if (BodyGUID == null || BodyList.IndexOf(BodyGUID) == -1)
                            {
                                //The loaded uncensor isn't on the list, possibly due to being forbidden
                                BodyDropdown.Value = 0;
                                BodyGUID           = null;
                            }
                            else
                            {
                                BodyDropdown.Value = BodyList.IndexOf(BodyGUID);
                            }

                            if (PenisGUID == null || PenisList.IndexOf(PenisGUID) == -1)
                            {
                                PenisDropdown.Value = DisplayPenis ? 0 : 1;
                                PenisGUID           = null;
                            }
                            else
                            {
                                PenisDropdown.Value = PenisList.IndexOf(PenisGUID);
                            }

                            if (BallsGUID == null || BallsList.IndexOf(BallsGUID) == -1)
                            {
                                BallsDropdown.Value = DisplayBalls ? 0 : 1;
                                BallsGUID           = null;
                            }
                            else
                            {
                                BallsDropdown.Value = BallsList.IndexOf(BallsGUID);
                            }
                        }
                    }
                    else
                    {
                        //Set the uncensor stuff to whatever is set in the maker
                        BodyGUID     = BodyDropdown.Value == 0 ? null : BodyList[BodyDropdown.Value];
                        PenisGUID    = PenisDropdown.Value == 0 || PenisDropdown.Value == 1 ? null : PenisList[PenisDropdown.Value];
                        BallsGUID    = BallsDropdown.Value == 0 || BallsDropdown.Value == 1 ? null : BallsList[BallsDropdown.Value];
                        DisplayPenis = PenisDropdown.Value == 1 ? false : true;
                        DisplayBalls = BallsDropdown.Value == 1 ? false : true;
                    }
                    DoDropdownEvents = true;
                }
                //Update the uncensor on every load or reload
                UpdateUncensor();
            }