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.
 Max 127 reasons at the same time.
- 
Nested Class Summary
Nested Classes - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleanSets maximum durationbooleanaddReasonForDuration(String reason, float duration) voidclear()intUse 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] ...booleanbooleanisTrue()voidbooleanremoveReason(String reason) voidupdate(float deltaTime) Expire reasonsvoid 
- 
Constructor Details
- 
MultiReasonBool
public MultiReasonBool() 
 - 
 - 
Method Details
- 
write
- Specified by:
 writein interfaceKryoSerializable
 - 
read
- Specified by:
 readin interfaceKryoSerializable
 - 
addReason
Sets maximum duration- Returns:
 - true if added or updated
 
 - 
addReasonForDuration
- 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] ... } 
 -