From 1cfc933a59f37355ed8f5f614daf7e9429cb65b7 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Tue, 17 Aug 2021 06:57:29 +0300 Subject: [PATCH] Introduce a base class for system models --- src/openrct2/System.hpp | 60 ++++++++++++++++++++++++++++++++ src/openrct2/libopenrct2.vcxproj | 1 + 2 files changed, 61 insertions(+) create mode 100644 src/openrct2/System.hpp diff --git a/src/openrct2/System.hpp b/src/openrct2/System.hpp new file mode 100644 index 0000000000..2987df5538 --- /dev/null +++ b/src/openrct2/System.hpp @@ -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 diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 7029514897..91c438e8fc 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -436,6 +436,7 @@ +