예제 #1
0
파일: Plugin.cs 프로젝트: flopes89/rainify
        public static void Initialize(ref IntPtr data_, IntPtr rm_)
        {
            _api = rm_;

            try
            {
                string      parent = _api.ReadString("ParentName", string.Empty);
                BaseMeasure measure;

                if (string.IsNullOrWhiteSpace(parent))
                {
                    measure = new ParentMeasure(_api.Log);
                }
                else
                {
                    measure = new ChildMeasure(_api.Log);
                }

                data_ = GCHandle.ToIntPtr(GCHandle.Alloc(measure));
            }
            catch (Exception ex)
            {
                _api.Log(LogType.Error, ex.Message);
                _api.Log(LogType.Error, ex.StackTrace);
            }
        }
예제 #2
0
        /// <summary>
        /// <see cref="BaseMeasure.Reload"/>
        /// </summary>
        /// <param name="api_"><see cref="BaseMeasure.Reload"/></param>
        /// <param name="max_"><see cref="BaseMeasure.Reload"/></param>
        internal override void Reload(Api api_, ref double max_)
        {
            base.Reload(api_, ref max_);

            _field = api_.ReadString("Field", string.Empty);

            var parentName = api_.ReadString("ParentName", string.Empty);
            var skin       = api_.GetSkin();

            _parentMeasure = null;
            foreach (ParentMeasure parent in ParentMeasure.Parents)
            {
                if (parent.Skin.Equals(skin) && parent.Name.Equals(parentName))
                {
                    _parentMeasure = parent;
                }
            }

            if (_parentMeasure == null)
            {
                _log(LogType.Error, $"Parent [{parentName}] not found in Skin [{skin}]");
            }
        }