Beispiel #1
0
        public bool Set <T>(T t)
        {
            //var res=Activator.CreateInstance(type,ItemRank.magic);
            Type[] arr;
            if (!CacheInterfaceDictionary.ContainsKey(typeof(T)))
            {
                arr = InterfaceUtils.GetInterfaces <IFormattable <T> >();
                if (arr.Length != 1)
                {
                    throw new Exception();
                }
                CacheInterfaceDictionary[typeof(T)] = arr;
            }
            else
            {
                arr = CacheInterfaceDictionary[typeof(T)];
            };
            //if(arr.Length!=1)
            //    throw new Exception();
            var target = arr.First();
            IFormattable <T> formattable = (IFormattable <T>)Activator.CreateInstance(target);

            formattable.Set(t);
            //return new FormattableMaster{
            FormattableName = TypeUtils.TypeToString(formattable.GetType());
            DataType        = formattable.DataType;
            Data            = formattable.Data;
            return(true);

            //};
        }
Beispiel #2
0
 public AccessableData(Type[] saver, Type[] loader)
 {
     accesessableDictionary = new Dictionary <string, (bool savable, bool loadable)>();
     foreach (Type itemtype in saver)
     {
         var item = TypeUtils.TypeToString(itemtype);
         if (accesessableDictionary.ContainsKey(item))
         {
             accesessableDictionary[item] = (true, accesessableDictionary[item].loadable);
         }
         else
         {
             accesessableDictionary[item] = (true, false);
         }
     }
     foreach (Type itemtype in loader)
     {
         var item = TypeUtils.TypeToString(itemtype);
         if (accesessableDictionary.ContainsKey(item))
         {
             accesessableDictionary[item] = (accesessableDictionary[item].savable, true);
         }
         else
         {
             accesessableDictionary[item] = (false, true);
         }
     }
     //this.data = data;
 }
Beispiel #3
0
        public bool Set(ISuffix <IStatus> t)
        {
            var statusModifierCore = new StatusModifierCore {
                type = t.modifier.type, amount = t.modifier.amount
            };

            Data = ZeroFormatterSerializer.Serialize(new FigereCore {
                statusModifierCore = statusModifierCore, tier = t.tier
            });
            DataType = TypeUtils.TypeToString(t.GetType().GenericTypeArguments.First());
            return(true);
        }
Beispiel #4
0
        public bool Set(IBaseItem t)
        {
            //Debug.Log("ItemSet");
            var itemCore = new ItemCore {
                rank       = t.rank,
                prefixList = t.prefixList.Select(ele => { var res = new FormattablePrefix(); res.Set(ele); return(res); }).ToList(),
                suffixList = t.suffixList.Select(ele => { var res = new FormattableSuffix(); res.Set(ele); return(res); }).ToList()
            };

            Data     = ZeroFormatterSerializer.Serialize(itemCore);
            DataType = TypeUtils.TypeToString(t.GetType());
            return(true);
        }
Beispiel #5
0
        public bool Set(IStatusModifier <IStatus> data)
        {
            bool ret = true;

            Data = ZeroFormatterSerializer.Serialize(new StatusModifierCore {
                type = data.type, amount = data.amount
            });
            //Type type=data.GetType();
            DataType = TypeUtils.TypeToString(data.GetType().GenericTypeArguments.First());
            //DataType=TypeUtils.TypeToString(type);
            //type=data.GetType();
            return(ret);
        }
Beispiel #6
0
        public bool Set(IStatus data)
        {
            bool ret = true;

            Data = ZeroFormatterSerializer.Serialize(data.baseValue);
            Type type = data.GetType();

            if (type.IsSubclassOf(typeof(Status)))
            {
                DataType = TypeUtils.TypeToString(type);//$"{type}, {type.Assembly.GetName().Name}";
            }
            //type=data.GetType();
            return(ret);
        }
Beispiel #7
0
        public bool Set(IElementsHolder t)
        {
            FormattableModifierList formmatable = new FormattableModifierList();

            formmatable.Set(t.permanentModifierList.ToList());
            var core = new ElementsHolderCore {
                statusList = t.elementDictionary.Select(ele =>
                {
                    FormattableStatusHolder status = new FormattableStatusHolder();
                    status.Set(ele.Value);
                    return(status);
                }).ToList(),
                modifierList = formmatable
                               //.ToDictionary(ele=>ele.Item1,ele=>ele.status)
            };

            Data     = ZeroFormatterSerializer.Serialize(core);
            DataType = TypeUtils.TypeToString(t.GetType());
            return(true);
        }