-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #458 from tonihele/feature/training-impl
Feature/training impl
- Loading branch information
Showing
19 changed files
with
538 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/toniarts/openkeeper/game/controller/room/TrainingRoomController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2014-2023 OpenKeeper | ||
* | ||
* OpenKeeper is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OpenKeeper is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OpenKeeper. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package toniarts.openkeeper.game.controller.room; | ||
|
||
import toniarts.openkeeper.common.RoomInstance; | ||
import toniarts.openkeeper.game.controller.IGameTimer; | ||
import toniarts.openkeeper.game.controller.IObjectsController; | ||
import toniarts.openkeeper.game.controller.room.storage.RoomTraineeControl; | ||
import toniarts.openkeeper.tools.convert.map.KwdFile; | ||
|
||
/** | ||
* The training room | ||
* | ||
* @author Toni Helenius <[email protected]> | ||
*/ | ||
public class TrainingRoomController extends NormalRoomController { | ||
|
||
public TrainingRoomController(KwdFile kwdFile, RoomInstance roomInstance, IObjectsController objectsController, | ||
IGameTimer gameTimer) { | ||
super(kwdFile, roomInstance, objectsController); | ||
|
||
addObjectControl(new RoomTraineeControl(kwdFile, this, objectsController, gameTimer) { | ||
|
||
@Override | ||
protected int getNumberOfAccessibleTiles() { | ||
return getFurnitureCount(); | ||
} | ||
}); | ||
} | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
src/toniarts/openkeeper/game/controller/room/storage/RoomTraineeControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (C) 2014-2023 OpenKeeper | ||
* | ||
* OpenKeeper is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* OpenKeeper is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OpenKeeper. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package toniarts.openkeeper.game.controller.room.storage; | ||
|
||
import com.simsilica.es.EntityId; | ||
import java.awt.Point; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import toniarts.openkeeper.game.component.Position; | ||
import toniarts.openkeeper.game.controller.IGameTimer; | ||
import toniarts.openkeeper.game.controller.IObjectsController; | ||
import toniarts.openkeeper.game.controller.room.AbstractRoomController.ObjectType; | ||
import toniarts.openkeeper.game.controller.room.IRoomController; | ||
import toniarts.openkeeper.tools.convert.map.KwdFile; | ||
import toniarts.openkeeper.utils.WorldUtils; | ||
|
||
/** | ||
* Holds out the trainees populating a room | ||
* | ||
* @author Toni Helenius <[email protected]> | ||
*/ | ||
public abstract class RoomTraineeControl extends AbstractRoomObjectControl<EntityId> { | ||
|
||
protected RoomTraineeControl(KwdFile kwdFile, IRoomController parent, IObjectsController objectsController, IGameTimer gameTimer) { | ||
super(kwdFile, parent, objectsController, gameTimer); | ||
} | ||
|
||
@Override | ||
public int getCurrentCapacity() { | ||
return objectsByCoordinate.size(); | ||
} | ||
|
||
@Override | ||
protected int getObjectsPerTile() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public ObjectType getObjectType() { | ||
return ObjectType.TRAINEE; | ||
} | ||
|
||
@Override | ||
public EntityId addItem(EntityId trainee, Point p) { | ||
setRoomStorageToItem(trainee, false); | ||
|
||
return trainee; | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
|
||
// TODO: The trainee can't do his/her job | ||
} | ||
|
||
@Override | ||
public void captured(short playerId) { | ||
|
||
} | ||
|
||
@Override | ||
protected Collection<Point> getCoordinates() { | ||
|
||
// Only furniture | ||
List<Point> coordinates = new ArrayList<>(parent.getFloorFurnitureCount() + parent.getWallFurnitureCount()); | ||
for (EntityId oc : parent.getFloorFurniture()) { | ||
coordinates.add(WorldUtils.vectorToPoint(objectsController.getEntityData().getComponent(oc, Position.class).position)); | ||
} | ||
for (EntityId oc : parent.getWallFurniture()) { | ||
coordinates.add(WorldUtils.vectorToPoint(objectsController.getEntityData().getComponent(oc, Position.class).position)); | ||
} | ||
|
||
return coordinates; | ||
} | ||
|
||
} |
Oops, something went wrong.