Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - PlayerSingleton managing game actions #376

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/deps/openvic-simulation
Submodule openvic-simulation updated 43 files
+1 −1 src/headless/main.cpp
+2 −6 src/openvic-simulation/GameManager.cpp
+1 −3 src/openvic-simulation/GameManager.hpp
+569 −18 src/openvic-simulation/InstanceManager.cpp
+125 −5 src/openvic-simulation/InstanceManager.hpp
+381 −0 src/openvic-simulation/console/ConsoleInstance.cpp
+119 −0 src/openvic-simulation/console/ConsoleInstance.hpp
+121 −47 src/openvic-simulation/country/CountryInstance.cpp
+26 −18 src/openvic-simulation/country/CountryInstance.hpp
+8 −0 src/openvic-simulation/economy/GoodDefinition.cpp
+228 −62 src/openvic-simulation/economy/GoodInstance.cpp
+14 −4 src/openvic-simulation/economy/GoodInstance.hpp
+15 −9 src/openvic-simulation/economy/production/ArtisanalProducer.cpp
+1 −1 src/openvic-simulation/economy/production/ArtisanalProducerFactoryPattern.hpp
+1 −1 src/openvic-simulation/economy/production/FactoryProducer.cpp
+5 −0 src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
+7 −3 src/openvic-simulation/economy/trading/BuyResult.hpp
+5 −0 src/openvic-simulation/economy/trading/BuyUpToOrder.hpp
+12 −6 src/openvic-simulation/economy/trading/MarketInstance.cpp
+3 −1 src/openvic-simulation/economy/trading/MarketInstance.hpp
+4 −0 src/openvic-simulation/economy/trading/SellResult.hpp
+1 −1 src/openvic-simulation/interface/GFXObject.cpp
+2 −2 src/openvic-simulation/interface/GFXObject.hpp
+1 −1 src/openvic-simulation/map/MapDefinition.cpp
+0 −19 src/openvic-simulation/map/MapInstance.cpp
+0 −4 src/openvic-simulation/map/MapInstance.hpp
+2 −4 src/openvic-simulation/map/Mapmode.cpp
+42 −18 src/openvic-simulation/map/ProvinceInstance.cpp
+10 −8 src/openvic-simulation/map/ProvinceInstance.hpp
+3 −0 src/openvic-simulation/military/Leader.cpp
+13 −18 src/openvic-simulation/military/Leader.hpp
+18 −13 src/openvic-simulation/military/UnitInstance.cpp
+36 −12 src/openvic-simulation/military/UnitInstance.hpp
+117 −125 src/openvic-simulation/military/UnitInstanceGroup.cpp
+48 −25 src/openvic-simulation/military/UnitInstanceGroup.hpp
+6 −0 src/openvic-simulation/misc/GameRulesManager.hpp
+2 −7 src/openvic-simulation/misc/SimulationClock.cpp
+3 −7 src/openvic-simulation/misc/SimulationClock.hpp
+1 −1 src/openvic-simulation/politics/Rule.cpp
+1 −19 src/openvic-simulation/pop/Pop.cpp
+8 −8 src/openvic-simulation/pop/Pop.hpp
+24 −1 src/openvic-simulation/types/Colour.hpp
+4 −0 src/openvic-simulation/utility/StringUtils.hpp
43 changes: 0 additions & 43 deletions extension/doc_classes/GameSingleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,12 @@
Return a [Texture2DArray] containing all the textures that the province shape image was split into.
</description>
</method>
<method name="get_selected_province_index" qualifiers="const">
<return type="int" />
<description>
Returns the [int] index of the currently selected province, or [code]0[/code] if there is no selected province.
</description>
</method>
<method name="get_terrain_texture" qualifiers="const">
<return type="Texture2DArray" />
<description>
Return a [Texture2DArray] containing all terrain textures, both the solid blue generated water texture and the loaded land terrain textures.
</description>
</method>
<method name="get_viewed_country_capital_position" qualifiers="const">
<return type="Vector2" />
<description>
Returns the viewed country's capital position as a normalized [Vector2], or [code](0.0, 0.0)[/code] if no country is being viewed.
</description>
</method>
<method name="is_parchment_mapmode_allowed" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -177,20 +165,6 @@
Sets the active mapmode to that identified by [param index]. Returns [code]FAILED[/code] if the mapmode index is invalid, otherwise returns [code]OK[/code].
</description>
</method>
<method name="set_selected_province">
<return type="void" />
<param index="0" name="index" type="int" />
<description>
Sets the currently selected province to that identified by [param index], or unselects the currently selected province if [param index] is [code]0[/code].
</description>
</method>
<method name="set_viewed_country_by_province_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
Sets the viewed country to that which owns the province identified by [param province_index], or unsets the viewed country if the province has no owner/is uncolonised. Returns [code]FAILED[/code] if the [param province_index] is invalid, otherwise returns [code]OK[/code].
</description>
</method>
<method name="setup_game">
<return type="int" enum="Error" />
<param index="0" name="bookmark_index" type="int" />
Expand All @@ -210,12 +184,6 @@
Sets up the simulation's clock and timestamps so that it can be unpaused, marking the move from the initialized but static game state used for the lobby to the dynamic game session that is ready to tick, update and simulate.
</description>
</method>
<method name="unset_selected_province">
<return type="void" />
<description>
Unselects the currently selected province, should there be one.
</description>
</method>
<method name="update_clock">
<return type="int" enum="Error" />
<description>
Expand All @@ -224,11 +192,6 @@
</method>
</methods>
<signals>
<signal name="clock_state_changed">
<description>
Signal emitted when the simulation's clock changes state (paused vs unpaused, clock speed, etc.).
</description>
</signal>
<signal name="gamestate_updated">
<description>
Signal emitted when the simulation's gamestate is updated (this happens after any event that changes the gamestate, e.g. a day tick, a player taking a decision, etc).
Expand All @@ -240,11 +203,5 @@
Signal emitted when the active mapmode changes, with the new mapmode's [param index] provided as a parameter.
</description>
</signal>
<signal name="province_selected">
<param index="0" name="index" type="int" />
<description>
Signal emitted when the currently selected province changes, with the new province's [param index] provided as a parameter (or [code]0[/code] if there is no longer a selected province/the change was de-selecting a province).
</description>
</signal>
</signals>
</class>
27 changes: 0 additions & 27 deletions extension/doc_classes/MenuSingleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@
<description>
</description>
</method>
<method name="decrease_speed">
<return type="void" />
<description>
</description>
</method>
<method name="expand_selected_province_building">
<return type="int" enum="Error" />
<param index="0" name="building_index" type="int" />
<description>
</description>
</method>
<method name="generate_search_cache">
<return type="int" enum="Error" />
<description>
Expand Down Expand Up @@ -191,11 +180,6 @@
<description>
</description>
</method>
<method name="increase_speed">
<return type="void" />
<description>
</description>
</method>
<method name="is_paused" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -248,12 +232,6 @@
<description>
</description>
</method>
<method name="set_paused">
<return type="void" />
<param index="0" name="paused" type="bool" />
<description>
</description>
</method>
<method name="show_control_tooltip">
<return type="void" />
<param index="0" name="text" type="String" />
Expand All @@ -270,11 +248,6 @@
<description>
</description>
</method>
<method name="toggle_paused">
<return type="void" />
<description>
</description>
</method>
<method name="update_search_results">
<return type="void" />
<param index="0" name="text" type="String" />
Expand Down
78 changes: 78 additions & 0 deletions extension/doc_classes/PlayerSingleton.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PlayerSingleton" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="decrease_speed">
<return type="void" />
<description>
</description>
</method>
<method name="expand_selected_province_building">
<return type="void" />
<param index="0" name="building_index" type="int" />
<description>
</description>
</method>
<method name="get_player_country_capital_position" qualifiers="const">
<return type="Vector2" />
<description>
</description>
</method>
<method name="get_selected_province_index" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="increase_speed">
<return type="void" />
<description>
</description>
</method>
<method name="set_auto_assign_leaders" qualifiers="const">
<return type="void" />
<param index="0" name="value" type="bool" />
<description>
</description>
</method>
<method name="set_auto_create_leaders" qualifiers="const">
<return type="void" />
<param index="0" name="value" type="bool" />
<description>
</description>
</method>
<method name="set_player_country_by_province_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
</description>
</method>
<method name="set_selected_province_by_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
</description>
</method>
<method name="toggle_paused">
<return type="void" />
<description>
</description>
</method>
<method name="unset_selected_province">
<return type="void" />
<description>
</description>
</method>
</methods>
<signals>
<signal name="province_selected">
<param index="0" name="index" type="int" />
<description>
</description>
</signal>
</signals>
</class>
9 changes: 9 additions & 0 deletions extension/src/openvic-extension/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "openvic-extension/singletons/MapItemSingleton.hpp"
#include "openvic-extension/singletons/MenuSingleton.hpp"
#include "openvic-extension/singletons/ModelSingleton.hpp"
#include "openvic-extension/singletons/PlayerSingleton.hpp"
#include "openvic-extension/singletons/SoundSingleton.hpp"

