Skip to content

Campaing

Gustavo Lopes edited this page Oct 19, 2023 · 9 revisions

A Campaing based plugin

The GodoLibur is a "Campaing based" plugin, meaning it incorporates a system where the developer can create their game scenes on top of a "campaing" which manages all the important background elements of a "regular adventure game experience", things like: Player Inventory, UI, connecting levels with one another.

flowchart LR

    title[Campaing Visual representation]
    title-->A[root]
    style title fill:#FFF,stroke:#FFF
    linkStyle 0 stroke:#FFF,stroke-width:0;

    A--- B[Campaing]
    A --- X[CampaingOverseer]
    B --- C[UI]
    B --- D[SceneHandler]
    B --- E[PlayerInventory]
    D --- G[Scene]
Loading

Obs.: The "root" node is the first node in the "SceneTree" of Godot.

Because of this, the first nodes we are going to take a look, is the "Campaing" related nodes.

Campaing Overseer

The CampaingOverseer is probably the best place to start, since is the one responsible for loading, saving, and handling Campaings during the runtime of your game. This node is an "Autoload" meaning that this node functions as a Singleton where you can reference in any part of your code.

Methods

save_game

func save_game(save_filename: String = "") -> Dictionary:

As it's name suggests, this function is responsible for saving the progress of any ongoing campaings during game time. It has an optional argument "save_filename". If "save_filename" is specified, then the game is saved on a file with the name that it was specified.

When saving, you might get an error , if the player is trying to save when there is no active campaing available.

The method returns in the end, a dictionary containing every information of the campaing that it was saved.

obs.: the filename is only the name of the file, do not include the extension.

load_game

func load_game(save_filename: String) -> void:

Load the game information located in the "file" specified in the "save_filename" argument. Just like when saving the game, only provide the filename excluding the extension.

When loading a game, be sure that the save exist, or you will get an error.

start_campaing

func start_campaing(campaing_path: String, player_information : Dictionary = {}) -> void:

Use this function to start your campaing at the specified "campaing_path", if there is any previous recorded player information on different screens, then pass this information as the "player_information" argument.

Signals

campaing_changed()

signal campaing_changed()

Triggered when the current_campaing property is changed

is_saving_campaing()

signal is_saving_campaing()

Triggered when the function save_game is called.

saving_campaing_finished()

signal saving_campaing_finished()

Triggered when the function save_game ends its execution.

is_loading_campaing()

signal is_loading_campaing()

Triggered when the function load_game is called.

loading_campaing_finished()

signal loading_campaing_finished()

Triggered when the function load_game ends its execution.

Properties

current_campaing

var current_campaing : Campaing

This property as it's name implies, holds the current ongoing campaing. If during the game, you want code to retrieve the campaing and it's information, you should do this by getting this property, like this:

func _ready():
   var campaing = CampaingOverseer.current_campaing

Obs.: Don't try to use get_tree().current_scene to get the Campaing node, because this property is now reserved to the actual current scene, which is the active scene in the SceneHandler node. For more information check our tutorial on Handling Scenes.

How to use

As stated before, the CampaingOverseer works as an AutoLoad, and it should remain as it is, since this is a very important node that needs to be working at all times. You will use this node in four instances:

  • Starting a new campaing
  • Loading a campaing
  • Saving campaing current state
  • Access current campaing state

Ok, so let's create now some Campaings!

Creating Campaings

As already stated, if you are going to start the production of the scenes of your game, you have to start with the Campaing node. The Campaing Node is the starting line of every game made with this plugin, and essentially dictates the main features present in a Campaing of your game, since you can have multiple campaings in the same game, with different functionalities.

The logic behind the usage of this approach is to:

  • Avoid having nodes being instantiated in a time were they are unnecessary (essentially reserving the use of Singletons only when they are essential to the entire workings of the plugin and need to be constantly active).
  • Allow the game developer choose which features each campaing has.
  • Be able to visualize which features are present in a Campaing, by instantiating them in the Editor.
  • Only focus on inserting features that are related to the Scene.

Methods

Signals

signal campaing_ready()
signal paused_status_changed(status)

Properties

How to use

Clone this wiki locally