Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParticleFieldAccessor.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 namespace SiliconStudio.Paradox.Particles
4 {
5  /// <summary>
6  /// Specifies how to access a <see cref="ParticleFieldDescription"/> in a given <see cref="ParticleSystem"/> instance.
7  /// </summary>
8  public struct ParticleFieldAccessor
9  {
10  private readonly int offset;
11 
12  internal ParticleFieldAccessor(ParticleField field)
13  {
14  this.offset = field.Offset;
15  }
16 
17  public ParticleFieldAccessor(int offset)
18  {
19  this.offset = offset;
20  }
21 
22  public bool IsValid()
23  {
24  return this.offset != -1;
25  }
26 
27  public static implicit operator int(ParticleFieldAccessor accessor)
28  {
29  return accessor.offset;
30  }
31  }
32 
33  /// <summary>
34  /// Specifies how to access a <see cref="ParticleFieldDescription{T}"/> in a given <see cref="ParticleSystem"/> instance.
35  /// </summary>
36  /// <typeparam name="T">Type of the field.</typeparam>
37  public struct ParticleFieldAccessor<T>
38  {
39  private readonly int offset;
40 
41  internal ParticleFieldAccessor(ParticleField field)
42  {
43  this.offset = field.Offset;
44  }
45 
46  public ParticleFieldAccessor(int offset)
47  {
48  this.offset = offset;
49  }
50 
51  public bool IsValid()
52  {
53  return this.offset != -1;
54  }
55 
56  public static implicit operator ParticleFieldAccessor(ParticleFieldAccessor<T> field)
57  {
58  return new ParticleFieldAccessor(field.offset);
59  }
60 
61  public static implicit operator int(ParticleFieldAccessor<T> accessor)
62  {
63  return accessor.offset;
64  }
65  }
66 }
Specifies how to access a ParticleFieldDescription in a given ParticleSystem instance.
Specifies how to access a ParticleFieldDescription{T} in a given ParticleSystem instance.