Introduce a base class for system models

This commit is contained in:
ZehMatt 2021-08-17 06:57:29 +03:00
parent 4ece997ff3
commit 1cfc933a59
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
2 changed files with 61 additions and 0 deletions

60
src/openrct2/System.hpp Normal file
View File

@ -0,0 +1,60 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
namespace OpenRCT2
{
struct IContext;
// Base class for systems that are hosted in the Context.
class System
{
IContext& _context;
public:
System(IContext& owner)
: _context(owner)
{
}
virtual ~System() = default;
// Called before a tick.
virtual void PreTick()
{
}
// Called every game tick, which by default is 40hz.
virtual void Tick()
{
}
// Called after a tick.
virtual void PostTick()
{
}
// Called every frame.
virtual void Update()
{
}
IContext& GetContext()
{
return _context;
}
const IContext& GetContext() const
{
return _context;
}
};
} // namespace OpenRCT2

View File

@ -436,6 +436,7 @@
<ClInclude Include="scripting\bindings\network\ScSocket.hpp" />
<ClInclude Include="scripting\bindings\world\ScTile.hpp" />
<ClInclude Include="sprites.h" />
<ClInclude Include="System.hpp" />
<ClInclude Include="title\TitleScreen.h" />
<ClInclude Include="title\TitleSequence.h" />
<ClInclude Include="title\TitleSequenceManager.h" />