Merge branch 'fixcurrentmapracecondition' into nut_test_brimhaven

This commit is contained in:
Gonk
2020-02-25 23:02:42 +01:00
21 changed files with 103 additions and 90 deletions

View File

@@ -111,7 +111,7 @@ public final class Dialogs {
if (!params.containsKey("x")) return null;
int x = params.getInt("x");
int y = params.getInt("y");
return world.model.currentMap.getMonsterAt(x, y);
return world.model.currentMaps.map.getMonsterAt(x, y);
}
public static void showMonsterEncounter(final MainActivity currentActivity, final ControllerContext context, final Monster monster) {

View File

@@ -43,6 +43,7 @@ import com.gpl.rpg.AndorsTrail.model.item.Loot;
import com.gpl.rpg.AndorsTrail.model.quest.Quest;
import com.gpl.rpg.AndorsTrail.model.quest.QuestLogEntry;
import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
@@ -85,7 +86,7 @@ public final class ConversationActivity
replyGroup.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, ListView.LayoutParams.WRAP_CONTENT));
statementList = (ListView) findViewById(R.id.conversation_statements);
statementList.addFooterView(replyGroup);
listAdapter = new StatementContainerAdapter(this, conversationHistory, world.tileManager);
listAdapter = new StatementContainerAdapter(this, conversationHistory, world.tileManager, world.model.currentMaps.tiles);
statementList.setAdapter(listAdapter);
nextButton = (Button) findViewById(R.id.conversation_next);
@@ -349,10 +350,12 @@ public final class ConversationActivity
private static final class StatementContainerAdapter extends ArrayAdapter<ConversationStatement> {
private final TileManager tileManager;
private final TileCollection tiles;
public StatementContainerAdapter(Context context, ArrayList<ConversationStatement> items, TileManager tileManager) {
public StatementContainerAdapter(Context context, ArrayList<ConversationStatement> items, TileManager tileManager, TileCollection tiles) {
super(context, 0, items);
this.tileManager = tileManager;
this.tiles = tiles;
}
@Override
@@ -367,7 +370,7 @@ public final class ConversationActivity
if (statement.hasActor()) {
final Resources res = getContext().getResources();
if (statement.isPlayerActor) tileManager.setImageViewTileForPlayer(res, tv, statement.iconID);
else tileManager.setImageViewTileForMonster(res, tv, statement.iconID);
else tileManager.setImageViewTileForMonster(res, tv, statement.iconID, tiles);
tv.setText(statement.actorName + ": " + statement.text, BufferType.SPANNABLE);
Spannable sp = (Spannable) tv.getText();

View File

@@ -93,7 +93,7 @@ public final class DisplayWorldMapActivity extends AndorsTrailBaseActivity {
}
WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName);
map = segment.maps.get(world.model.currentMap.name);
map = segment.maps.get(world.model.currentMaps.map.name);
if (map == null) {
this.finish();
return;

View File

@@ -41,7 +41,7 @@ public final class MonsterEncounterActivity extends AndorsTrailBaseActivity {
TextView tv = (TextView) findViewById(R.id.monsterencounter_title);
tv.setText(monster.getName());
world.tileManager.setImageViewTile(getResources(), tv, monster);
world.tileManager.setImageViewTile(getResources(), tv, monster, world.model.currentMaps.tiles);
tv = (TextView) findViewById(R.id.monsterencounter_description);
tv.setText(getString(R.string.dialog_monsterencounter_message, difficulty));

View File

@@ -79,7 +79,7 @@ public final class MonsterInfoActivity extends AndorsTrailBaseActivity {
private void updateTitle(Monster monster) {
monsterinfo_title.setText(monster.getName());
world.tileManager.setImageViewTile(getResources(), monsterinfo_title, monster);
world.tileManager.setImageViewTile(getResources(), monsterinfo_title, monster, world.model.currentMaps.tiles);
monsterinfo_difficulty.setText(getMonsterDifficultyResource(controllers, monster));
}

View File

@@ -111,10 +111,10 @@ public final class CombatController implements VisualEffectCompletedCallback {
}
public void setCombatSelection(Coord p) {
Monster m = world.model.currentMap.getMonsterAt(p);
Monster m = world.model.currentMaps.map.getMonsterAt(p);
if (m != null) {
setCombatSelection(m, p);
} else if (world.model.currentTileMap.isWalkable(p)) {
} else if (world.model.currentMaps.tileMap.isWalkable(p)) {
setCombatSelection(null, p);
}
}
@@ -130,7 +130,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
public boolean canExitCombat() { return getAdjacentAggressiveMonster() == null; }
private Monster getAdjacentAggressiveMonster() {
return MovementController.getAdjacentAggressiveMonster(world.model.currentMap, world.model.player);
return MovementController.getAdjacentAggressiveMonster(world.model.currentMaps.map, world.model.player);
}
public void executeMoveAttack(int dx, int dy) {
@@ -157,7 +157,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
private void executeFlee(int dx, int dy) {
// avoid monster fields when fleeing
if (!controllers.movementController.findWalkablePosition(dx, dy, AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_DEFENSIVE)) return;
Monster m = world.model.currentMap.getMonsterAt(world.model.player.nextPosition);
Monster m = world.model.currentMaps.map.getMonsterAt(world.model.player.nextPosition);
if (m != null) return;
executeCombatMove(world.model.player.nextPosition);
}
@@ -200,11 +200,11 @@ public final class CombatController implements VisualEffectCompletedCallback {
public void playerKilledMonster(Monster killedMonster) {
final Player player = world.model.player;
Loot loot = world.model.currentMap.getBagOrCreateAt(killedMonster.position);
Loot loot = world.model.currentMaps.map.getBagOrCreateAt(killedMonster.position);
killedMonster.createLoot(loot, player);
controllers.monsterSpawnController.remove(world.model.currentMap, killedMonster);
controllers.effectController.addSplatter(world.model.currentMap, killedMonster);
controllers.monsterSpawnController.remove(world.model.currentMaps.map, killedMonster);
controllers.effectController.addSplatter(world.model.currentMaps.map, killedMonster);
controllers.actorStatsController.addActorAP(player, player.getSkillLevel(SkillCollection.SkillID.cleave) * SkillCollection.PER_SKILLPOINT_INCREASE_CLEAVE_AP);
controllers.actorStatsController.addActorHealth(player, player.getSkillLevel(SkillCollection.SkillID.eater) * SkillCollection.PER_SKILLPOINT_INCREASE_EATER_HEALTH);
@@ -218,7 +218,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
controllers.actorStatsController.applyOnDeathEffectsToPlayer(player, killedMonster);
if (!loot.hasItemsOrGold()) {
world.model.currentMap.removeGroundLoot(loot);
world.model.currentMaps.map.removeGroundLoot(loot);
} else if (world.model.uiSelections.isInCombat) {
killedMonsterBags.add(loot);
}
@@ -307,7 +307,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
private void beginMonsterTurn(boolean isFirstRound) {
controllers.actorStatsController.setActorMinAP(world.model.player);
world.model.uiSelections.isPlayersCombatTurn = false;
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
for (MonsterSpawnArea a : world.model.currentMaps.map.spawnAreas) {
for (Monster m : a.monsters) {
controllers.actorStatsController.setActorMaxAP(m);
}
@@ -325,7 +325,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
if (shouldAttackWithMonsterInCombat(currentActiveMonster, playerPosition)) return MonsterAction.attack;
}
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
for (MonsterSpawnArea a : world.model.currentMaps.map.spawnAreas) {
for (Monster m : a.monsters) {
if (!m.isAgressive(world.model.player)) continue;
@@ -389,7 +389,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
}
final Monster movingMonster = currentActiveMonster;
controllers.monsterMovementController.moveMonsterToNextPositionDuringCombat(currentActiveMonster, world.model.currentMap, new VisualEffectController.VisualEffectCompletedCallback(){
controllers.monsterMovementController.moveMonsterToNextPositionDuringCombat(currentActiveMonster, world.model.currentMaps.map, new VisualEffectController.VisualEffectCompletedCallback(){
@Override
public void onVisualEffectCompleted(int callbackValue) {
combatActionListeners.onMonsterMovedDuringCombat(movingMonster);
@@ -595,7 +595,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
world.model.worldData.tickWorldTime();
controllers.gameRoundController.resetRoundTimers();
controllers.actorStatsController.applyConditionsToPlayer(world.model.player, false);
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMap, true);
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMaps.map, true);
}
public void monsterSteppedOnPlayer(Monster m) {

View File

@@ -130,7 +130,7 @@ public final class ConversationController {
private void changeMapFilter(Resources res, String mapName, String effectID) {
PredefinedMap map = findMapForScriptEffect(mapName);
map.currentColorFilter = effectID;
if (world.model.currentMap == map) {
if (world.model.currentMaps.map == map) {
controllers.mapController.applyCurrentMapReplacements(res, true);
}
}
@@ -141,7 +141,7 @@ public final class ConversationController {
}
private PredefinedMap findMapForScriptEffect(String mapName) {
if (mapName == null) return world.model.currentMap;
if (mapName == null) return world.model.currentMaps.map;
return world.maps.findPredefinedMap(mapName);
}
@@ -153,8 +153,8 @@ public final class ConversationController {
private void spawnAll(String mapName, String areaId) {
PredefinedMap map = findMapForScriptEffect(mapName);
LayeredTileMap tileMap = null;
if (map == world.model.currentMap) {
tileMap = world.model.currentTileMap;
if (map == world.model.currentMaps.map) {
tileMap = world.model.currentMaps.tileMap;
}
for (MonsterSpawnArea area : map.spawnAreas) {
if (!area.areaID.equals(areaId)) continue;
@@ -174,12 +174,12 @@ public final class ConversationController {
private void addAlignmentReward(Player player, String faction, int delta) {
player.addAlignment(faction, delta);
MovementController.refreshMonsterAggressiveness(world.model.currentMap, world.model.player);
MovementController.refreshMonsterAggressiveness(world.model.currentMaps.map, world.model.player);
}
private void setAlignmentReward(Player player, String faction, int delta) {
player.setAlignment(faction, delta);
MovementController.refreshMonsterAggressiveness(world.model.currentMap, world.model.player);
MovementController.refreshMonsterAggressiveness(world.model.currentMaps.map, world.model.player);
}
private void addQuestProgressReward(Player player, String questID, int questProgress, ScriptEffectResult result) {
@@ -388,7 +388,7 @@ public final class ConversationController {
if (currentPhrase == null) currentPhrase = new Phrase("(phrase \"" + phraseID + "\" not implemented yet)", null, null, null);
}
if (this.currentPhrase.switchToNPC != null) {
setCurrentNPC(world.model.currentMap.findSpawnedMonster(this.currentPhrase.switchToNPC));
setCurrentNPC(world.model.currentMaps.map.findSpawnedMonster(this.currentPhrase.switchToNPC));
}
}
@@ -445,7 +445,7 @@ public final class ConversationController {
listener.onConversationEnded();
return;
}
controllers.monsterSpawnController.remove(world.model.currentMap, npc);
controllers.monsterSpawnController.remove(world.model.currentMaps.map, npc);
listener.onConversationEndedWithRemoval(npc);
}

View File

@@ -74,7 +74,7 @@ public final class GameRoundController implements TimedMessageTask.Callback {
public void onNewFullRound() {
controllers.mapController.resetMapsNotRecentlyVisited();
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMap, true);
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMaps.map, true);
controllers.actorStatsController.applyConditionsToPlayer(world.model.player, true);
gameRoundListeners.onNewFullRound();
}
@@ -87,19 +87,19 @@ public final class GameRoundController implements TimedMessageTask.Callback {
public void onNewPlayerRound() {
world.model.worldData.tickWorldTime();
controllers.actorStatsController.applyConditionsToPlayer(world.model.player, false);
controllers.actorStatsController.applySkillEffectsForNewRound(world.model.player, world.model.currentMap);
controllers.mapController.handleMapEvents(world.model.currentMap, world.model.player.position, MapObject.MapObjectEvaluationType.afterEveryRound);
controllers.actorStatsController.applySkillEffectsForNewRound(world.model.player, world.model.currentMaps.map);
controllers.mapController.handleMapEvents(world.model.currentMaps.map, world.model.player.position, MapObject.MapObjectEvaluationType.afterEveryRound);
}
public void onNewMonsterRound() {
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMap, false);
controllers.actorStatsController.applyConditionsToMonsters(world.model.currentMaps.map, false);
}
private void onNewTick() {
controllers.monsterMovementController.moveMonsters();
controllers.monsterSpawnController.maybeSpawn(world.model.currentMap, world.model.currentTileMap);
controllers.monsterSpawnController.maybeSpawn(world.model.currentMaps.map, world.model.currentMaps.tileMap);
controllers.monsterMovementController.attackWithAgressiveMonsters();
controllers.effectController.updateSplatters(world.model.currentMap);
controllers.mapController.handleMapEvents(world.model.currentMap, world.model.player.position, MapObject.MapObjectEvaluationType.continuously);
controllers.effectController.updateSplatters(world.model.currentMaps.map);
controllers.mapController.handleMapEvents(world.model.currentMaps.map, world.model.player.position, MapObject.MapObjectEvaluationType.continuously);
gameRoundListeners.onNewTick();
}
}

View File

@@ -35,7 +35,7 @@ public final class ItemController {
public void dropItem(ItemType type, int quantity) {
if (world.model.player.inventory.getItemQuantity(type.id) < quantity) return;
world.model.player.inventory.removeItem(type.id, quantity);
world.model.currentMap.itemDropped(type, quantity, world.model.player.position);
world.model.currentMaps.map.itemDropped(type, quantity, world.model.player.position);
}
public void equipItem(ItemType type, Inventory.WearSlot slot) {
@@ -245,8 +245,8 @@ public final class ItemController {
public boolean removeLootBagIfEmpty(final Loot loot) {
if (loot.hasItemsOrGold()) return false;
world.model.currentMap.removeGroundLoot(loot);
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMap, loot.position);
world.model.currentMaps.map.removeGroundLoot(loot);
controllers.mapController.mapLayoutListeners.onLootBagRemoved(world.model.currentMaps.map, loot.position);
return true; // The bag was removed.
}

View File

@@ -146,14 +146,14 @@ public final class MapController {
for (PredefinedMap m : world.maps.getAllMaps()) {
m.resetTemporaryData();
}
controllers.monsterSpawnController.spawnAll(world.model.currentMap, world.model.currentTileMap);
controllers.monsterSpawnController.spawnAll(world.model.currentMaps.map, world.model.currentMaps.tileMap);
world.model.worldData.tickWorldTime(20);
controllers.gameRoundController.resetRoundTimers();
}
public void rest(MapObject area) {
lotsOfTimePassed();
world.model.player.setSpawnPlace(world.model.currentMap.name, area.id);
world.model.player.setSpawnPlace(world.model.currentMaps.map.name, area.id);
worldEventListeners.onPlayerRested();
}
@@ -168,7 +168,7 @@ public final class MapController {
public void resetMapsNotRecentlyVisited() {
for (PredefinedMap m : world.maps.getAllMaps()) {
if (m == world.model.currentMap) continue;
if (m == world.model.currentMaps.map) continue;
if (m.isRecentlyVisited()) continue;
if (m.hasResetTemporaryData()) continue;
m.resetTemporaryData();
@@ -176,12 +176,12 @@ public final class MapController {
}
public void applyCurrentMapReplacements(final Resources res, boolean updateWorldmap) {
if (!applyReplacements(world.model.currentMap, world.model.currentTileMap)) return;
if (!applyReplacements(world.model.currentMaps.map, world.model.currentMaps.tileMap)) return;
world.maps.worldMapRequiresUpdate = true;
if (!updateWorldmap) return;
WorldMapController.updateWorldMap(world, res);
mapLayoutListeners.onMapTilesChanged(world.model.currentMap, world.model.currentTileMap);
mapLayoutListeners.onMapTilesChanged(world.model.currentMaps.map, world.model.currentMaps.tileMap);
}
private boolean applyReplacements(PredefinedMap map, LayeredTileMap tileMap) {

View File

@@ -27,7 +27,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
public void moveMonsters() {
long currentTime = System.currentTimeMillis();
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
for (MonsterSpawnArea a : world.model.currentMaps.map.spawnAreas) {
for (Monster m : a.monsters) {
if (m.nextActionTime <= currentTime) {
moveMonster(m, a);
@@ -37,7 +37,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
}
public void attackWithAgressiveMonsters() {
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
for (MonsterSpawnArea a : world.model.currentMaps.map.spawnAreas) {
for (Monster m : a.monsters) {
if (!m.isAgressive(world.model.player)) continue;
if (!m.isAdjacentTo(world.model.player)) continue;
@@ -75,8 +75,8 @@ public final class MonsterMovementController implements EvaluateWalkable {
}
private void moveMonster(final Monster m, final MonsterSpawnArea area) {
PredefinedMap map = world.model.currentMap;
LayeredTileMap tileMap = world.model.currentTileMap;
PredefinedMap map = world.model.currentMaps.map;
LayeredTileMap tileMap = world.model.currentMaps.tileMap;
m.nextActionTime = System.currentTimeMillis() + getMillisecondsPerMove(m);
if (m.movementDestination != null && m.position.equals(m.movementDestination)) {
// Monster has been moving and arrived at the destination.
@@ -159,7 +159,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
@Override
public boolean isWalkable(CoordRect r, Monster m) {
return monsterCanMoveTo(null, world.model.currentMap, world.model.currentTileMap, r, m.area.ignoreAreas);
return monsterCanMoveTo(null, world.model.currentMaps.map, world.model.currentMaps.tileMap, r, m.area.ignoreAreas);
}
public void moveMonsterToNextPosition(final Monster m, final PredefinedMap map) {

View File

@@ -7,6 +7,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.listeners.PlayerMovementListeners;
import com.gpl.rpg.AndorsTrail.model.MapBundle;
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
@@ -56,7 +57,7 @@ public final class MovementController implements TimedMessageTask.Callback {
protected void onPostExecute(Void result) {
super.onPostExecute(result);
stopMovement();
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMap, world.model.player.position);
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMaps.map, world.model.player.position);
controllers.gameRoundController.resume();
}
@@ -83,7 +84,7 @@ public final class MovementController implements TimedMessageTask.Callback {
}
final ModelContainer model = world.model;
if (model.currentMap != null) model.currentMap.updateLastVisitTime();
if (model.currentMaps.map != null) model.currentMaps.map.updateLastVisitTime();
model.player.position.set(place.position.topLeft);
model.player.position.x += Math.min(offset_x, place.position.size.width-1);
model.player.position.y += Math.min(offset_y, place.position.size.height-1);
@@ -103,19 +104,28 @@ public final class MovementController implements TimedMessageTask.Callback {
public void prepareMapAsCurrentMap(PredefinedMap newMap, Resources res, boolean spawnMonsters) {
final ModelContainer model = world.model;
model.currentMap = newMap;
cacheCurrentMapData(res, newMap);
MapBundle newMaps = new MapBundle();
newMaps.map = newMap;
LayeredTileMap mapTiles = TMXMapTranslator.readLayeredTileMap(res, world.tileManager.tileCache, newMaps.map);
mapTiles.changeColorFilter(newMaps.map.currentColorFilter);
TileCollection cachedTiles = world.tileManager.loadTilesFor(newMaps.map, mapTiles, world, res);
newMaps.tileMap = mapTiles;
newMaps.tiles = cachedTiles;
world.tileManager.cacheAdjacentMaps(res, world, newMaps.map);
world.model.currentMaps = newMaps;
//Apply replacements before spawning, so that MonsterSpawnArea's isActive variable is up to date.
controllers.mapController.applyCurrentMapReplacements(res, false);
if (spawnMonsters) {
if (!newMap.isRecentlyVisited()) {
controllers.monsterSpawnController.spawnAll(newMap, model.currentTileMap);
controllers.monsterSpawnController.spawnAll(newMap, model.currentMaps.tileMap);
}
}
controllers.mapController.prepareScriptsOnCurrentMap();
newMap.visited = true;
newMap.updateLastVisitTime();
moveBlockedActors(newMap, model.currentTileMap);
moveBlockedActors(newMap, model.currentMaps.tileMap);
refreshMonsterAggressiveness(newMap, model.player);
controllers.effectController.updateSplatters(newMap);
WorldMapController.updateWorldMap(world, res);
@@ -131,7 +141,7 @@ public final class MovementController implements TimedMessageTask.Callback {
if (!findWalkablePosition(dx, dy)) return;
Monster m = world.model.currentMap.getMonsterAt(world.model.player.nextPosition);
Monster m = world.model.currentMaps.map.getMonsterAt(world.model.player.nextPosition);
if (m != null) {
controllers.mapController.steppedOnMonster(m, world.model.player.nextPosition);
return;
@@ -196,14 +206,14 @@ public final class MovementController implements TimedMessageTask.Callback {
,player.position.y + dy
);
if (!world.model.currentTileMap.isWalkable(player.nextPosition)) return false;
if (!world.model.currentMaps.tileMap.isWalkable(player.nextPosition)) return false;
// allow player to enter every field when he is NORMAL
// prevent player from entering "non-monster-fields" when he is AGGRESSIVE
// prevent player from entering "monster-fields" when he is DEFENSIVE
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_NORMAL) return true;
Monster m = world.model.currentMap.getMonsterAt(player.nextPosition);
Monster m = world.model.currentMaps.map.getMonsterAt(player.nextPosition);
if (m != null && !m.isAgressive(player)) return true; // avoid MOVEMENTAGGRESSIVENESS settings for NPCs
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_AGGRESSIVE && m == null) return false;
@@ -225,7 +235,7 @@ public final class MovementController implements TimedMessageTask.Callback {
public void moveToNextIfPossible() {
final Player player = world.model.player;
final PredefinedMap currentMap = world.model.currentMap;
final PredefinedMap currentMap = world.model.currentMaps.map;
final Coord newPosition = player.nextPosition;
for (MapObject o : currentMap.eventObjects) {
@@ -251,7 +261,7 @@ public final class MovementController implements TimedMessageTask.Callback {
if (!world.model.uiSelections.isInCombat) {
//currentMap can be outdated due to mapchange events processed above.
Loot loot = world.model.currentMap.getBagAt(newPosition);
Loot loot = world.model.currentMaps.map.getBagAt(newPosition);
if (loot != null) controllers.itemController.playerSteppedOnLootBag(loot);
}
}
@@ -262,7 +272,7 @@ public final class MovementController implements TimedMessageTask.Callback {
public void respawnPlayer(Resources res) {
placePlayerAt(res, MapObject.MapObjectType.rest, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMap, world.model.player.position);
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMaps.map, world.model.player.position);
}
public void respawnPlayerAsync() {
placePlayerAsyncAt(MapObject.MapObjectType.rest, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
@@ -311,16 +321,6 @@ public final class MovementController implements TimedMessageTask.Callback {
return null;
}
private void cacheCurrentMapData(final Resources res, final PredefinedMap nextMap) {
LayeredTileMap mapTiles = TMXMapTranslator.readLayeredTileMap(res, world.tileManager.tileCache, nextMap);
mapTiles.changeColorFilter(nextMap.currentColorFilter);
TileCollection cachedTiles = world.tileManager.loadTilesFor(nextMap, mapTiles, world, res);
world.model.currentTileMap = mapTiles;
world.tileManager.currentMapTiles = cachedTiles;
world.tileManager.cacheAdjacentMaps(res, world, nextMap);
}
private int movementDx;
private int movementDy;
public void startMovement(int dx, int dy, Coord destination) {

View File

@@ -41,7 +41,7 @@ public final class WorldMapController {
public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE;
public static void updateWorldMap(final WorldContext world, final Resources res) {
updateWorldMap(world, world.model.currentMap, world.model.currentTileMap, world.tileManager.currentMapTiles, res);
updateWorldMap(world, world.model.currentMaps.map, world.model.currentMaps.tileMap, world.model.currentMaps.tiles, res);
}
private static void updateWorldMap(
@@ -303,7 +303,7 @@ public final class WorldMapController {
}
public static boolean displayWorldMap(Context context, WorldContext world) {
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMap.name);
String worldMapSegmentName = world.maps.getWorldMapSegmentNameForMap(world.model.currentMaps.map.name);
if (worldMapSegmentName == null) {
Toast.makeText(context, context.getResources().getString(R.string.display_worldmap_not_available), Toast.LENGTH_LONG).show();
return false;

View File

@@ -0,0 +1,11 @@
package com.gpl.rpg.AndorsTrail.model;
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
public final class MapBundle {
public PredefinedMap map;
public LayeredTileMap tileMap;
public TileCollection tiles;
}

View File

@@ -9,6 +9,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
public final class ModelContainer {
@@ -17,8 +18,7 @@ public final class ModelContainer {
public final CombatLog combatLog = new CombatLog();
public final GameStatistics statistics;
public final WorldData worldData;
public PredefinedMap currentMap;
public LayeredTileMap currentTileMap;
public MapBundle currentMaps = new MapBundle();;
public ModelContainer(int startLives, boolean unlimitedSaves) {
player = new Player();
@@ -31,13 +31,13 @@ public final class ModelContainer {
public ModelContainer(DataInputStream src, WorldContext world, ControllerContext controllers, int fileversion) throws IOException {
this.player = Player.newFromParcel(src, world, controllers, fileversion);
this.currentMap = world.maps.findPredefinedMap(src.readUTF());
this.currentMaps.map = world.maps.findPredefinedMap(src.readUTF());
this.uiSelections = new InterfaceData(src, fileversion);
if (uiSelections.selectedPosition != null) {
this.uiSelections.selectedMonster = currentMap.getMonsterAt(uiSelections.selectedPosition);
this.uiSelections.selectedMonster = currentMaps.map.getMonsterAt(uiSelections.selectedPosition);
}
this.statistics = new GameStatistics(src, world, fileversion);
this.currentTileMap = null;
this.currentMaps.tileMap = null;
if (fileversion >= 40) {
this.worldData = new WorldData(src, fileversion);
} else {
@@ -47,7 +47,7 @@ public final class ModelContainer {
public void writeToParcel(DataOutputStream dest) throws IOException {
player.writeToParcel(dest);
dest.writeUTF(currentMap.name);
dest.writeUTF(currentMaps.map.name);
uiSelections.writeToParcel(dest);
statistics.writeToParcel(dest);
worldData.writeToParcel(dest);

View File

@@ -361,7 +361,7 @@ public final class PredefinedMap {
public boolean shouldSaveMapData(WorldContext world) {
if (!hasResetTemporaryData()) return true;
if (this == world.model.currentMap) return true;
if (this == world.model.currentMaps.map) return true;
if (!groundBags.isEmpty()) return true;
for (MonsterSpawnArea a : spawnAreas) {
if (this.visited && a.isUnique) return true;

View File

@@ -98,7 +98,6 @@ public final class TileManager {
public final TileCache tileCache = new TileCache();
public TileCollection preloadedTiles;// = new TileCollection(116);
public TileCollection currentMapTiles;
public TileCollection adjacentMapTiles;
private final HashSet<Integer> preloadedTileIDs = new HashSet<Integer>();
@@ -177,9 +176,9 @@ public final class TileManager {
public void setImageViewTile(Resources res, TextView textView, Monster monster) { setImageViewTileForMonster(res, textView, monster.iconID); }
public void setImageViewTile(Resources res, TextView textView, Monster monster, TileCollection tiles) { setImageViewTileForMonster(res, textView, monster.iconID, tiles); }
public void setImageViewTile(Resources res, TextView textView, Player player) { setImageViewTileForPlayer(res, textView, player.iconID); }
public void setImageViewTileForMonster(Resources res, TextView textView, int iconID) { setImageViewTile(res, textView, currentMapTiles.getBitmap(iconID)); }
public void setImageViewTileForMonster(Resources res, TextView textView, int iconID, TileCollection tiles) { setImageViewTile(res, textView, tiles.getBitmap(iconID)); }
public void setImageViewTileForPlayer(Resources res, TextView textView, int iconID) { setImageViewTile(res, textView, preloadedTiles.getBitmap(iconID)); }
public void setImageViewTile(Resources res, TextView textView, ActorConditionType conditionType) { setImageViewTile(res, textView, preloadedTiles.getBitmap(conditionType.iconID)); }
public void setImageViewTile(Resources res, TextView textView, ActorConditionType conditionType, boolean immunityOverlay) { setImageViewTile(res, textView, preloadedTiles.getBitmap(conditionType.iconID), immunityOverlay); }
@@ -249,9 +248,9 @@ public final class TileManager {
}
}
public void setImageViewTile(Resources res, ImageView imageView, Monster monster) { setImageViewTileForMonster(res, imageView, monster.iconID); }
public void setImageViewTile(Resources res, ImageView imageView, Monster monster, TileCollection tiles) { setImageViewTileForMonster(res, imageView, monster.iconID, tiles); }
public void setImageViewTile(Resources res, ImageView imageView, Player player) { setImageViewTileForPlayer(res, imageView, player.iconID); }
public void setImageViewTileForMonster(Resources res, ImageView imageView, int iconID) { setImageViewTile(res, imageView, currentMapTiles.getBitmap(iconID)); }
public void setImageViewTileForMonster(Resources res, ImageView imageView, int iconID, TileCollection tiles) { setImageViewTile(res, imageView, tiles.getBitmap(iconID)); }
public void setImageViewTileForPlayer(Resources res, ImageView imageView, int iconID) { setImageViewTile(res, imageView, preloadedTiles.getBitmap(iconID)); }
// public void setImageViewTile(Resources res, ImageView imageView, ActorConditionType conditionType) { setImageViewTile(res, imageView, preloadedTiles.getBitmap(conditionType.iconID)); }
public void setImageViewTile(Context ctx, ImageView imageView, ActorConditionType conditionType, boolean immunityOverlay) { setImageViewTile(ctx, imageView, preloadedTiles.getBitmap(conditionType.iconID), immunityOverlay); }

View File

@@ -29,7 +29,7 @@ public class LegacySavegamesContentAdaptations {
for (MonsterSpawnArea newarea : fields5Map.spawnAreas) {
if (newarea.areaID.equals("guynmart_robber1")) {
controllers.monsterSpawnController.spawnAllInArea(fields5Map,
(world.model.currentMap == fields5Map ? world.model.currentTileMap : null),
(world.model.currentMaps.map == fields5Map ? world.model.currentMaps.tileMap : null),
newarea, true);
break;
}

View File

@@ -233,7 +233,7 @@ public final class Savegames {
private static void onWorldLoaded(Resources res, WorldContext world, ControllerContext controllers) {
controllers.actorStatsController.recalculatePlayerStats(world.model.player);
controllers.mapController.resetMapsNotRecentlyVisited();
controllers.movementController.prepareMapAsCurrentMap(world.model.currentMap, res, false);
controllers.movementController.prepareMapAsCurrentMap(world.model.currentMaps.map, res, false);
controllers.gameRoundController.resetRoundTimers();
}

View File

@@ -197,7 +197,7 @@ public final class CombatView extends RelativeLayout implements CombatSelectionL
currentMonster = null;
if (selectedMonster != null) {
monsterBar.setVisibility(View.VISIBLE);
world.tileManager.setImageViewTile(res, monsterInfo, selectedMonster);
world.tileManager.setImageViewTile(res, monsterInfo, selectedMonster, world.model.currentMaps.tiles);
updateMonsterHealth(selectedMonster);
currentMonster = selectedMonster;
}

View File

@@ -167,8 +167,8 @@ public final class MainView extends SurfaceView
sh.setFixedSize(surfaceSize.width, surfaceSize.height);
}
if (model.currentMap != null) {
onPlayerEnteredNewMap(model.currentMap, model.player.position);
if (model.currentMaps.map != null) {
onPlayerEnteredNewMap(model.currentMaps.map, model.player.position);
} else {
redrawAll(RedrawAllDebugReason.SurfaceChanged);
}
@@ -506,8 +506,8 @@ public final class MainView extends SurfaceView
movingSpritesRedrawTick.start();
synchronized (holder) {
currentMap = map;
currentTileMap = model.currentTileMap;
tiles = world.tileManager.currentMapTiles;
currentTileMap = model.currentMaps.tileMap;
tiles = world.model.currentMaps.tiles;
movingSprites = 0;
Size visibleNumberOfTiles = new Size(
Math.min(screenSizeTileCount.width, currentMap.size.width)