This repository has been archived by the owner on Dec 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
ResourcePoolBase.cs
98 lines (84 loc) · 4.21 KB
/
ResourcePoolBase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using UnityEngine;
namespace Archon.SwissArmyLib.ResourceSystem
{
/// <summary>
/// Non-generic base class for <see cref="ResourcePool"/> to allow its editor to work for subclasses.
/// </summary>
public abstract class ResourcePoolBase : MonoBehaviour
{
/// <summary>
/// Gets the current amount of resource in this pool.
/// </summary>
public abstract float Current { get; protected set; }
/// <summary>
/// Gets or sets the maximum amount of source that can be in this pool.
/// </summary>
public abstract float Max { get; set; }
/// <summary>
/// Gets or sets whether adding resource should be disabled after the pool is completely empty, until it is renewed again.
/// </summary>
public abstract bool EmptyTillRenewed { get; set; }
/// <summary>
/// Gets a how full the resource is percentage-wise (0 to 1)
/// </summary>
public abstract float Percentage { get; }
/// <summary>
/// Gets whether the pool is completely empty.
/// </summary>
public abstract bool IsEmpty { get; }
/// <summary>
/// Gets whether the pool is completely empty.
/// </summary>
public abstract bool IsFull { get; }
/// <summary>
/// Get the (scaled) time since this pool was last empty.
/// </summary>
public abstract float TimeSinceEmpty { get; }
/// <summary>
/// Adds the specified amount of resource to the pool.
/// </summary>
/// <param name="amount">The amount to add.</param>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Add(float amount, bool forced = false);
/// <summary>
/// Removes the specified amount of resource to the pool.
/// </summary>
/// <param name="amount">The amount to remove.</param>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Remove(float amount, bool forced = false);
/// <summary>
/// Completely empties the pool.
/// </summary>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Empty(bool forced = false);
/// <summary>
/// Fully fills the pool.
/// </summary>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Fill(bool forced = false);
/// <summary>
/// Fills the pool to the specified amount.
/// </summary>
/// <param name="toValue">The amount of resource to restore to.</param>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Fill(float toValue, bool forced = false);
/// <summary>
/// Fully restores the pool, regardless of <see cref="ResourcePool{TSource,TArgs}.EmptyTillRenewed"/>.
/// </summary>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Renew(bool forced = false);
/// <summary>
/// Restores the pool to the specified amount, regardless of <see cref="ResourcePool{TSource,TArgs}.EmptyTillRenewed"/>.
/// </summary>
/// <param name="toValue">The amount of resource to restore to.</param>
/// <param name="forced">Controls whether to force the change, despite modifications by listeners.</param>
/// <returns>The resulting change in the pool.</returns>
public abstract float Renew(float toValue, bool forced = false);
}
}