Пример #1
0
        /// <summary>
        /// Add a custom topic to the game. Check the other overloads for more info.
        /// Warning: This overload skips most of the parameter checks! It's best to use the other overload instead.
        /// </summary>
        public static IDisposable RegisterTopic(Topic.Param param, GetTopicADVscript getAdvScript, GetTopicADVresult getAdvResult)
        {
            if (StudioAPI.InsideStudio)
            {
                return(Disposable.Empty);
            }

            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (getAdvScript == null)
            {
                throw new ArgumentNullException(nameof(getAdvScript), "You need to return some sort of ADV script or picking the topic will crash the game. You can return a null if you don't want to show any ADV.");
            }
            if (getAdvResult == null)
            {
                throw new ArgumentNullException(nameof(getAdvResult), "You need to return some sort of ADV result. You can return a null if you don't want to add any stats.");
            }

            if (param.No < 100)
            {
                throw new ArgumentOutOfRangeException(nameof(param), param.No, "No has to be above 100");
            }

            TopicHooks.ApplyHooksIfNeeded();

            _customTopics.Add(param.No, new CustomTopicInfo(param, getAdvScript, getAdvResult));

            // All topics get added by a hook when ActionScene is loaded, need to add manually after that
            if (ActionScene.initialized && ActionScene.instance.topicDic != null)
            {
                ActionScene.instance.topicDic.Add(param.No, param);
            }

            return(Disposable.Create(() =>
            {
                _customTopics.Remove(param.No);
                ActionScene.instance.topicDic.Remove(param.No);
            }));
        }
Пример #2
0
 public CustomTopicInfo(Topic.Param param, GetTopicADVscript scriptGetter, GetTopicADVresult resultGetter)
 {
     Param        = param;
     ScriptGetter = scriptGetter;
     ResultGetter = resultGetter;
 }