supertux
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
GameObject Class Referenceabstract

This class is responsible for: Updating and drawing the object. More...

#include <game_object.hpp>

Inheritance diagram for GameObject:
Inheritance graph
[legend]
Collaboration diagram for GameObject:
Collaboration graph
[legend]

Public Member Functions

 GameObject (const std::string &name)
 
 GameObject (const ReaderMapping &reader)
 
virtual void finish_construction ()
 Called after all objects have been added to the Sector and the Sector is fully constructed. More...
 
UID get_uid () const
 
virtual void update (float dt_sec)=0
 This function is called once per frame and allows the object to update it's state. More...
 
virtual void draw (DrawingContext &context)=0
 The GameObject should draw itself onto the provided DrawingContext if this function is called. More...
 
virtual void save (Writer &writer)
 This function saves the object. More...
 
std::string save ()
 
virtual std::string get_class_name () const
 
virtual std::string get_exposed_class_name () const override
 
virtual std::string get_display_name () const
 Returns the display name of the object, translated to the user's locale.
 
virtual GameObjectClasses get_class_types () const
 List notable classes in inheritance hierarchy of class. More...
 
virtual std::vector< std::string > get_patches () const
 Version checking/updating, patch information.
 
virtual void update_version ()
 
int get_version () const
 Returns the current version of the object.
 
int get_latest_version () const
 Returns the latest version of the object.
 
bool is_up_to_date () const
 Checks whether the object's current version is equal to its latest one.
 
virtual bool is_singleton () const
 If true only a single object of this type is allowed in a given GameObjectManager.
 
virtual bool has_variable_size () const
 Does this object have variable size (secret area trigger, wind, etc.)
 
virtual bool is_saveable () const
 Indicates if the object will be saved. More...
 
virtual bool track_state () const
 Indicates if the object's state should be tracked. More...
 
virtual bool has_object_manager_priority () const
 Indicates if the object should be added at the beginning of the object list. More...
 
virtual bool has_settings () const
 Indicates if get_settings() is implemented. More...
 
virtual ObjectSettings get_settings ()
 
virtual GameObjectTypes get_types () const
 Get all types of the object, if available. More...
 
int get_type () const
 Returns the type index of the object.
 
virtual void after_editor_set ()
 
virtual void on_flip (float height)
 When level is flipped vertically.
 
virtual void remove_me ()
 schedules this object to be removed at the end of the frame
 
bool is_valid () const
 returns true if the object is not scheduled to be removed yet
 
void add_remove_listener (ObjectRemoveListener *listener)
 registers a remove listener which will be called if the object gets removed/destroyed
 
void del_remove_listener (ObjectRemoveListener *listener)
 unregisters a remove listener, so it will no longer be called if the object gets removed/destroyed
 
void set_name (const std::string &name)
 
const std::string & get_name () const
 Returns the name of the object.
 
virtual const std::string get_icon_path () const
 
virtual void stop_looping_sounds ()
 stops all looping sounds
 
virtual void play_looping_sounds ()
 continues all looping sounds
 
template<typename T >
T * get_component ()
 
void add_component (std::unique_ptr< GameObjectComponent > component)
 
void remove_component (GameObjectComponent *component)
 
virtual void save_state ()
 Save/check the current state of the object. More...
 
virtual void check_state ()
 
virtual void editor_delete ()
 The editor requested the deletion of the object.
 
virtual void editor_select ()
 The user clicked on the object in the editor and selected it.
 
virtual void editor_deselect ()
 The object got deselected.
 
