v2.5.0: merged spawning logic into one class (freeing up bestiary)
This commit is contained in:
@@ -48,6 +48,11 @@ public class ShatteredPixelDungeon extends Game {
|
|||||||
public ShatteredPixelDungeon( PlatformSupport platform ) {
|
public ShatteredPixelDungeon( PlatformSupport platform ) {
|
||||||
super( sceneClass == null ? WelcomeScene.class : sceneClass, platform );
|
super( sceneClass == null ? WelcomeScene.class : sceneClass, platform );
|
||||||
|
|
||||||
|
//pre-v2.5.0
|
||||||
|
com.watabou.utils.Bundle.addAlias(
|
||||||
|
com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner.class,
|
||||||
|
"com.shatteredpixel.shatteredpixeldungeon.levels.Level$Respawner" );
|
||||||
|
|
||||||
//pre-v2.4.0
|
//pre-v2.4.0
|
||||||
com.watabou.utils.Bundle.addAlias(
|
com.watabou.utils.Bundle.addAlias(
|
||||||
com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.UnstableBrew.class,
|
com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.UnstableBrew.class,
|
||||||
|
|||||||
+30
-1
@@ -21,13 +21,42 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.RatSkull;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.RatSkull;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Bestiary {
|
public class MobSpawner extends Actor {
|
||||||
|
{
|
||||||
|
actPriority = BUFF_PRIO; //as if it were a buff.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean act() {
|
||||||
|
|
||||||
|
if (Dungeon.level.mobCount() < Dungeon.level.mobLimit()) {
|
||||||
|
|
||||||
|
if (Dungeon.level.spawnMob(12)){
|
||||||
|
spend(Dungeon.level.respawnCooldown());
|
||||||
|
} else {
|
||||||
|
//try again in 1 turn
|
||||||
|
spend(TICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
spend(Dungeon.level.respawnCooldown());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetCooldown(){
|
||||||
|
spend(-cooldown());
|
||||||
|
spend(Dungeon.level.respawnCooldown());
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<Class<? extends Mob>> getMobRotation(int depth ){
|
public static ArrayList<Class<? extends Mob>> getMobRotation(int depth ){
|
||||||
ArrayList<Class<? extends Mob>> mobs = standardMobRotation( depth );
|
ArrayList<Class<? extends Mob>> mobs = standardMobRotation( depth );
|
||||||
@@ -47,10 +47,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.huntress.SpiritHawk;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.huntress.SpiritHawk;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GnollGeomancer;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GnollGeomancer;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogFist;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogFist;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||||
@@ -68,10 +68,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
|
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition;
|
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.EyeOfNewt;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.EyeOfNewt;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MimicTooth;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MossyClump;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.MossyClump;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrapMechanism;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrapMechanism;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
|
||||||
@@ -430,7 +430,7 @@ public abstract class Level implements Bundlable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bundle.contains( "respawner" )){
|
if (bundle.contains( "respawner" )){
|
||||||
respawner = (Respawner) bundle.get("respawner");
|
respawner = (MobSpawner) bundle.get("respawner");
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFlagMaps();
|
buildFlagMaps();
|
||||||
@@ -490,7 +490,7 @@ public abstract class Level implements Bundlable {
|
|||||||
|
|
||||||
public Mob createMob() {
|
public Mob createMob() {
|
||||||
if (mobsToSpawn == null || mobsToSpawn.isEmpty()) {
|
if (mobsToSpawn == null || mobsToSpawn.isEmpty()) {
|
||||||
mobsToSpawn = Bestiary.getMobRotation(Dungeon.depth);
|
mobsToSpawn = MobSpawner.getMobRotation(Dungeon.depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob m = Reflection.newInstance(mobsToSpawn.remove(0));
|
Mob m = Reflection.newInstance(mobsToSpawn.remove(0));
|
||||||
@@ -671,11 +671,11 @@ public abstract class Level implements Bundlable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Respawner respawner;
|
private MobSpawner respawner;
|
||||||
|
|
||||||
public Actor addRespawner() {
|
public Actor addRespawner() {
|
||||||
if (respawner == null){
|
if (respawner == null){
|
||||||
respawner = new Respawner();
|
respawner = new MobSpawner();
|
||||||
Actor.addDelayed(respawner, respawnCooldown());
|
Actor.addDelayed(respawner, respawnCooldown());
|
||||||
} else {
|
} else {
|
||||||
Actor.add(respawner);
|
Actor.add(respawner);
|
||||||
@@ -686,36 +686,6 @@ public abstract class Level implements Bundlable {
|
|||||||
return respawner;
|
return respawner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Respawner extends Actor {
|
|
||||||
{
|
|
||||||
actPriority = BUFF_PRIO; //as if it were a buff.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean act() {
|
|
||||||
|
|
||||||
if (Dungeon.level.mobCount() < Dungeon.level.mobLimit()) {
|
|
||||||
|
|
||||||
if (Dungeon.level.spawnMob(12)){
|
|
||||||
spend(Dungeon.level.respawnCooldown());
|
|
||||||
} else {
|
|
||||||
//try again in 1 turn
|
|
||||||
spend(TICK);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
spend(Dungeon.level.respawnCooldown());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void resetCooldown(){
|
|
||||||
spend(-cooldown());
|
|
||||||
spend(Dungeon.level.respawnCooldown());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float respawnCooldown(){
|
public float respawnCooldown(){
|
||||||
float cooldown;
|
float cooldown;
|
||||||
if (Statistics.amuletObtained){
|
if (Statistics.amuletObtained){
|
||||||
|
|||||||
+2
-2
@@ -29,12 +29,12 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Acidic;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Albino;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Albino;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredBrute;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.ArmoredBrute;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bandit;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bandit;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bestiary;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.CausticSlime;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.CausticSlime;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM201;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM201;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Elemental;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Elemental;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.MobSpawner;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Senior;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Senior;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
|
||||||
@@ -111,7 +111,7 @@ public class DistortionTrap extends Trap{
|
|||||||
do {
|
do {
|
||||||
floor = Random.Int(25);
|
floor = Random.Int(25);
|
||||||
} while( Dungeon.bossLevel(floor));
|
} while( Dungeon.bossLevel(floor));
|
||||||
mob = Reflection.newInstance(Bestiary.getMobRotation(floor).get(0));
|
mob = Reflection.newInstance(MobSpawner.getMobRotation(floor).get(0));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
switch (2){
|
switch (2){
|
||||||
|
|||||||
Reference in New Issue
Block a user