//////////////////////////////////////////////////////////////////////////////
// This file is part of the Journey MMORPG client //
// Copyright © 2015-2016 Daniel Allendorf //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program 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 Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see . //
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Camera.h"
#include "Spawn.h"
#include "Combat/Combat.h"
#include "MapleMap/MapInfo.h"
#include "MapleMap/MapEffect.h"
#include "MapleMap/MapTilesObjs.h"
#include "MapleMap/MapBackgrounds.h"
#include "MapleMap/MapPortals.h"
#include "MapleMap/MapChars.h"
#include "MapleMap/MapMobs.h"
#include "MapleMap/MapReactors.h"
#include "MapleMap/MapNpcs.h"
#include "MapleMap/MapDrops.h"
#include "Physics/Physics.h"
#include "../Character/Player.h"
#include "../IO/KeyType.h"
#include "../Template/TimedQueue.h"
#include "../Template/Singleton.h"
namespace jrc
{
class Stage : public Singleton
{
public:
Stage();
void init();
// Loads the map to display.
void load(int32_t mapid, int8_t portalid);
// Remove all map objects and graphics.
void clear();
// Contruct the player from a character entry.
void loadplayer(const CharEntry& entry);
// Call 'draw()' of all objects on stage.
void draw(float alpha) const;
// Calls 'update()' of all objects on stage.
void update();
// Show a character effect.
void show_character_effect(int32_t cid, CharEffect::Id effect);
// Show a map-level field effect.
void add_effect(const std::string& path);
// Schedule a timed map-warp request used by intro scene scripts.
void schedule_intro_warp(int32_t mapid, int32_t delay_ms);
// Send key input to the stage.
void send_key(KeyType::Id keytype, int32_t keycode, bool pressed);
// Send mouse input to the stage.
Cursor::State send_cursor(bool pressed, Point position);
// Check if the specified id is the player's id.
bool is_player(int32_t cid) const;
// Returns a reference to the npcs on the current map.
MapNpcs& get_npcs();
// Returns a reference to the other characters on the current map.
MapChars& get_chars();
// Returns a reference to the mobs on the current map.
MapMobs& get_mobs();
// Returns a reference to the reactors on the current map.
MapReactors& get_reactors();
// Returns a reference to the drops on the current map.
MapDrops& get_drops();
// Returns a reference to the Player.
Player& get_player();
// Returns the id of the current map.
int32_t get_mapid() const;
// Return a reference to the attack and buff component.
Combat& get_combat();
// Return a pointer to a character, possibly the player.
Optional get_character(int32_t cid);
private:
void load_map(int32_t mapid);
void respawn(int8_t portalid);
void check_portals();
void check_seats();
void check_ladders(bool up);
void handle_held_actions();
void handle_directional_context(KeyAction::Id action, bool down);
void update_directional_context();
void check_drops();
void update_intro_warp();
bool is_intro_input_locked() const;
void release_intro_locked_actions();
enum State
{
INACTIVE,
TRANSITION,
ACTIVE
};
Camera camera;
Physics physics;
Player player;
Optional playable;
State state;
int32_t mapid;
uint64_t last_pickup_time;
MapInfo mapinfo;
MapTilesObjs tilesobjs;
MapBackgrounds backgrounds;
MapPortals portals;
MapReactors reactors;
MapNpcs npcs;
MapChars chars;
MapMobs mobs;
MapDrops drops;
MapEffect effect;
Combat combat;
int32_t pending_intro_warp_mapid;
int32_t pending_intro_warp_delay_ms;
};
}