private static void OnCoordinateBeingLoaded(ChaControl character, ChaFileCoordinate coordinateFile)
        {
#if EC || AI
            KoikatuAPI.Logger.LogDebug($"Loading coord \"{coordinateFile.coordinateName}\" to chara \"{GetLogName(character)}\"");
#elif KK
            KoikatuAPI.Logger.LogDebug($"Loading coord \"{coordinateFile.coordinateName}\" to chara \"{GetLogName(character)}\" / {(ChaFileDefine.CoordinateType)character.fileStatus.coordinateType}");
#endif

            foreach (var controller in GetBehaviours(character))
            {
                controller.OnCoordinateBeingLoadedInternal(coordinateFile);
            }

            var args = new CoordinateEventArgs(character, coordinateFile);
            try
            {
                CoordinateLoaded?.Invoke(null, args);
            }
            catch (Exception e)
            {
                KoikatuAPI.Logger.LogError(e);
            }

            if (MakerAPI.InsideAndLoaded)
            {
                MakerAPI.OnReloadInterface(args);
            }
        }
        private static void OnCoordinateBeingLoaded(Human character, CustomParameter coordinateFile)
        {
            KoikatuAPI.Logger.LogDebug("Loading coordinate");

            foreach (var controller in GetBehaviours(character))
            {
                controller.OnCoordinateBeingLoadedInternal(coordinateFile);
            }

            var args = new CoordinateEventArgs(character, coordinateFile);

            try
            {
                CoordinateLoaded?.Invoke(null, args);
            }
            catch (Exception e)
            {
                KoikatuAPI.Logger.LogError(e);
            }

            if (MakerAPI.InsideAndLoaded)
            {
                MakerAPI.OnReloadInterface(args);
            }
        }
Exemplo n.º 3
0
        private static void ReloadChara(ChaControl chaControl = null)
        {
            if (IsCurrentlyReloading(chaControl))
            {
                return;
            }

            if (chaControl == null)
            {
                _currentlyReloading.UnionWith(ChaControls);
            }
            else
            {
                _currentlyReloading.Add(chaControl);
            }

            KoikatuAPI.Logger.LogDebug("Character load/reload: " + GetLogName(chaControl));

            // Always send events to controllers before subscribers of CharacterReloaded
            var gamemode = KoikatuAPI.GetCurrentGameMode();

            foreach (var behaviour in GetBehaviours(chaControl))
            {
                behaviour.OnReloadInternal(gamemode);
            }

            var args = new CharaReloadEventArgs(chaControl);

            try
            {
                CharacterReloaded?.Invoke(null, args);
            }
            catch (Exception e)
            {
                KoikatuAPI.Logger.LogError(e);
            }

            if (MakerAPI.InsideAndLoaded)
            {
                MakerAPI.OnReloadInterface(args);
            }

            if (chaControl == null)
            {
                _currentlyReloading.Clear();
            }
            else
            {
                _currentlyReloading.Remove(chaControl);
            }
        }
        private static void ReloadChara(Human chaControl = null)
        {
            if (IsCurrentlyReloading(chaControl))
            {
                return;
            }

            if (chaControl == null)
            {
                _currentlyReloading.UnionWith(ChaControls);
            }
            else
            {
                _currentlyReloading.Add(chaControl);
            }

            KoikatuAPI.Logger.LogDebug("Character load/reload");

            // Always send events to controllers before subscribers of CharacterReloaded
            var gamemode = KoikatuAPI.GetCurrentGameMode();

            foreach (var behaviour in GetBehaviours(chaControl))
            {
                behaviour.OnReloadInternal(gamemode);
            }

            OnCharacterReload(chaControl);

            if (MakerAPI.InsideAndLoaded)
            {
                MakerAPI.OnReloadInterface(new CharaReloadEventArgs(chaControl));
            }

            if (chaControl == null)
            {
                _currentlyReloading.Clear();
                Hooks.LastLoadedCardPaths.Clear();
            }
            else
            {
                _currentlyReloading.Remove(chaControl);
                Hooks.LastLoadedCardPaths[chaControl] = null;
            }
        }