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 voiddispose()should be called if removed from memoryvoidenter()Should be called when the manager becomes active.voidexecuteCommand(Command cmd)Executes the command and saves it for possible undo/redo.voidexit()Should get called when you leave the editor.CursorgetCursor()Get the entity laying under the cursor.DevToolsgetDevTools()static LightEnginegetLightEngine()The light engine doing the lighting.static MapgetMap()Returns the currently loaded map.intgetSaveSlot()Get the save slot used for loading and saving the map.java.util.ArrayList<AbstractEntity>getSelectedEntities()voidinit()This method works like a constructor.voidinit(java.lang.String mapName, int saveslot)This method works like a constructor.booleanisInitalized()static booleanloadMap(java.io.File path, int saveslot)Tries loading a new map instance.intnewSaveSlot()Uses a new save slot as the save slotvoidonEnter()Override to specify what should happen when the mangager becomes active.voidredoCommand()booleansave()saves the map and the complete game statestatic voidsetLightEngine(LightEngine le)static voidsetMap(Map map)voidsetMapName(java.lang.String mapName)Set the map name which is loaded then.voidsetSelectedEnt(java.util.ArrayList<AbstractEntity> newSel)filter map editor entitiesvoidshowCursor()static voidstaticDispose()Disposes static stuff.static voidstaticUpdate(float dt)update every static update methodvoidundoCommand()voidupdate(float dt)Main method which is called every refresh.voiduseSaveSlot(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:
isInitalizedin interfaceGameManager- Returns:
-
onEnter
public void onEnter()
Description copied from interface:GameManagerOverride to specify what should happen when the mangager becomes active. Super call must not be implemented.- Specified by:
onEnterin interfaceGameManager
-
enter
public final void enter()
Description copied from interface:GameManagerShould be called when the manager becomes active. CallsGameManager.onEnter().- Specified by:
enterin interfaceGameManager- See Also:
GameManager.onEnter()
-
exit
public void exit()
Description copied from interface:GameManagerShould get called when you leave the editor. To extend this method you should overwrite adn call super ethod.- Specified by:
exitin interfaceGameManager
-
save
public boolean save()
saves the map and the complete game state- Returns:
-
dispose
public void dispose()
Description copied from interface:GameManagershould be called if removed from memory- Specified by:
disposein 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:
-
-