Skip to content

Commit cca333e

Browse files
committed
v1.5.5-rc.1
1 parent 8958dc4 commit cca333e

18 files changed

+204
-444
lines changed
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region License
22

3-
// Copyright (c) 2018-2020, exomia
3+
// Copyright (c) 2018-2021, exomia
44
// All rights reserved.
55
//
66
// This source code is licensed under the BSD-style license found in the
@@ -12,33 +12,23 @@
1212

1313
namespace Exomia.ECS.Attributes
1414
{
15-
/// <summary>
16-
/// Attribute for entity component configuration. This class cannot be inherited.
17-
/// </summary>
15+
/// <summary> Attribute for entity component configuration. This class cannot be inherited. </summary>
1816
[AttributeUsage(AttributeTargets.Class)]
1917
public sealed class EntityComponentConfigurationAttribute : Attribute
2018
{
21-
/// <summary>
22-
/// True to use pooling.
23-
/// </summary>
24-
internal bool _usePooling;
19+
internal bool UsePooling;
2520

26-
/// <summary>
27-
/// Gets or sets the pool size.
28-
/// </summary>
29-
/// <value>
30-
/// The size of the pool.
31-
/// </value>
21+
/// <summary> Gets or sets the pool size. </summary>
22+
/// <value> The size of the pool. </value>
3223
public int PoolSize { get; set; } = EntityManager.INITIAL_ARRAY_SIZE;
3324

3425
/// <summary>
35-
/// Initializes a new instance of the <see cref="EntityComponentConfigurationAttribute" />
36-
/// class.
26+
/// Initializes a new instance of the <see cref="EntityComponentConfigurationAttribute" /> class.
3727
/// </summary>
38-
/// <param name="usePooling"> True to use pooling. </param>
28+
/// <param name="usePooling"> (Optional) True to use pooling. </param>
3929
public EntityComponentConfigurationAttribute(bool usePooling = true)
4030
{
41-
_usePooling = usePooling;
31+
UsePooling = usePooling;
4232
}
4333
}
4434
}

src/Exomia.ECS/Attributes/EntitySystemConfigurationAttribute.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region License
22

