/// <summary> /// Initializes a new instance of the <see cref="ParticleSystem" /> class. /// </summary> public ParticleSystem() { // Initialize collections Plugins = new TrackingCollection <IParticlePlugin>(); // Add default position field Position = new ParticleFieldAccessor <Vector3>(AddField(ParticleFields.Position)); Angle = new ParticleFieldAccessor <float>(AddField(ParticleFields.Angle)); EnsureCapacity(particleDefaultCapacity); Plugins.CollectionChanged += Plugins_CollectionChanged; }
/// <summary> /// Gets the pointer to the specifield field. /// </summary> /// <value> /// The field pointer, as an <see cref="IntPtr" />. /// </value> /// <param name="fieldAccessor">The field accessor.</param> /// <returns>The field pointer.</returns> public IntPtr this[ParticleFieldAccessor fieldAccessor] { get { return(Pointer + fieldAccessor); } }
/// <summary> /// Sets the specified field value. /// </summary> /// <typeparam name="T">The field type.</typeparam> /// <param name="fieldAccessor">The field accessor.</param> /// <param name="value">The field value.</param> public void Set <T>(ParticleFieldAccessor <T> fieldAccessor, T value) where T : struct { Utilities.Write <T>(Pointer + fieldAccessor, ref value); }
/// <summary> /// Gets the specified field value. /// </summary> /// <typeparam name="T">The field type.</typeparam> /// <param name="fieldAccessor">The field accessor.</param> /// <returns>The field value.</returns> public T Get <T>(ParticleFieldAccessor <T> fieldAccessor) where T : struct { return(Utilities.Read <T>(Pointer + fieldAccessor)); }