Package com.prineside.tdi2.utils
Class MultiReasonBool
java.lang.Object
com.prineside.tdi2.utils.MultiReasonBool
- All Implemented Interfaces:
KryoSerializable
Acts as a regular boolean field / flag which can be affected by multiple sources.
Instead of storing a plain "true" / "false" data, it stores a list of reasons why the field is
true, and acts as a boolean "true" (isTrue() method) if there's at least one reason.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Sets maximum durationboolean
void
clear()
int
Use getReasonCount() first If reason count is 0, this method may return null Iteration:String[] reasons = getReasonsBuffer(); for (int i = 0, n = bool.getReasonCount(); i < n; i++) { reasons[i] ...
boolean
boolean
isTrue()
void
boolean
removeReason
(String reason) void
update
(float deltaTime) Expire reasonsvoid
-
Constructor Details
-
MultiReasonBool
public MultiReasonBool()
-
-
Method Details
-
write
- Specified by:
write
in interfaceKryoSerializable
-
read
- Specified by:
read
in interfaceKryoSerializable
-
addReason
Sets maximum duration- Returns:
- true if added or updated
-
addReason
- Returns:
- true if added or updated
-
hasReason
-
removeReason
- Returns:
- true if has been removed
-
getReasonCount
public int getReasonCount() -
isTrue
public boolean isTrue() -
update
public void update(float deltaTime) Expire reasons -
clear
public void clear() -
getReasonsBuffer
Use getReasonCount() first If reason count is 0, this method may return null Iteration:String[] reasons = getReasonsBuffer(); for (int i = 0, n = bool.getReasonCount(); i < n; i++) { reasons[i] ... }
-