示例#1
0
        public InstanceResolverResult ResolvePossibleData(object baseObject, object data, PropertyInfo property)
        {
            InstanceResolverResult result = new InstanceResolverResult
            {
                PossibleInstanceTokens = InfoResolver.Resolve <FortInfo>().MarketInfos.Where(info => info != null).Select(info => new InstanceToken(info.MarketName, info.MarketName)).ToArray()
            };
            InstanceToken instanceToken =
                result.PossibleInstanceTokens.FirstOrDefault(token => string.Equals((string)token.Value, (string)data));

            result.PresentableInstanceTokens = instanceToken == null ? new InstanceToken[0] : new[] { instanceToken };
            return(result);
        }
        protected override void OnTargetChanged(IInfo targetObject)
        {
            LanguageEditorInfo languageEditorInfo = (LanguageEditorInfo)targetObject;

            if (languageEditorInfo != null)
            {
                if (
                    InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages.Any(
                        info => languageEditorInfo.Languages.All(languageInfo => languageInfo.Id != info.Id)))
                {
                    InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages =
                        InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages.Where(
                            info => languageEditorInfo.Languages.Any(languageInfo => languageInfo.Id == info.Id))
                        .ToArray();
                    InfoResolver.Resolve <FortInfo>().Save();
                }
            }
        }
示例#3
0
 public void SyncValues()
 {
     if (Values == null)
     {
         Values = new Dictionary <string, int>();
     }
     string[] valueDefenitions = InfoResolver.Resolve <FortInfo>().ValueDefenitions ?? new string[0];
     foreach (string valueDefenition in valueDefenitions)
     {
         if (!Values.ContainsKey(valueDefenition))
         {
             Values[valueDefenition] = 0;
         }
     }
     foreach (KeyValuePair <string, int> pair in Values.ToArray())
     {
         if (!valueDefenitions.Contains(pair.Key))
         {
             Values.Remove(pair.Key);
         }
     }
 }
        public static IInfo Resolve(Type infoType)
        {
            if (!typeof(IInfo).IsAssignableFrom(infoType))
            {
                throw new Exception("Only IInfo inherited interface types can be resolved");
            }
            InfoAttribute infoAttribute = infoType.GetCustomAttribute <InfoAttribute>();

            if (infoAttribute == null)
            {
                throw new Exception("Info attribute not found");
            }
            if (!infoAttribute.Editor)
            {
                return(InfoResolver.Resolve(infoType));
            }
            if (Infoes.ContainsKey(infoType))
            {
                return(Infoes[infoType]);
            }
            FortScriptableObject fortScriptableObject = AssetDatabase.LoadAssetAtPath <FortScriptableObject>(GetInfoLocation(infoType));

            if (fortScriptableObject == null)
            {
                LoadingSequences[infoType] = true;
                IInfo result = (IInfo)Activator.CreateInstance(infoType);
                Infoes[infoType]           = result;
                LoadingSequences[infoType] = false;
                return(result);
            }
            LoadingSequences[infoType] = true;
            IInfo info = fortScriptableObject.Load(infoType);

            Infoes[infoType]           = info;
            LoadingSequences[infoType] = false;
            return(info);
        }