예제 #1
0
        private Rect DrawProperty(Rect currentPosition, LockableProperty property)
        {
            currentPosition.y += EditorDrawingHelper.SingleLineHeight + EditorDrawingHelper.VerticalSpacing;
            Rect objectPosition = currentPosition;

            objectPosition.x     += EditorDrawingHelper.IndentationWidth * 2f;
            objectPosition.width -= EditorDrawingHelper.IndentationWidth * 2f;

            GUI.enabled = lockableCollection.IsInAutoUnlockList(property) == false;
            bool isFlagged = GUI.enabled == false || lockableCollection.IsInManualUnlockList(property);

            if (EditorGUI.Toggle(currentPosition, isFlagged) != isFlagged)
            {
                // Inverted due to not updated with the toggle
                if (isFlagged)
                {
                    lockableCollection.Remove(property);
                }
                else
                {
                    lockableCollection.Add(property);
                }
            }
            GUI.enabled = true;
            EditorGUI.LabelField(objectPosition, property.GetType().Name);
            return(currentPosition);
        }
예제 #2
0
        public bool IsInAutoUnlockList(LockableProperty property)
        {
            foreach (LockablePropertyData lockableProperty in toUnlock)
            {
                if (property == lockableProperty.Property)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public bool IsInManualUnlockList(LockableProperty property)
        {
            foreach (LockablePropertyReference lockableProperty in data.ToUnlock)
            {
                if (property == lockableProperty.GetProperty())
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Returns the referenced <see cref="LockableProperty"/>.
        /// </summary>
        public LockableProperty GetProperty()
        {
            if (property == null)
            {
                foreach (ISceneObjectProperty prop in Target.Value.Properties)
                {
                    if (prop.GetType().AssemblyQualifiedName.Equals(Type))
                    {
                        property = (LockableProperty)prop;
                        break;
                    }
                }
            }

            return(property);
        }
예제 #5
0
        public IEnumerator ObjectInConditionIsNotInManualUnlockList()
        {
            // Given a step with a condition with a LockableProperty
            ISceneObject     o1 = TestingUtils.CreateSceneObject("o1");
            LockableProperty lockableProperty = o1.GameObject.AddComponent <LockablePropertyMock>();
            LockableReferencingConditionMock lockCondition = new LockableReferencingConditionMock();

            lockCondition.Data.LockablePropertyMock = new ScenePropertyReference <ILockablePropertyMock>(o1.UniqueName);
            Step step = new BasicStepBuilder("step").AddCondition(lockCondition).Build();

            // When we create a collection referencing this step
            LockableObjectsCollection collection = new LockableObjectsCollection(step.Data);

            // Then the lockable property is not in the Manual Unlock List of the collection
            Assert.IsFalse(collection.IsInManualUnlockList(lockableProperty));

            yield return(null);
        }
예제 #6
0
        /// <summary>
        /// Extracts all <see cref="LockableProperties"/> from 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 <LockablePropertyData> ExtractLockablePropertiesFromConditions(IConditionData data, bool checkRequiredComponentsToo = true)
        {
            List <LockablePropertyData> result = new List <LockablePropertyData>();

            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 <LockableProperty>(reference);

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

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

            return(result);
        }
예제 #7
0
        public IEnumerator ManuallyAddedSceneObjectIsNotInAutoUnlockList()
        {
            // Given a step with a condition with a LockableProperty and a collection referencing this step
            Step step = new BasicStepBuilder("step").Build();
            LockableObjectsCollection collection = new LockableObjectsCollection(step.Data);

            // When we create a SceneObject with a lockable property
            ISceneObject     o1 = TestingUtils.CreateSceneObject("o1");
            LockableProperty lockableProperty = o1.GameObject.AddComponent <LockablePropertyMock>();

            // ...and add the SceneObject and its property to the collection
            collection.AddSceneObject(o1);
            collection.Add(lockableProperty);

            // Then the lockable property is not in the Auto Unlock List of the collection
            Assert.IsFalse(collection.IsInAutoUnlockList(lockableProperty));

            yield return(null);
        }
예제 #8
0
        public IEnumerator RemovedPropertyIsNotInManualUnlockList()
        {
            // Given a step with a condition with a LockableProperty
            Step step = new BasicStepBuilder("step").Build();
            // ...and a collection with a manually added SceneObject and an added lockable property
            LockableObjectsCollection collection = new LockableObjectsCollection(step.Data);
            ISceneObject     o1 = TestingUtils.CreateSceneObject("o1");
            LockableProperty lockableProperty = o1.GameObject.AddComponent <LockablePropertyMock>();

            collection.AddSceneObject(o1);
            collection.Add(lockableProperty);

            // When we remove the property from the collection
            collection.Remove(lockableProperty);

            // Then the lockable property is not in the Auto Unlock List of the collection
            Assert.IsFalse(collection.IsInAutoUnlockList(lockableProperty));

            yield return(null);
        }
예제 #9
0
 public void Add(LockableProperty property)
 {
     data.ToUnlock = data.ToUnlock.Union(new [] { new LockablePropertyReference(property), }).ToList();
 }
예제 #10
0
 public void Remove(LockableProperty property)
 {
     data.ToUnlock = data.ToUnlock.Where(reference => reference.GetProperty() != property).ToList();
 }
예제 #11
0
 public LockablePropertyReference(LockableProperty property)
 {
     Target = new SceneObjectReference(property.SceneObject.UniqueName);
     Type   = property.GetType().AssemblyQualifiedName;
 }
예제 #12
0
 public LockablePropertyData(LockableProperty property, bool endStepLocked)
 {
     EndStepLocked = endStepLocked;
     Property      = property;
 }
예제 #13
0
 public LockablePropertyData(LockableProperty property) : this(property, property.EndStepLocked)
 {
 }