using namespace godot;
Expand All @@ -43,6 +44,7 @@ static MenuSingleton* _menu_singleton = nullptr;
static ModelSingleton* _model_singleton = nullptr;
static AssetManager* _asset_manager_singleton = nullptr;
static SoundSingleton* _sound_singleton = nullptr;
static PlayerSingleton* _player_singleton = nullptr;

void initialize_openvic_types(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
Expand Down Expand Up @@ -85,6 +87,10 @@ void initialize_openvic_types(ModuleInitializationLevel p_level) {
_sound_singleton = memnew(SoundSingleton);
Engine::get_singleton()->register_singleton("SoundSingleton", SoundSingleton::get_singleton());

ClassDB::register_class<PlayerSingleton>();
_player_singleton = memnew(PlayerSingleton);
Engine::get_singleton()->register_singleton("PlayerSingleton", PlayerSingleton::get_singleton());

ClassDB::register_class<MapMesh>();
ClassDB::register_abstract_class<GFXCorneredTileSupportingTexture>();

Expand Down Expand Up @@ -148,6 +154,9 @@ void uninitialize_openvic_types(ModuleInitializationLevel p_level) {

Engine::get_singleton()->unregister_singleton("SoundSingleton");
memdelete(_sound_singleton);

Engine::get_singleton()->unregister_singleton("PlayerSingleton");
memdelete(_player_singleton);
}

extern "C" {
Expand Down
Loading
Loading