virtual void editor_update ()
 Called each frame in the editor, used to keep linked objects together (e.g. More...
 
GameObjectManagerget_parent () const
 

Static Public Member Functions

static void register_class (ssq::VM &vm)
 

Protected Types

enum  TypeChange { INITIAL = -1 }
 When the type has been changed from the editor. More...
 

Protected Member Functions

void parse_type (const ReaderMapping &reader)
 Parse object type. More...
 
virtual void on_type_change (int old_type)
 
int type_id_to_value (const std::string &id) const
 Conversion between type ID and value. More...
 
std::string type_value_to_id (int value) const
 

Protected Attributes

std::string m_name
 a name for the gameobject, this is mostly a hint for scripts and for debugging, don't rely on names being set or being unique
 
int m_type
 Type of the GameObject. More...
 
std::vector< std::unique_ptr< FadeHelper > > m_fade_helpers
 Fade Helpers are for easing/fading script functions.
 
bool m_track_undo
 Track the following creation/deletion of this object for undo. More...
 

Friends

class GameObjectManager
 

Detailed Description

This class is responsible for: Updating and drawing the object.

This should happen in the update() and draw() functions. Both are called once per frame. Providing a safe way to remove the object by calling the remove_me functions. Base class for all the things that make up Levels' Sectors.${SRG_NEWPARAGRAPH}

     Each sector of a level holds a list of active ""GameObject""s, while the
     game is played.${SRG_NEWPARAGRAPH}

Member Enumeration Documentation

◆ TypeChange

enum GameObject::TypeChange
protected

When the type has been changed from the editor.

Member Function Documentation

◆ draw()

virtual void GameObject::draw ( DrawingContext context)
pure virtual

◆ editor_update()

virtual void GameObject::editor_update ( )
inlinevirtual

Called each frame in the editor, used to keep linked objects together (e.g.

platform on a path)

Reimplemented in TileMap, Platform, Coin, ResizeMarker, BezierMarker, and NodeMarker.

◆ finish_construction()

virtual void GameObject::finish_construction ( )
inlinevirtual

Called after all objects have been added to the Sector and the Sector is fully constructed.

If objects refer to other objects by name, those connection can be resolved here.

Reimplemented in TileMap, Platform, WillOWisp, Ghoul, and Coin.

◆ get_class_types()

GameObjectClasses GameObject::get_class_types ( ) const
virtual

List notable classes in inheritance hierarchy of class.

This makes it possible to efficiently look up all objects deriving from a particular intermediate class

Reimplemented in CrusherRoot, StickyTrigger, HeavyCoin, SpritedTrigger, LiveFireDormant, Player, StickyBadguy, LevelTime, LiveFireAsleep, Crusher, HeavyBrick, BadGuy, WillOWisp, Trigger, Dispenser, BicyclePlatform, Camera, PneumaticPlatform, TileMap, LeafShot, ParticleSystem, BonusBlock, Spotlight, MovingSprite, worldmap::SpawnPointObject, TextArrayObject, MrBomb, CustomParticleSystem, Platform, WalkingBadguy, Granito, TextObject, Thunderstorm, AmbientSound, Background, DiveMine, CloudParticleSystem, MrIceBlock, Decal, Gradient, RainParticleSystem, ParticleSystem_Interactive, SpawnPointMarker, TextArea, Flame, ConveyorBelt, Torch, MovingObject, Climbable, Haywire, LitObject, ScriptedObject, Owl, PathGameObject, TextScroller, CorruptedGranito, Dart, GranitoBig, MoleRock, Coin, SkyDive, Snail, Candle, Wind, Stalactite, MagicBlock, MusicObject, UnstableTile, FishJumping, FishSwimming, GhostTree, RootSapling, WalkingCandle, FallBlock, SoundObject, BouncingSnowball, Jumpy, Kugelblitz, FloatingImage, PowerUp, Rock, RustyTrampoline, worldmap::Tux, AngryStone, Igel, Root, Tarantula, Zeekling, BigSnowball, CustomParticleSystemFile, LiveFire, Mole, Stumpy, Toad, Yeti, AmbientLight, Bumper, Firefly, Key, Lantern, ParticleZone, SpriteParticle, SSpiky, Totem, GhostParticleSystem, InfoBlock, InvisibleWall, SnowParticleSystem, Trampoline, SecretAreaTrigger, worldmap::WorldMapObject, GoldBomb, Electrifier, Particles, WeakBlock, worldmap::LevelTile, worldmap::SpecialTile, CorruptedGranitoBig, DartTrap, CirclePlatform, DisplayEffect, Explosion, Ispy, Shard, PlayerStatusHUD, worldmap::SpriteChange, FishChasing, KamikazeSnowball, Plant, YetiStalactite, Brick, RubLight, worldmap::Teleporter, Crystallo, FlyingSnowBall, RCrystallo, ViciousIvy, WalkingLeaf, ResizeMarker, CaptainSnowball, GranitoGiant, MrTree, SmartBall, Bullet, Light, PushButton, StickyObject, SequenceTrigger, Boss, Ghoul, SCrystallo, Spiky, Block, Flower, HurtingPlatform, Door, FishHarmless, ShortFuse, SmartBlock, SnowBall, InvisibleBlock, ScriptTrigger, Switch, Snowman, MarkerObject, BicyclePlatformChild, FloatingText, PneumaticPlatformChild, RainSplash, VerticalStripes, TreeWillOWisp, BouncyCoin, CoinRain, EndSequence, PulsingLight, SpecialRiser, WaterDrop, BezierMarker, FallingCoin, Fireworks, SmokeCloud, Star, NodeMarker, CoinExplode, EndSequenceFireworks, EndSequenceWalk, GrowUp, and OneUp.

◆ get_types()

GameObjectTypes GameObject::get_types ( ) const
virtual

◆ has_object_manager_priority()

virtual bool GameObject::has_object_manager_priority ( ) const
inlinevirtual

Indicates if the object should be added at the beginning of the object list.

Reimplemented in Player.

◆ has_settings()

virtual bool GameObject::has_settings ( ) const
inlinevirtual

Indicates if get_settings() is implemented.

If true the editor will display Tip and ObjectMenu.

Reimplemented in ResizeMarker, BezierMarker, and NodeMarker.

◆ is_saveable()

virtual bool GameObject::is_saveable ( ) const
inlinevirtual

◆ parse_type()

void GameObject::parse_type ( const ReaderMapping reader)
protected

Parse object type.

◆ save()

void GameObject::save ( Writer writer)
virtual

This function saves the object.

Editor will use that.

Reimplemented in CustomParticleSystem, and WeakBlock.

◆ save_state()

void GameObject::save_state ( )
virtual

Save/check the current state of the object.

Reimplemented in Camera, TileMap, Platform, Coin, MarkerObject, NodeMarker, BezierMarker, and ResizeMarker.

◆ track_state()

virtual bool GameObject::track_state ( ) const
inlinevirtual

Indicates if the object's state should be tracked.

If false, load_state() and save_state() calls would not do anything.

Reimplemented in Player, and MarkerObject.

◆ type_id_to_value()

int GameObject::type_id_to_value ( const std::string &  id) const
protected

Conversion between type ID and value.

◆ update()

void GameObject::update ( float  dt_sec)
pure virtual

This function is called once per frame and allows the object to update it's state.

The dt_sec is the time that has passed since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode). This function is not called in the Editor.

