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