Esempio n. 1
0
            public static void CustomStringImports(MutagenFrame frame, IConditionData item)
            {
                if (!frame.Reader.TryGetSubrecordFrame(out var subMeta))
                {
                    return;
                }
                if (!(item is IFunctionConditionData funcData))
                {
                    return;
                }
                switch (subMeta.RecordType.TypeInt)
                {
                case 0x31534943:     // CIS1
                    funcData.ParameterOneString = BinaryStringUtility.ProcessWholeToZString(subMeta.Content);
                    break;

                case 0x32534943:     // CIS2
                    funcData.ParameterTwoString = BinaryStringUtility.ProcessWholeToZString(subMeta.Content);
                    break;

                default:
                    return;
                }
                frame.Position += subMeta.TotalLength;
            }
Esempio n. 2
0
 public static void DeepCopyIn(
     this IConditionData lhs,
     IConditionDataGetter rhs)
 {
     ((ConditionDataSetterTranslationCommon)((IConditionDataGetter)lhs).CommonSetterTranslationInstance() !).DeepCopyIn(
         item: lhs,
         rhs: rhs,
         errorMask: default,
Esempio n. 3
0
        private static List <MemberInfo> GetAllPropertyReferencesFromCondition(IConditionData conditionData)
        {
            List <MemberInfo> memberInfo = conditionData.GetType()
                                           .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                           .Where(info =>
                                                  info.PropertyType.IsConstructedGenericType && info.PropertyType.GetGenericTypeDefinition() ==
                                                  typeof(ScenePropertyReference <>))
                                           .Cast <MemberInfo>()
                                           .ToList();

            memberInfo.AddRange(conditionData.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)
                                .Where(info =>
                                       info.FieldType.IsConstructedGenericType && info.FieldType.GetGenericTypeDefinition() ==
                                       typeof(ScenePropertyReference <>)));

            return(memberInfo);
        }
Esempio n. 4
0
        /// <summary>
        /// Extracts all <see cref="ISceneObjectProperty"/> from type T from the given condition.
        /// </summary>
        /// <param name="data">Condition to be used for extraction</param>
        /// <param name="checkRequiredComponentsToo">if true the [RequiredComponents] will be checked and added too.</param>
        public static List <ISceneObjectProperty> ExtractPropertiesFromConditions(IConditionData data, bool checkRequiredComponentsToo = true)
        {
            List <ISceneObjectProperty> result = new List <ISceneObjectProperty>();

            List <MemberInfo> memberInfo = GetAllPropertyReferencesFromCondition(data);

            memberInfo.ForEach(info =>
            {
                UniqueNameReference reference = ReflectionUtils.GetValueFromPropertyOrField(data, info) as UniqueNameReference;

                if (reference == null || string.IsNullOrEmpty(reference.UniqueName))
                {
                    return;
                }

                if (RuntimeConfigurator.Configuration.SceneObjectRegistry.ContainsName(reference.UniqueName) == false)
                {
                    return;
                }

                IEnumerable <Type> refs = ExtractFittingPropertyTypeFrom <ISceneObjectProperty>(reference);

                Type refType = refs.FirstOrDefault();
                if (refType != null)
                {
                    IEnumerable <Type> types = new[] { refType };
                    if (checkRequiredComponentsToo)
                    {
                        types = GetDependenciesFrom(refType);
                    }

                    foreach (Type type in types)
                    {
                        ISceneObjectProperty property = GetFittingPropertyFromReference <ISceneObjectProperty>(reference, type);
                        if (property != null)
                        {
                            result.Add(property);
                        }
                    }
                }
            });

            return(result);
        }
Esempio n. 5
0
 public static void Clear(this IConditionData item)
 {
     ((ConditionDataSetterCommon)((IConditionDataGetter)item).CommonSetterInstance() !).Clear(item: item);
 }
 public void Setup()
 {
     _data = Substitute.For <IConditionData>();
 }
 public ConditionRuntime(IDialogueController dialogueController, string uniqueId, IConditionData data)
 {
     _data = data;
     _dialogueController = dialogueController;
     UniqueId            = uniqueId;
 }