Class Controller
- java.lang.Object
-
- com.bombinggames.wurfelengine.core.Controller
-
- All Implemented Interfaces:
GameManager
public class Controller extends java.lang.Object implements GameManager
A controller manages the map and the game data. Before this is usedinit()
orinit(java.lang.String, int)
must be called.
-
-
Constructor Summary
Constructors Constructor Description Controller()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
should be called if removed from memoryvoid
enter()
Should be called when the manager becomes active.void
executeCommand(Command cmd)
Executes the command and saves it for possible undo/redo.void
exit()
Should get called when you leave the editor.Cursor
getCursor()
Get the entity laying under the cursor.DevTools
getDevTools()
static LightEngine
getLightEngine()
The light engine doing the lighting.static Map
getMap()
Returns the currently loaded map.int
getSaveSlot()
Get the save slot used for loading and saving the map.java.util.ArrayList<AbstractEntity>
getSelectedEntities()
void
init()
This method works like a constructor.void
init(java.lang.String mapName, int saveslot)
This method works like a constructor.boolean
isInitalized()
static boolean
loadMap(java.io.File path, int saveslot)
Tries loading a new map instance.int
newSaveSlot()
Uses a new save slot as the save slotvoid
onEnter()
Override to specify what should happen when the mangager becomes active.void
redoCommand()
boolean
save()
saves the map and the complete game statestatic void
setLightEngine(LightEngine le)
static void
setMap(Map map)
void
setMapName(java.lang.String mapName)
Set the map name which is loaded then.void
setSelectedEnt(java.util.ArrayList<AbstractEntity> newSel)
filter map editor entitiesvoid
showCursor()
static void
staticDispose()
Disposes static stuff.static void
staticUpdate(float dt)
update every static update methodvoid
undoCommand()
void
update(float dt)
Main method which is called every refresh.void
useSaveSlot(int slot)
Uses a specific save slot for loading and saving the map.
-
-
-
Method Detail
-
staticUpdate
public static void staticUpdate(float dt)
update every static update method- Parameters:
dt
-
-
loadMap
public static boolean loadMap(java.io.File path, int saveslot)
Tries loading a new map instance.- Parameters:
path
-saveslot
- this saveslot will become the active- Returns:
- returns true if the map could be loaded and false if it failed
-
getMap
public static Map getMap()
Returns the currently loaded map.- Returns:
- the map
-
setMap
public static void setMap(Map map)
- Parameters:
map
-
-
getLightEngine
public static LightEngine getLightEngine()
The light engine doing the lighting.- Returns:
- can return null
-
setLightEngine
public static void setLightEngine(LightEngine le)
- Parameters:
le
-
-
staticDispose
public static void staticDispose()
Disposes static stuff.
-
executeCommand
public void executeCommand(Command cmd)
Executes the command and saves it for possible undo/redo.- Parameters:
cmd
-
-
undoCommand
public void undoCommand()
-
redoCommand
public void redoCommand()
-
useSaveSlot
public void useSaveSlot(int slot)
Uses a specific save slot for loading and saving the map. Can be called before callinginit()
.- Parameters:
slot
-
-
setMapName
public void setMapName(java.lang.String mapName)
Set the map name which is loaded then. Should be called before theinit()
- Parameters:
mapName
- the name of the map on the file system
-
getSaveSlot
public int getSaveSlot()
Get the save slot used for loading and saving the map.- Returns:
- save slot number
-
newSaveSlot
public int newSaveSlot()
Uses a new save slot as the save slot- Returns:
- the new save slot number
-
init
public void init()
This method works like a constructor. Everything is loaded here. You must set your custom map generator, if you want one, before calling this method, because chunk loading is started by calling this method. Uses last set saveslot and mapName. Set before calling this.- See Also:
init(java.lang.String, int)
-
init
public void init(java.lang.String mapName, int saveslot)
This method works like a constructor. Everything is loaded here. You must Set your custom map generator optionally, before calling this method.- Parameters:
mapName
- name on disksaveslot
-- See Also:
init()
,Map.setDefaultGenerator(com.bombinggames.wurfelengine.core.map.Generator)
-
update
public void update(float dt)
Main method which is called every refresh.- Parameters:
dt
- time since last call
-
showCursor
public void showCursor()
-
getDevTools
public DevTools getDevTools()
- Returns:
-
isInitalized
public boolean isInitalized()
- Specified by:
isInitalized
in interfaceGameManager
- Returns:
-
onEnter
public void onEnter()
Description copied from interface:GameManager
Override to specify what should happen when the mangager becomes active. Super call must not be implemented.- Specified by:
onEnter
in interfaceGameManager
-
enter
public final void enter()
Description copied from interface:GameManager
Should be called when the manager becomes active. CallsGameManager.onEnter()
.- Specified by:
enter
in interfaceGameManager
- See Also:
GameManager.onEnter()
-
exit
public void exit()
Description copied from interface:GameManager
Should get called when you leave the editor. To extend this method you should overwrite adn call super ethod.- Specified by:
exit
in interfaceGameManager
-
save
public boolean save()
saves the map and the complete game state- Returns:
-
dispose
public void dispose()
Description copied from interface:GameManager
should be called if removed from memory- Specified by:
dispose
in interfaceGameManager
-
getSelectedEntities
public java.util.ArrayList<AbstractEntity> getSelectedEntities()
- Returns:
- selected entities but map editor entities
-
setSelectedEnt
public void setSelectedEnt(java.util.ArrayList<AbstractEntity> newSel)
filter map editor entities- Parameters:
newSel
-
-
getCursor
public Cursor getCursor()
Get the entity laying under the cursor.- Returns:
-
-