v0.6.2: improved hero fov logic
This commit is contained in:
parent
ab847c9e1b
commit
70a39f4229
|
@ -174,9 +174,6 @@ public class Dungeon {
|
||||||
|
|
||||||
public static HashSet<Integer> chapters;
|
public static HashSet<Integer> chapters;
|
||||||
|
|
||||||
// Hero's field of view
|
|
||||||
public static boolean[] visible;
|
|
||||||
|
|
||||||
public static SparseArray<ArrayList<Item>> droppedItems;
|
public static SparseArray<ArrayList<Item>> droppedItems;
|
||||||
|
|
||||||
public static int version;
|
public static int version;
|
||||||
|
|
|
@ -468,7 +468,17 @@ public class Hero extends Char {
|
||||||
@Override
|
@Override
|
||||||
public boolean act() {
|
public boolean act() {
|
||||||
|
|
||||||
super.act();
|
//calls to dungeon.observe will also update hero's local FOV.
|
||||||
|
fieldOfView = Dungeon.level.heroFOV;
|
||||||
|
|
||||||
|
//do a full observe (including fog update) if not resting.
|
||||||
|
if (!resting || buff(MindVision.class) != null || buff(Awareness.class) != null) {
|
||||||
|
Dungeon.observe();
|
||||||
|
} else {
|
||||||
|
//otherwise just directly re-calculate FOV
|
||||||
|
Dungeon.level.updateFieldOfView( this, fieldOfView );
|
||||||
|
}
|
||||||
|
checkVisibleMobs();
|
||||||
|
|
||||||
if (paralysed > 0) {
|
if (paralysed > 0) {
|
||||||
|
|
||||||
|
@ -478,11 +488,6 @@ public class Hero extends Char {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkVisibleMobs();
|
|
||||||
if (!resting || buff(MindVision.class) != null || buff(Awareness.class) != null) {
|
|
||||||
Dungeon.observe();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curAction == null) {
|
if (curAction == null) {
|
||||||
|
|
||||||
if (resting) {
|
if (resting) {
|
||||||
|
@ -980,7 +985,7 @@ public class Hero extends Char {
|
||||||
|
|
||||||
Mob target = null;
|
Mob target = null;
|
||||||
for (Mob m : Dungeon.level.mobs) {
|
for (Mob m : Dungeon.level.mobs) {
|
||||||
if (Dungeon.level.heroFOV[ m.pos ] && m.hostile) {
|
if (fieldOfView[ m.pos ] && m.hostile) {
|
||||||
visible.add(m);
|
visible.add(m);
|
||||||
if (!visibleEnemies.contains( m )) {
|
if (!visibleEnemies.contains( m )) {
|
||||||
newMob = true;
|
newMob = true;
|
||||||
|
@ -998,7 +1003,7 @@ public class Hero extends Char {
|
||||||
|
|
||||||
if (target != null && (QuickSlotButton.lastTarget == null ||
|
if (target != null && (QuickSlotButton.lastTarget == null ||
|
||||||
!QuickSlotButton.lastTarget.isAlive() ||
|
!QuickSlotButton.lastTarget.isAlive() ||
|
||||||
!Dungeon.level.heroFOV[QuickSlotButton.lastTarget.pos])){
|
!fieldOfView[QuickSlotButton.lastTarget.pos])){
|
||||||
QuickSlotButton.target(target);
|
QuickSlotButton.target(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,7 +1140,7 @@ public class Hero extends Char {
|
||||||
|
|
||||||
curAction = new HeroAction.Alchemy( cell );
|
curAction = new HeroAction.Alchemy( cell );
|
||||||
|
|
||||||
} else if (Dungeon.level.heroFOV[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
|
} else if (fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) {
|
||||||
|
|
||||||
if (ch instanceof NPC) {
|
if (ch instanceof NPC) {
|
||||||
curAction = new HeroAction.Interact( (NPC)ch );
|
curAction = new HeroAction.Interact( (NPC)ch );
|
||||||
|
@ -1508,7 +1513,7 @@ public class Hero extends Char {
|
||||||
for (int y = ay; y <= by; y++) {
|
for (int y = ay; y <= by; y++) {
|
||||||
for (int x = ax, p = ax + y * Dungeon.level.width(); x <= bx; x++, p++) {
|
for (int x = ax, p = ax + y * Dungeon.level.width(); x <= bx; x++, p++) {
|
||||||
|
|
||||||
if (Dungeon.level.heroFOV[p] && p != pos) {
|
if (fieldOfView[p] && p != pos) {
|
||||||
|
|
||||||
if (intentional) {
|
if (intentional) {
|
||||||
sprite.parent.addToBack( new CheckedCell( p ) );
|
sprite.parent.addToBack( new CheckedCell( p ) );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user