3-
// Copyright (c) 2018-2020, exomia
3+
// Copyright (c) 2018-2021, exomia
44
// All rights reserved.
55
//
66
// This source code is licensed under the BSD-style license found in the
@@ -17,9 +17,6 @@ namespace Exomia.ECS.Attributes
1717
[AttributeUsage(AttributeTargets.Class)]
1818
public sealed class EntitySystemConfigurationAttribute : Attribute
1919
{
20-
/// <summary>
21-
/// The name.
22-
/// </summary>
2320
internal readonly string Name;
2421

2522
/// <summary> Gets or sets the list of system names which has to be executed after this one. </summary>

src/Exomia.ECS/Entity.cs

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region License
22

3-
// Copyright (c) 2018-2020, exomia
3+
// Copyright (c) 2018-2021, exomia
44
// All rights reserved.
55
//
66
// This source code is licensed under the BSD-style license found in the
@@ -13,63 +13,33 @@
1313

1414
namespace Exomia.ECS
1515
{
16-
/// <summary>
17-
/// An entity. This class cannot be inherited.
18-
/// </summary>
16+
/// <summary> An entity. This class cannot be inherited. </summary>
1917
public sealed class Entity
2018
{
21-
/// <summary>
22-
/// Initial size of the components.
23-
/// </summary>
2419
private const int INITIAL_COMPONENTS_SIZE = 8;
2520

26-
/// <summary>
27-
/// True if this object is initialized.
28-
/// </summary>
29-
internal bool _isInitialized = false;
30-
31-
/// <summary>
32-
/// The group flags.
33-
/// </summary>
34-
internal uint _systemFlags = 0u;
35-
36-
/// <summary>
37-
/// The components.
38-
/// </summary>
21+
internal bool IsInitialized = false;
22+
internal uint SystemFlags = 0u;
3923
private readonly Dictionary<Type, object> _components;
4024

41-
/// <summary>
42-
/// Unique identifier.
43-
/// </summary>
25+
/// <summary> Unique identifier. </summary>
26+
/// <value> The identifier of the unique. </value>
4427
public Guid Guid { get; internal set; }
4528

46-
/// <summary>
47-
/// Gets the components.
48-
/// </summary>
49-
/// <value>
50-
/// The components.
51-
/// </value>
5229
internal IEnumerable<object> Components
5330
{
5431
get { return _components.Values; }
5532
}
5633

57-
/// <summary>
58-
/// Initializes a new instance of the <see cref="Entity" /> class.
59-
/// </summary>
6034
internal Entity()
6135
{
6236
_components = new Dictionary<Type, object>(INITIAL_COMPONENTS_SIZE);
6337
}
6438

65-
/// <summary>
66-
/// Gets a bool using the given component.
67-
/// </summary>
39+
/// <summary> Gets a bool using the given component. </summary>
6840
/// <typeparam name="T"> Generic type parameter. </typeparam>
6941
/// <param name="component"> [out] The component. </param>
70-
/// <returns>
71-
/// True if it succeeds, false if it fails.
72-
/// </returns>
42+
/// <returns> True if it succeeds, false if it fails. </returns>
7343
public bool Get<T>(out T component)
7444
where T : class
7545
{
@@ -78,30 +48,25 @@ public bool Get<T>(out T component)
7848
return res;
7949
}
8050

81-
/// <inheritdoc />
51+
/// <inheritdoc/>
8252
public override bool Equals(object obj)
8353
{
8454
return obj is Entity other && Guid.Equals(other.Guid);
8555
}
8656

87-
/// <inheritdoc />
57+
/// <inheritdoc/>
8858
public override int GetHashCode()
8959
{
9060
// ReSharper disable once NonReadonlyMemberInGetHashCode
9161
return Guid.GetHashCode();
9262
}
9363

94-
/// <inheritdoc />
64+
/// <inheritdoc/>
9565
public override string ToString()
9666
{
97-
return $"[{Guid}]";
67+
return $"[{Guid.ToString()}]";
9868
}
9969

100-
/// <summary>
101-
/// Adds component.
102-
/// </summary>
103-
/// <typeparam name="T"> Generic type parameter. </typeparam>
104-
/// <param name="component"> The component. </param>
10570
internal void Add<T>(T component)
10671
where T : class
10772
{
@@ -111,13 +76,6 @@ internal void Add<T>(T component)
11176
_components.Add(typeof(T), component!);
11277
}
11378

114-
/// <summary>
115-
/// Removes this object.
116-
/// </summary>
117-
/// <typeparam name="T"> Generic type parameter. </typeparam>
118-
/// <returns>
119-
/// True if it succeeds, false if it fails.
120-
/// </returns>
12179
internal bool Remove<T>()
12280
where T : class
12381
{

src/Exomia.ECS/EntityComponentPool.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region License
22

3-
// Copyright (c) 2018-2020, exomia
3+
// Copyright (c) 2018-2021, exomia
44
// All rights reserved.
55
//
66
// This source code is licensed under the BSD-style license found in the
@@ -15,49 +15,33 @@
1515
using Exomia.ECS.Attributes;
1616

1717
// ReSharper disable StaticMemberInGenericType
18-
1918
namespace Exomia.ECS
2019
{
21-
/// <summary>
22-
/// An entity component pool.
23-
/// </summary>
24-
static class EntityComponentPool
20+
internal static class EntityComponentPool
2521
{
26-
/// <summary>
27-
/// Releases the given component.
28-
/// </summary>
29-
/// <typeparam name="TComponent"> Type of the component. </typeparam>
30-
/// <param name="component"> The component. </param>
3122
public static void Release<TComponent>(TComponent component)
3223
where TComponent : class
3324
{
3425
EntityComponentPool<TComponent>.Release(component);
3526
}
3627
}
3728

38-
/// <summary>
39-
/// An entity component pool.
40-
/// </summary>
41-
/// <typeparam name="TComponent"> Type of the component. </typeparam>
42-
static class EntityComponentPool<TComponent>
29+
internal static class EntityComponentPool<TComponent>
4330
where TComponent : class
4431
{
4532
private static readonly bool s_usePooling;
4633
private static readonly Stack<TComponent> s_free = null!;
4734
private static readonly Func<TComponent> s_getInstance;
4835

49-
/// <summary>
50-
/// Initializes static members of the <see cref="EntityComponentPool{TComponent}" /> class.
51-
/// </summary>
5236
static EntityComponentPool()
5337
{
5438
s_getInstance = Expression.Lambda<Func<TComponent>>(Expression.New(typeof(TComponent))).Compile();
5539

5640
EntityComponentConfigurationAttribute cfg =
5741
typeof(TComponent).GetCustomAttribute<EntityComponentConfigurationAttribute>(false)
58-
?? new EntityComponentConfigurationAttribute();
42+
?? new EntityComponentConfigurationAttribute();
5943

60-
s_usePooling = cfg._usePooling;
44+
s_usePooling = cfg.UsePooling;
6145
if (!s_usePooling) { return; }
6246

6347
s_free = new Stack<TComponent>(cfg.PoolSize);

src/Exomia.ECS/EntityManager.DrawableComponent.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region License
22

3-
// Copyright (c) 2018-2020, exomia
3+
// Copyright (c) 2018-2021, exomia
44
// All rights reserved.
55
//
66
// This source code is licensed under the BSD-style license found in the
@@ -15,12 +15,13 @@
1515

1616
namespace Exomia.ECS
1717
{
18+
/// <content> Manager for entities. This class cannot be inherited. </content>
1819
public sealed partial class EntityManager : DrawableComponent
1920
{
2021
private readonly Entity[] _currentlyToChanged = new Entity[INITIAL_ARRAY_SIZE];
2122
private readonly Entity[] _currentlyToRemove = new Entity[INITIAL_ARRAY_SIZE];
2223

23-
/// <inheritdoc />
24+
/// <inheritdoc/>
2425
public override void Update(GameTime gameTime)
2526
{
2627
int currentlyToRemoveCount;
@@ -39,7 +40,7 @@ public override void Update(GameTime gameTime)
3940
for (int si = _entitySystemsCount - 1; si >= 0; si--)
4041
{
4142
EntitySystemBase system = _entitySystems[si];
42-
if (entity._systemFlags == 0 || (entity._systemFlags & system.SystemMask) == system.SystemMask)
43+
if (entity.SystemFlags == 0 || (entity.SystemFlags & system.SystemMask) == system.SystemMask)
4344
{
4445
system.Remove(entity);
4546
}
@@ -62,7 +63,7 @@ public override void Update(GameTime gameTime)
6263
for (int si = _entitySystemsCount - 1; si >= 0; si--)
6364
{
6465
EntitySystemBase system = _entitySystems[si];
65-
if (entity._systemFlags == 0 || (entity._systemFlags & system.SystemMask) == system.SystemMask)
66+
if (entity.SystemFlags == 0 || (entity.SystemFlags & system.SystemMask) == system.SystemMask)
6667
{
6768
system.Changed(entity);
6869
}
@@ -79,7 +80,7 @@ public override void Update(GameTime gameTime)
7980
}
8081
}
8182

82-
/// <inheritdoc />
83+
/// <inheritdoc/>
8384
public override void Draw(GameTime gameTime)
8485
{
8586
for (int i = 0; i < _entityDrawableSystemsCount; i++)
@@ -93,7 +94,7 @@ public override void Draw(GameTime gameTime)
9394
}
9495
}
9596

96-
/// <inheritdoc />
97+
/// <inheritdoc/>
9798
protected override void OnInitialize(IServiceRegistry registry)
9899
{
99100
for (int si = _entitySystemsCount - 1; si >= 0; si--)
@@ -104,7 +105,7 @@ protected override void OnInitialize(IServiceRegistry registry)
104105

105106
#region IDisposable Support
106107

107-
/// <inheritdoc />
108+
/// <inheritdoc/>
108109
protected override void OnDispose(bool disposing)
109110
{
110111
if (disposing)

0 commit comments

Comments
 (0)