Merging 1.7.5 Source: actors/buffs changes

This commit is contained in:
Evan Debenham
2015-01-30 17:16:05 -05:00
parent d50c566579
commit 9e79aab869
8 changed files with 82 additions and 38 deletions
@@ -56,19 +56,29 @@ public class Buff extends Actor {
public int icon() {
return BuffIndicator.NONE;
}
public static<T extends Buff> T append( Char target, Class<T> buffClass ) {
try {
T buff = buffClass.newInstance();
buff.attachTo( target );
return buff;
} catch (Exception e) {
return null;
}
}
public static<T extends FlavourBuff> T append( Char target, Class<T> buffClass, float duration ) {
T buff = append( target, buffClass );
buff.spend( duration );
return buff;
}
public static<T extends Buff> T affect( Char target, Class<T> buffClass ) {
T buff = target.buff( buffClass );
if (buff != null) {
return buff;
} else {
try {
buff = buffClass.newInstance();
buff.attachTo( target );
return buff;
} catch (Exception e) {
return null;
}
return append( target, buffClass );
}
}