protected override void AssignNextValue(EffectableObject obj, float nextVal) { var prevVec = obj.Get <Vector2>(EffectedPropertyName); prevVec.X = nextVal; obj.Set(EffectedPropertyName, prevVec); }
public virtual void InternalInitialize(EffectableObject obj) { if (Initialized) { string exceptionMessage = "The most likely cause for this is the same effector " + "was added to multiple objects. Check to ensure you aren't reusing the same " + "effector instance."; if (Anonymous) { exceptionMessage = String.Format( "Anonymous effector of type '{0}' was initialized twice.", this.GetType()) + exceptionMessage; } else { exceptionMessage = String.Format( "Effector with name '{0}' and type '{1}' was initialized twice.", EffectorName, this.GetType()) + exceptionMessage; } throw new EffectorException(exceptionMessage); } if (ValueType == EffectorValueType.RelativeToStart) { InitialValues.Add(obj, CoerceTo((T1)obj.Get(EffectedPropertyName))); } // If this effector is reusable, then it may be used for multiple // ArtemisObject instances, meaning we can't store an internal reference // to any single one. // // The advantage of using a non-reusable effector over a reusable one is // that the effector can initialize it's own properties based on it's // assigned instance. if (!Reusable) { Object = obj; } Initialize(); Initialized = true; }