Merging 1.7.5 Source: actors/buffs changes
This commit is contained in:
parent
d50c566579
commit
9e79aab869
|
@ -57,19 +57,29 @@ public class Buff extends Actor {
|
|||
return BuffIndicator.NONE;
|
||||
}
|
||||
|
||||
public static<T extends Buff> T affect( Char target, Class<T> buffClass ) {
|
||||
T buff = target.buff( buffClass );
|
||||
if (buff != null) {
|
||||
return buff;
|
||||
} else {
|
||||
public static<T extends Buff> T append( Char target, Class<T> buffClass ) {
|
||||
try {
|
||||
buff = buffClass.newInstance();
|
||||
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 {
|
||||
return append( target, buffClass );
|
||||
}
|
||||
}
|
||||
|
||||
public static<T extends FlavourBuff> T affect( Char target, Class<T> buffClass, float duration ) {
|
||||
|
|
|
@ -20,23 +20,24 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.Resistance;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
public class Charm extends FlavourBuff {
|
||||
|
||||
public int object = 0;
|
||||
|
||||
private static final String OBJECT = "object";
|
||||
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
if (super.attachTo( target )) {
|
||||
target.pacified = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( OBJECT, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
target.pacified = false;
|
||||
super.detach();
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
object = bundle.getInt( OBJECT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
//Special kind of buff, that doesn't perform any kind actions
|
||||
//buff which does not need to act, used as a flag for other logic.
|
||||
public class FlavourBuff extends Buff {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,8 +56,8 @@ public class Frost extends FlavourBuff {
|
|||
|
||||
@Override
|
||||
public void detach() {
|
||||
target.paralysed = false;
|
||||
super.detach();
|
||||
Paralysis.unfreeze( target );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,6 @@ public class Light extends FlavourBuff {
|
|||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
if (super.attachTo( target )) {
|
||||
// When a level is loading, do nothing
|
||||
if (Dungeon.level != null) {
|
||||
target.viewDistance = Math.max( Dungeon.level.viewDistance, DISTANCE );
|
||||
Dungeon.observe();
|
||||
|
|
|
@ -37,8 +37,8 @@ public class Paralysis extends FlavourBuff {
|
|||
|
||||
@Override
|
||||
public void detach() {
|
||||
target.paralysed = false;
|
||||
super.detach();
|
||||
unfreeze(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,4 +55,12 @@ public class Paralysis extends FlavourBuff {
|
|||
Resistance r = ch.buff( Resistance.class );
|
||||
return r != null ? r.durationFactor() * DURATION : DURATION;
|
||||
}
|
||||
|
||||
public static void unfreeze( Char ch ) {
|
||||
if (ch.buff( Paralysis.class ) == null &&
|
||||
ch.buff( Frost.class ) == null) {
|
||||
|
||||
ch.paralysed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,28 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
//TODO: consider refactoring this
|
||||
public class SnipersMark extends FlavourBuff {
|
||||
|
||||
public int object = 0;
|
||||
|
||||
private static final String OBJECT = "object";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( OBJECT, object );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
object = bundle.getInt( OBJECT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.MARK;
|
||||
|
@ -28,6 +47,6 @@ public class SnipersMark extends FlavourBuff {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sniper's mark";
|
||||
return "Zeroed in";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
@ -25,18 +24,26 @@ import com.watabou.utils.Bundle;
|
|||
public class Terror extends FlavourBuff {
|
||||
|
||||
public static final float DURATION = 10f;
|
||||
public Char source;
|
||||
|
||||
public int object = 0;
|
||||
|
||||
private static final String OBJECT = "object";
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.TERROR;
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(OBJECT, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
// It's not really correct...
|
||||
source = Dungeon.hero;
|
||||
object = bundle.getInt( OBJECT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.TERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user