private static void OnCharacterReloaded(ChaControl chaControl)
        {
            var args = new CharaReloadEventArgs(chaControl);

            try
            {
                CharacterReloaded?.Invoke(null, args);
            }
            catch (Exception e)
            {
                KoikatuAPI.Logger.LogError(e);
            }
        }
예제 #2
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);
            }
        }