v0.6.2: Code for well water now supports more than one well at a time
This commit is contained in:
parent
4a8373246b
commit
8fb8061ee1
|
@ -217,17 +217,21 @@ public class Blob extends Actor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static<T extends Blob> T seed( int cell, int amount, Class<T> type ) {
|
public static<T extends Blob> T seed( int cell, int amount, Class<T> type ) {
|
||||||
try {
|
return seed(cell, amount, type, Dungeon.level);
|
||||||
|
|
||||||
T gas = (T)Dungeon.level.blobs.get( type );
|
|
||||||
if (gas == null) {
|
|
||||||
gas = type.newInstance();
|
|
||||||
Dungeon.level.blobs.put( type, gas );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gas.seed( Dungeon.level, cell, amount );
|
@SuppressWarnings("unchecked")
|
||||||
|
public static<T extends Blob> T seed( int cell, int amount, Class<T> type, Level level ) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
T gas = (T)level.blobs.get( type );
|
||||||
|
if (gas == null) {
|
||||||
|
gas = type.newInstance();
|
||||||
|
level.blobs.put( type, gas );
|
||||||
|
}
|
||||||
|
|
||||||
|
gas.seed( level, cell, amount );
|
||||||
|
|
||||||
return gas;
|
return gas;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
|
@ -70,8 +69,6 @@ public class WaterOfAwareness extends WellWater {
|
||||||
|
|
||||||
GLog.p( Messages.get(this, "procced") );
|
GLog.p( Messages.get(this, "procced") );
|
||||||
|
|
||||||
Notes.remove( Landmark.WELL_OF_AWARENESS );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +82,15 @@ public class WaterOfAwareness extends WellWater {
|
||||||
|
|
||||||
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
|
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
|
||||||
|
|
||||||
Notes.remove( Landmark.WELL_OF_AWARENESS );
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Landmark record() {
|
||||||
|
return Landmark.WELL_OF_AWARENESS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void use( BlobEmitter emitter ) {
|
public void use( BlobEmitter emitter ) {
|
||||||
super.use( emitter );
|
super.use( emitter );
|
||||||
|
|
|
@ -32,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.DewVial;
|
import com.shatteredpixel.shatteredpixeldungeon.items.DewVial;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
@ -58,8 +57,6 @@ public class WaterOfHealth extends WellWater {
|
||||||
|
|
||||||
GLog.p( Messages.get(this, "procced") );
|
GLog.p( Messages.get(this, "procced") );
|
||||||
|
|
||||||
Notes.remove( Landmark.WELL_OF_HEALTH );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +64,17 @@ public class WaterOfHealth extends WellWater {
|
||||||
protected Item affectItem( Item item ) {
|
protected Item affectItem( Item item ) {
|
||||||
if (item instanceof DewVial && !((DewVial)item).isFull()) {
|
if (item instanceof DewVial && !((DewVial)item).isFull()) {
|
||||||
((DewVial)item).fill();
|
((DewVial)item).fill();
|
||||||
Notes.remove( Landmark.WELL_OF_HEALTH );
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Landmark record() {
|
||||||
|
return Landmark.WELL_OF_HEALTH;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void use( BlobEmitter emitter ) {
|
public void use( BlobEmitter emitter ) {
|
||||||
super.use( emitter );
|
super.use( emitter );
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
|
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||||
|
@ -40,7 +41,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
||||||
|
@ -71,25 +71,31 @@ public class WaterOfTransmutation extends WellWater {
|
||||||
item = null;
|
item = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != null) {
|
|
||||||
Notes.remove( Landmark.WELL_OF_TRANSMUTATION );
|
|
||||||
|
|
||||||
//incase a never-seen item pops out
|
//incase a never-seen item pops out
|
||||||
if (item.isIdentified()){
|
if (item != null&& item.isIdentified()){
|
||||||
Catalog.setSeen(item.getClass());
|
Catalog.setSeen(item.getClass());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean affectHero(Hero hero) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void use( BlobEmitter emitter ) {
|
public void use( BlobEmitter emitter ) {
|
||||||
super.use( emitter );
|
super.use( emitter );
|
||||||
emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 );
|
emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Landmark record() {
|
||||||
|
return Landmark.WELL_OF_TRANSMUTATION;
|
||||||
|
}
|
||||||
|
|
||||||
private MagesStaff changeStaff( MagesStaff staff ){
|
private MagesStaff changeStaff( MagesStaff staff ){
|
||||||
Class<?extends Wand> wandClass = staff.wandClass();
|
Class<?extends Wand> wandClass = staff.wandClass();
|
||||||
|
|
||||||
|
|
|
@ -26,54 +26,46 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.watabou.utils.Bundle;
|
|
||||||
import com.watabou.utils.PathFinder;
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class WellWater extends Blob {
|
public abstract class WellWater extends Blob {
|
||||||
|
|
||||||
protected int pos;
|
protected int pos;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
|
||||||
super.restoreFromBundle( bundle );
|
|
||||||
|
|
||||||
if (volume > 0)
|
|
||||||
for (int i=0; i < cur.length; i++) {
|
|
||||||
if (cur[i] > 0) {
|
|
||||||
pos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void evolve() {
|
protected void evolve() {
|
||||||
volume = off[pos] = cur[pos];
|
int cell;
|
||||||
area.union(pos%Dungeon.level.width(), pos/Dungeon.level.width());
|
boolean seen = false;
|
||||||
|
for (int i=area.top-1; i <= area.bottom; i++) {
|
||||||
if (Dungeon.visible[pos]) {
|
for (int j = area.left-1; j <= area.right; j++) {
|
||||||
if (this instanceof WaterOfAwareness) {
|
cell = j + i* Dungeon.level.width();
|
||||||
Notes.add( Landmark.WELL_OF_AWARENESS );
|
if (Dungeon.level.insideMap(cell)) {
|
||||||
} else if (this instanceof WaterOfHealth) {
|
off[cell] = cur[cell];
|
||||||
Notes.add( Notes.Landmark.WELL_OF_HEALTH );
|
volume += off[cell];
|
||||||
} else if (this instanceof WaterOfTransmutation) {
|
if (off[cell] > 0 && Dungeon.level.visited[cell]) {
|
||||||
Notes.add( Landmark.WELL_OF_TRANSMUTATION );
|
seen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (seen){
|
||||||
|
Notes.add(record());
|
||||||
|
} else {
|
||||||
|
Notes.remove(record());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean affect() {
|
protected boolean affect( int pos ) {
|
||||||
|
|
||||||
Heap heap;
|
Heap heap;
|
||||||
|
|
||||||
if (pos == Dungeon.hero.pos && affectHero( Dungeon.hero )) {
|
if (pos == Dungeon.hero.pos && affectHero( Dungeon.hero )) {
|
||||||
|
|
||||||
volume = off[pos] = cur[pos] = 0;
|
cur[pos] = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if ((heap = Dungeon.level.heaps.get( pos )) != null) {
|
} else if ((heap = Dungeon.level.heaps.get( pos )) != null) {
|
||||||
|
@ -95,7 +87,7 @@ public class WellWater extends Blob {
|
||||||
}
|
}
|
||||||
|
|
||||||
heap.sprite.link();
|
heap.sprite.link();
|
||||||
volume = off[pos] = cur[pos] = 0;
|
cur[pos] = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -118,25 +110,11 @@ public class WellWater extends Blob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean affectHero( Hero hero ) {
|
protected abstract boolean affectHero( Hero hero );
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Item affectItem( Item item ) {
|
protected abstract Item affectItem( Item item );
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
protected abstract Notes.Landmark record();
|
||||||
public void seed( Level level, int cell, int amount ) {
|
|
||||||
super.seed(level, cell, amount);
|
|
||||||
|
|
||||||
cur[pos] = 0;
|
|
||||||
pos = cell;
|
|
||||||
volume = cur[pos] = amount;
|
|
||||||
|
|
||||||
area.setEmpty();
|
|
||||||
area.union(cell%level.width(), cell/level.width());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void affectCell( int cell ) {
|
public static void affectCell( int cell ) {
|
||||||
|
|
||||||
|
@ -146,8 +124,8 @@ public class WellWater extends Blob {
|
||||||
WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass );
|
WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass );
|
||||||
if (water != null &&
|
if (water != null &&
|
||||||
water.volume > 0 &&
|
water.volume > 0 &&
|
||||||
water.pos == cell &&
|
water.cur[cell] > 0 &&
|
||||||
water.affect()) {
|
water.affect( cell )) {
|
||||||
|
|
||||||
Level.set( cell, Terrain.EMPTY_WELL );
|
Level.set( cell, Terrain.EMPTY_WELL );
|
||||||
GameScene.updateMap( cell );
|
GameScene.updateMap( cell );
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfAwareness;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfAwareness;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation;
|
||||||
|
@ -57,17 +56,7 @@ public class MagicWellRoom extends SpecialRoom {
|
||||||
SpecialRoom.disableGuaranteedWell();
|
SpecialRoom.disableGuaranteedWell();
|
||||||
}
|
}
|
||||||
|
|
||||||
WellWater water = (WellWater)level.blobs.get( waterClass );
|
WellWater.seed(c.x + level.width() * c.y, 1, waterClass, level);
|
||||||
if (water == null) {
|
|
||||||
try {
|
|
||||||
water = waterClass.newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
ShatteredPixelDungeon.reportException(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
water.seed( level, c.x + level.width() * c.y, 1 );
|
|
||||||
level.blobs.put( waterClass, water );
|
|
||||||
|
|
||||||
entrance().set( Door.Type.REGULAR );
|
entrance().set( Door.Type.REGULAR );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user