Implemented in CrusherRoot, StickyTrigger, SpritedTrigger, HeavyCoin, Player, AmbientSound, TileMap, Trigger, BadGuy, Crusher, BicyclePlatform, PneumaticPlatform, Camera, TextObject, Decal, MovingSprite, Climbable, ConveyorBelt, Spotlight, TextArrayObject, CustomParticleSystem, worldmap::WorldMapObject, Platform, Thunderstorm, Background, FloatingImage, Electrifier, RainParticleSystem, SpriteParticle, CloudParticleSystem, Particles, LevelTime, TextArea, Coin, Gradient, TextScroller, PathGameObject, Torch, worldmap::Tux, DisplayEffect, Explosion, LitObject, SpecialRiser, PlayerStatusHUD, MagicBlock, RainSplash, Door, FloatingText, Flower, ScriptedObject, Block, Bullet, Light, SoundObject, StickyObject, UnstableTile, Switch, MusicObject, VerticalStripes, Wind, PneumaticPlatformChild, SpawnPointMarker, MarkerObject, BicyclePlatformChild, BigSnowball, Bumper, Firefly, GhostParticleSystem, OneUp, Rock, RustyTrampoline, SnowParticleSystem, FishSwimming, EndSequence, FallBlock, FallingCoin, GrowUp, InfoBlock, Ispy, Key, ParticleZone, PowerUp, PulsingLight, WaterDrop, WeakBlock, BouncyCoin, CoinRain, Fireworks, SmokeCloud, Star, AmbientLight, RubLight, Shard, Trampoline, YetiStalactite, CirclePlatform, CoinExplode, and PushButton.

Member Data Documentation

◆ m_track_undo

bool GameObject::m_track_undo
protected

Track the following creation/deletion of this object for undo.

If track_state() returns false, this object would not be tracked, regardless of the value of this variable.

◆ m_type

int GameObject::m_type
protected

Type of the GameObject.

Used to provide special functionality, based on the child object.


The documentation for this class was generated from the following files: