Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Particle.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using SiliconStudio.Paradox.Games;
5 using SiliconStudio.Core;
6 
7 namespace SiliconStudio.Paradox.Particles
8 {
9  /// <summary>
10  /// A particle in the particle system.
11  /// </summary>
12  public struct Particle
13  {
14  public readonly IntPtr Pointer;
15 
16  public Particle(IntPtr pointer)
17  {
18  this.Pointer = pointer;
19  }
20 
21  /// <summary>
22  /// Gets the specified field value.
23  /// </summary>
24  /// <typeparam name="T">The field type.</typeparam>
25  /// <param name="fieldAccessor">The field accessor.</param>
26  /// <returns>The field value.</returns>
27  public T Get<T>(ParticleFieldAccessor fieldAccessor) where T : struct
28  {
29  return Utilities.Read<T>(Pointer + fieldAccessor);
30  }
31 
32  /// <summary>
33  /// Sets the specified field value.
34  /// </summary>
35  /// <typeparam name="T">The field type.</typeparam>
36  /// <param name="fieldAccessor">The field accessor.</param>
37  /// <param name="value">The field value.</param>
38  public void Set<T>(ParticleFieldAccessor fieldAccessor, ref T value) where T : struct
39  {
40  Utilities.Write<T>(Pointer + fieldAccessor, ref value);
41  }
42 
43  /// <summary>
44  /// Sets the specified field value.
45  /// </summary>
46  /// <typeparam name="T">The field type.</typeparam>
47  /// <param name="fieldAccessor">The field accessor.</param>
48  /// <param name="value">The field value.</param>
49  public void Set<T>(ParticleFieldAccessor fieldAccessor, T value) where T : struct
50  {
51  Utilities.Write<T>(Pointer + fieldAccessor, ref value);
52  }
53 
54  /// <summary>
55  /// Gets the specified field value.
56  /// </summary>
57  /// <typeparam name="T">The field type.</typeparam>
58  /// <param name="fieldAccessor">The field accessor.</param>
59  /// <returns>The field value.</returns>
60  public T Get<T>(ParticleFieldAccessor<T> fieldAccessor) where T : struct
61  {
62  return Utilities.Read<T>(Pointer + fieldAccessor);
63  }
64 
65  /// <summary>
66  /// Sets the specified field value.
67  /// </summary>
68  /// <typeparam name="T">The field type.</typeparam>
69  /// <param name="fieldAccessor">The field accessor.</param>
70  /// <param name="value">The field value.</param>
71  public void Set<T>(ParticleFieldAccessor<T> fieldAccessor, ref T value) where T : struct
72  {
73  Utilities.Write<T>(Pointer + fieldAccessor, ref value);
74  }
75 
76  /// <summary>
77  /// Sets the specified field value.
78  /// </summary>
79  /// <typeparam name="T">The field type.</typeparam>
80  /// <param name="fieldAccessor">The field accessor.</param>
81  /// <param name="value">The field value.</param>
82  public void Set<T>(ParticleFieldAccessor<T> fieldAccessor, T value) where T : struct
83  {
84  Utilities.Write<T>(Pointer + fieldAccessor, ref value);
85  }
86 
87  /// <summary>
88  /// Gets the pointer to the specifield field.
89  /// </summary>
90  /// <value>
91  /// The field pointer, as an <see cref="IntPtr" />.
92  /// </value>
93  /// <param name="fieldAccessor">The field accessor.</param>
94  /// <returns>The field pointer.</returns>
95  public IntPtr this[ParticleFieldAccessor fieldAccessor]
96  {
97  get { return Pointer + fieldAccessor; }
98  }
99  }
100 }
Specifies how to access a ParticleFieldDescription in a given ParticleSystem instance.
A particle in the particle system.
Definition: Particle.cs:12
Specifies how to access a ParticleFieldDescription{T} in a given ParticleSystem instance.