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); }
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; } }
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); }
protected void SetSetterData(DependencyObject targetObject, SetterData setterData) { targetObject.SetAttachedPropertyValue(GetAttachedPropertyName(), setterData); }