示例#1
0
        public void Execute(Entity entity, int index, ref AnimatorStatesComponentData states)
        {
            if (!states.out_StateChangedEventFlag)
            {
                return;
            }
            //states.stateChangedEventFlag = false;

            var setData = new SetterData()
            {
                entity = entity, animation = AnimationType.IDLE
            };

            if (states.running)
            {
                setData.animation = AnimationType.RUN;
            }
            if (states.climbing)
            {
                setData.animation = AnimationType.CLIMB;
            }
            if (states.fighting)
            {
                setData.animation = AnimationType.FIGHT;
            }
            if (states.shooting)
            {
                setData.animation = AnimationType.SHOOT;
            }

            animationsToSet.Enqueue(setData);
        }
示例#2
0
        public override void Set(UIElement element)
        {
            IDataDescriptor  dd;
            DependencyObject targetObject;

            if (!FindPropertyDescriptor(element, out dd, out targetObject))
            {
                return;
            }
            SetterData setterData = GetSetterData(targetObject);

            if (setterData != null)
            {
                // If any setter is currently setting our property, we don't want to interfere
                return;
            }
            object obj;

            // The next lines are necessary because the render thread is setting our values.
            // If there's still a value pending to be set by the render thread, we would get an old, obsolete value if
            // we just copied dd.Value to _originalValue.
            element.GetPendingOrCurrentValue(dd, out obj);
            SetSetterData(targetObject, new SetterData(obj));

            object value = Value;

            if (TypeConverter.Convert(value, dd.DataType, out obj))
            {
                if (ReferenceEquals(value, obj))
                {
                    SetDataDescriptorValueWithLP(dd, MpfCopyManager.DeepCopyCutLVPs(obj));
                }
                else
                {
                    // Avoid creating a copy twice
                    SetDataDescriptorValueWithLP(dd, obj);
                }
            }
            else
            {
                // Value is not compatible: We cannot execute
                ServiceRegistration.Get <ILogger>().Warn("Setter for property '{0}': Cannot convert value {1} to target type {2}", _propertyName,
                                                         value == null ? "'null'" : ("of type " + value.GetType().Name), dd.DataType.Name);
                return;
            }
        }
示例#3
0
        public override void Restore(UIElement element)
        {
            IDataDescriptor  dd;
            DependencyObject targetObject;

            if (!FindPropertyDescriptor(element, out dd, out targetObject))
            {
                return;
            }
            SetterData setterData = GetSetterData(targetObject);

            if (setterData == null)
            {
                return;
            }
            element.SetValueInRenderThread(dd, setterData.OrigValue);
            ClearSetterData(targetObject);
        }
示例#4
0
 protected void SetSetterData(DependencyObject targetObject, SetterData setterData)
 {
     targetObject.SetAttachedPropertyValue(GetAttachedPropertyName(), setterData);
 }
示例#5
0
 protected void SetSetterData(DependencyObject targetObject, SetterData setterData)
 {
   targetObject.SetAttachedPropertyValue(GetAttachedPropertyName(), setterData);
 }