V-Gears 0
Free Final Fantasy VII engine.
BattleManager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreSingleton.h>
19#include "Enemy.h"
20#include "Event.h"
21#include "Manager.h"
24
28class BattleManager : public Manager, public Ogre::Singleton<BattleManager>{
29
30 public:
31
35 enum LAYOUT{
36
43 NORMAL = 0,
44
52
61
71
81
88 SOLO = 5,
89
96
103
111 };
112
116 struct Spoil {
117
121 unsigned int id;
122
126 unsigned int qty;
127 };
128
133
137 unsigned int id;
138
142 Ogre::Vector3 location;
143
149 Ogre::Vector3 orientation;
150 };
151
156
160 virtual ~BattleManager();
161
167 void Input(const VGears::Event& event) override;
168
174 void UpdateDebug() override;
175
179 void OnResize() override;
180
186 void ClearField() override;
187
191 void ClearBattle() override;
192
196 void ClearWorld() override;
197
203 void StartBattle(const unsigned int id);
204
208 void EndBattle();
209
215 std::vector<Enemy> GetEnemies() const;
216
228 void AddEnemy(
229 const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible,
230 const bool targeteable, const bool active, const std::string cover
231 );
232
240 unsigned int ScriptGetEnemyCount() const;
241
251 Enemy* ScriptGetEnemy(const unsigned int index);
252
256 void Load();
257
264 void SetLayout(const LAYOUT layout);
265
271 void SetFormationId(const int id);
272
281 void SetNextFormationId(const int id);
282
290 void SetEscapeability(const float difficulty);
291
295 void SetSkipVictoryPose(const bool skip);
296
300 void SetSkipSpoils(const bool skip);
301
308 void SetLocation(const int id, const Ogre::String name);
309
315 void SetArenaBattle(const bool arena);
316
325 void SetInitialCamera(const unsigned int id);
326
334 void AddCamera(
335 const unsigned int id, const Ogre::Vector3 pos, const Ogre::Vector3 dir
336 );
337
338 private:
339
343 void LoadParty();
344
350 void UpdateField() override;
351
355 void UpdateBattle() override;
356
362 void UpdateWorld() override;
363
367 static const float ENEMY_SCALE;
368
372 static const float PARTY_SCALE;
373
377 static const float SCENE_SCALE;
378
382 Ogre::SceneNode* scene_node_;
383
388
393
394 // TODO: Location
395 //BattleLocation location_;
396
397 // TODO: Camera list
398 std::vector<BattleCamera> camera_;
399
403 unsigned int initial_camera_;
404
409
414
419
424
429
434
438 unsigned int money_;
439
443 std::vector<Spoil> spoil_;
444
448 std::vector<Enemy> enemies_;
449
453 std::vector<XmlBattleCharactersFile::BattleCharacter> character_model_map_;
454
458 std::vector<XmlBattleScenesFile::BattleScene> scene_model_map_;
459
463 // TODO std::vector<Player> party_;
464
465};
The battle manager.
Definition: BattleManager.h:28
unsigned int money_
Money earned during the current battle.
Definition: BattleManager.h:438
void SetInitialCamera(const unsigned int id)
Sets the initial camera.
Definition: BattleManager.cpp:295
void ClearBattle() override
Clears all battle information in the battle manager.
Definition: BattleManager.cpp:81
void EndBattle()
Ends the current battle.
Definition: BattleManager.cpp:147
std::vector< Enemy > enemies_
List of enemies for the battle.
Definition: BattleManager.h:448
void SetSkipVictoryPose(const bool skip)
Sets the battle to show or skip the victory pose.
Definition: BattleManager.cpp:252
void ClearField() override
Clears all field information in the battle manager.
Definition: BattleManager.cpp:77
void OnResize() override
Handles resizing events.
Definition: BattleManager.cpp:75
LAYOUT
Possible battle layouts.
Definition: BattleManager.h:35
@ SOLO
Reserved for scripted battles with only one character.
Definition: BattleManager.h:88
@ NORMAL
Normal battle.
Definition: BattleManager.h:43
@ PREEMPTIVE
Preemptive attack.
Definition: BattleManager.h:51
@ LOCKED
Locked formation.
Definition: BattleManager.h:110
@ SIDE_ATTACK
Party surrounds the enemy.
Definition: BattleManager.h:70
@ BACK_ATTACK
Party attacked from the back.
Definition: BattleManager.h:60
@ UNKNOWN_1
Unknown.
Definition: BattleManager.h:102
@ PINCER_ATTACK
Enemies surrounds the party.
Definition: BattleManager.h:80
@ UNKNOWN_0
Unknown.
Definition: BattleManager.h:95
int formation_id_
The current battle formation ID.
Definition: BattleManager.h:387
void SetFormationId(const int id)
Sets the battle formation ID.
Definition: BattleManager.cpp:225
std::vector< XmlBattleCharactersFile::BattleCharacter > character_model_map_
Map of playable character models.
Definition: BattleManager.h:453
virtual ~BattleManager()
Destructor.
Definition: BattleManager.cpp:63
void SetSkipSpoils(const bool skip)
Sets the battle to show or skip the spoils screens.
Definition: BattleManager.cpp:260
Ogre::SceneNode * scene_node_
The scene node.
Definition: BattleManager.h:382
std::vector< Spoil > spoil_
List of items earned during the battle.
Definition: BattleManager.h:443
void LoadParty()
Loads the party members into the battle.
Definition: BattleManager.cpp:303
bool preemptive_
Indicates if the battle can be preemptive (not if it will definitely be).
Definition: BattleManager.h:433
static const float ENEMY_SCALE
Scale factor for battle enemy models.
Definition: BattleManager.h:367
std::vector< XmlBattleScenesFile::BattleScene > scene_model_map_
Map of battle scene models.
Definition: BattleManager.h:458
std::vector< Enemy > GetEnemies() const
Retrieves the list of enemies.
Definition: BattleManager.cpp:169
void UpdateDebug() override
Updates the battle in the manager with debug information.
Definition: BattleManager.cpp:73
void SetLayout(const LAYOUT layout)
Sets the battle layout.
Definition: BattleManager.cpp:216
void UpdateWorld() override
Updates manager while in the world map.
Definition: BattleManager.cpp:353
void UpdateBattle() override
Updates the manager during a battle.
Definition: BattleManager.cpp:349
void AddEnemy(const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible, const bool targeteable, const bool active, const std::string cover)
Adds an enemy to the manager for the next battle.
Definition: BattleManager.cpp:171
float escape_difficulty_
Difficulty to escape the battle.
Definition: BattleManager.h:413
bool show_victory_pose_
Indicates if the victory pose must be shown at the battle end.
Definition: BattleManager.h:423
Enemy * ScriptGetEnemy(const unsigned int index)
Retrieves an enemy.
Definition: BattleManager.cpp:195
unsigned int ScriptGetEnemyCount() const
Retrieves the number of enemies in the battle.
Definition: BattleManager.cpp:193
bool show_spoils_
Indicates if the spoils screens must be shown at the battle end.
Definition: BattleManager.h:428
void Load()
Loads enemy info from the enemy XML enemy file.
void SetEscapeability(const float difficulty)
Sets escaping data for the battle.
Definition: BattleManager.cpp:243
void AddCamera(const unsigned int id, const Ogre::Vector3 pos, const Ogre::Vector3 dir)
Adds a camera for the next battle.
Definition: BattleManager.cpp:200
BattleManager()
Constructor.
Definition: BattleManager.cpp:52
LAYOUT layout_
Battle layout.
Definition: BattleManager.h:408
void SetLocation(const int id, const Ogre::String name)
Sets the battle location.
Definition: BattleManager.cpp:268
void SetNextFormationId(const int id)
Sets the battle formation ID for the next battle, if any.
Definition: BattleManager.cpp:234
void Input(const VGears::Event &event) override
Handles an input event.
Definition: BattleManager.cpp:71
bool arena_battle_
Indicates if the current battle is an arena one.
Definition: BattleManager.h:418
static const float SCENE_SCALE
Scale factor for battle background models.
Definition: BattleManager.h:377
void SetArenaBattle(const bool arena)
Indicates if the battle is an arena battle.
Definition: BattleManager.cpp:287
unsigned int initial_camera_
Default camera ID.
Definition: BattleManager.h:403
void StartBattle(const unsigned int id)
Starts a battle.
Definition: BattleManager.cpp:103
std::vector< BattleCamera > camera_
Definition: BattleManager.h:398
void UpdateField() override
Updates the manager while in the field.
Definition: BattleManager.cpp:347
static const float PARTY_SCALE
Scale factor for battle character models.
Definition: BattleManager.h:372
int next_formation_id_
The battle formation ID for the next battle, if any.
Definition: BattleManager.h:392
void ClearWorld() override
Clears all world map information in the battle manager.
Definition: BattleManager.cpp:99
Any enemy in a battle.
Definition: Enemy.h:24
A base manager.
Definition: Manager.h:24
Ogre::String String
Definition: TypeDefine.h:37
A battle camera settings.
Definition: BattleManager.h:132
Ogre::Vector3 location
Camera location.
Definition: BattleManager.h:142
unsigned int id
Camera ID.
Definition: BattleManager.h:137
Ogre::Vector3 orientation
Camera orientation.
Definition: BattleManager.h:149
Item earned during the battle.
Definition: BattleManager.h:116
unsigned int id
Item ID.
Definition: BattleManager.h:121
unsigned int qty
Item quantity.
Definition: BattleManager.h:126
An input event.
Definition: Event.h:84