62
62
import toniarts .openkeeper .view .map .construction .RoomConstructor ;
63
63
import toniarts .openkeeper .view .map .construction .SingleQuadConstructor ;
64
64
import toniarts .openkeeper .view .map .construction .WaterConstructor ;
65
- import toniarts .openkeeper .world .room .GenericRoom ;
66
65
67
66
/**
68
67
* Loads whole maps, and handles the maps
@@ -85,20 +84,16 @@ public abstract class MapViewController implements ILoader<KwdFile> {
85
84
private List <Node > pages ;
86
85
private final KwdFile kwdFile ;
87
86
private Node map ;
88
- //private final MapData mapData;
89
87
private final AssetManager assetManager ;
90
88
private final IMapInformation mapClientService ;
91
- //private final EffectManagerState effectManager;
92
89
private Node roomsNode ;
93
90
private final short playerId ;
94
- // private final WorldState worldState;
95
- //private final ObjectLoader objectLoader;
96
- // private final List<RoomInstance> rooms = new ArrayList<>(); // The list of rooms
97
91
private final Set <Point > flashedTiles = new HashSet <>();
98
92
private final List <EntityInstance <Terrain >> waterBatches = new ArrayList <>(); // Lakes and rivers
99
93
private final List <EntityInstance <Terrain >> lavaBatches = new ArrayList <>(); // Lakes and rivers, but hot
100
94
private final Map <Point , RoomInstance > roomCoordinates = new HashMap <>(); // A quick glimpse whether room at specific coordinates is already "found"
101
95
private final Map <RoomInstance , Spatial > roomNodes = new HashMap <>(); // Room instances by node
96
+ private final Map <Point , Thing .Room > roomThings = new HashMap <>();
102
97
private final Map <RoomInstance , RoomConstructor > roomActuals = new HashMap <>(); // Rooms by room constructor
103
98
private final Map <Point , EntityInstance <Terrain >> terrainBatchCoordinates = new HashMap <>(); // A quick glimpse whether terrain batch at specific coordinates is already "found"
104
99
@@ -553,19 +548,10 @@ private RoomInstance handleRoom(Point p, Room room, Thing.Room thing) {
553
548
return roomInstance ;
554
549
}
555
550
556
- RoomInstance roomInstance = new RoomInstance (room , thing );
557
- findRoom (p , roomInstance );
551
+ RoomInstance roomInstance = new RoomInstance (room , thing != null ? thing : roomThings . get ( p ) );
552
+ findRoom (p , roomInstance , thing );
558
553
findRoomWallSections (roomInstance );
559
- //rooms.add(roomInstance);
560
-
561
- // Put the thing attributes in
562
- // if (thing != null) {
563
- // for (Point roomPoint : roomInstance.getCoordinates()) {
564
- // MapTile tile = mapData.getTile(roomPoint);
565
- // tile.setPlayerId(thing.getPlayerId());
566
- // tile.setHealth((int) (tile.getTerrain().getMaxHealth() * (thing.getInitialHealth() / 100f)));
567
- // }
568
- // }
554
+
569
555
Spatial roomNode = handleRoom (roomInstance );
570
556
if (roomNode != null ) {
571
557
roomsNode .attachChild (roomNode );
@@ -632,8 +618,6 @@ private void handleTop(IMapTileInformation tile, Terrain terrain, Node pageNode)
632
618
topTileNode .attachChild (spatial );
633
619
setTileMaterialToGeometries (tile , topTileNode );
634
620
AssetUtils .translateToTile (topTileNode , p );
635
-
636
- // tile.setTopNode(topTileNode);
637
621
}
638
622
639
623
private void handleSide (IMapTileInformation tile , Node pageNode ) {
@@ -650,8 +634,6 @@ private void handleSide(IMapTileInformation tile, Node pageNode) {
650
634
651
635
setTileMaterialToGeometries (tile , sideTileNode );
652
636
AssetUtils .translateToTile (sideTileNode , p );
653
-
654
- // tile.setSideNode(sideTileNode);
655
637
}
656
638
657
639
public void flashTile (boolean enabled , List <Point > points ) {
@@ -736,8 +718,9 @@ public static boolean hasRoomWalls(Room room) {
736
718
*
737
719
* @param p starting point
738
720
* @param roomInstance the room instance
721
+ * @param thing fixed room item
739
722
*/
740
- private void findRoom (Point p , RoomInstance roomInstance ) {
723
+ private void findRoom (Point p , RoomInstance roomInstance , Thing . Room thing ) {
741
724
IMapTileInformation tile = getMapData ().getTile (p );
742
725
743
726
// Get the terrain
@@ -750,18 +733,21 @@ private void findRoom(Point p, RoomInstance roomInstance) {
750
733
// Add the coordinate
751
734
roomCoordinates .put (p , roomInstance );
752
735
roomInstance .addCoordinate (p );
736
+ if (thing != null ) {
737
+ roomThings .put (p , thing );
738
+ }
753
739
754
740
// Find north
755
- findRoom (new Point (p .x , p .y - 1 ), roomInstance );
741
+ findRoom (new Point (p .x , p .y - 1 ), roomInstance , thing );
756
742
757
743
// Find east
758
- findRoom (new Point (p .x + 1 , p .y ), roomInstance );
744
+ findRoom (new Point (p .x + 1 , p .y ), roomInstance , thing );
759
745
760
746
// Find south
761
- findRoom (new Point (p .x , p .y + 1 ), roomInstance );
747
+ findRoom (new Point (p .x , p .y + 1 ), roomInstance , thing );
762
748
763
749
// Find west
764
- findRoom (new Point (p .x - 1 , p .y ), roomInstance );
750
+ findRoom (new Point (p .x - 1 , p .y ), roomInstance , thing );
765
751
}
766
752
}
767
753
}
@@ -869,26 +855,6 @@ public static void setTerrainMaterialLighting(Material material, Terrain terrain
869
855
material .setBoolean ("UseMaterialColors" , false ); // Hmm...
870
856
}
871
857
872
- /**
873
- * Get coordinate / room instance mapping
874
- *
875
- * @return mapping
876
- */
877
- public HashMap <Point , RoomInstance > getRoomCoordinates () {
878
- // return roomCoordinates;
879
- return null ;
880
- }
881
-
882
- /**
883
- * Get list of room instances
884
- *
885
- * @return room instances
886
- */
887
- protected List <RoomInstance > getRooms () {
888
- // return rooms;
889
- return null ;
890
- }
891
-
892
858
/**
893
859
* Remove all the given room instances (and actually removes them from the
894
860
* scene)
@@ -899,11 +865,7 @@ protected void removeRoomInstances(RoomInstance... instances) {
899
865
for (RoomInstance instance : instances ) {
900
866
roomsNode .detachChild (roomNodes .get (instance ));
901
867
roomNodes .remove (instance );
902
- //rooms.remove(instance);
903
868
904
- // Signal the room
905
- //GenericRoom room = roomActuals.get(instance);
906
- //room.destroy();
907
869
roomActuals .remove (instance );
908
870
for (Point p : instance .getCoordinates ()) {
909
871
roomCoordinates .remove (p );
@@ -1049,38 +1011,6 @@ protected void updateRoom(RoomInstance roomInstance) {
1049
1011
1050
1012
// Redraw
1051
1013
updateRoomWalls (roomInstance );
1052
- // roomActuals.get(roomInstance).construct();
1053
- // roomsNode.attachChild(roomActuals.get(roomInstance).construct());
1054
- }
1055
-
1056
- /**
1057
- * Get a rooms by knowing its instance
1058
- *
1059
- * @return room
1060
- */
1061
- public Map <RoomInstance , GenericRoom > getRoomActuals () {
1062
- // return roomActuals;
1063
- return null ;
1064
- }
1065
-
1066
- /**
1067
- * Get rooms by function.<br> FIXME: Should the player have ready lists?
1068
- *
1069
- * @param objectType the function
1070
- * @param playerId the player id, can be null
1071
- * @return list of rooms that match the criteria
1072
- */
1073
- public List <GenericRoom > getRoomsByFunction (GenericRoom .ObjectType objectType , Short playerId ) {
1074
- List <GenericRoom > roomsList = new ArrayList <>();
1075
- // for (Entry<RoomInstance, GenericRoom> entry : roomActuals.entrySet()) {
1076
- // if (playerId != null && entry.getKey().getOwnerId() != playerId) {
1077
- // continue;
1078
- // }
1079
- // if (entry.getValue().hasObjectControl(objectType)) {
1080
- // roomsList.add(entry.getValue());
1081
- // }
1082
- // }
1083
- return roomsList ;
1084
1014
}
1085
1015
1086
1016
/**
0 commit comments