/// <summary> /// Unsafe method for getting a <see cref="ParticleFieldAccessor"/>. /// If the field doesn't exist an invalid accessor is returned to the user. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="fieldDesc"></param> /// <returns></returns> public ParticleFieldAccessor <T> GetField <T>(ParticleFieldDescription <T> fieldDesc) where T : struct { ParticleField field; return(fields.TryGetValue(fieldDesc, out field) ? new ParticleFieldAccessor <T>(field) : ParticleFieldAccessor <T> .Invalid()); }
/// <summary> /// Gets the particle field with the specified description if the field exists in this pool /// </summary> /// <typeparam name="T">Type data for the field</typeparam> /// <param name="fieldDesc">Field's decription</param> /// <param name="accessor">Accessor for the field</param> /// <returns></returns> public bool TryGetField <T>(ParticleFieldDescription <T> fieldDesc, out ParticleFieldAccessor <T> accessor) where T : struct { ParticleField field; if (!fields.TryGetValue(fieldDesc, out field)) { accessor = ParticleFieldAccessor <T> .Invalid(); return(false); } accessor = new ParticleFieldAccessor <T>(field); return(true); }