/***************************************************************************** * Copyright (c) 2014-2018 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 #ifdef __ENABLE_SCRIPTING__ # include "Duktape.hpp" # include namespace OpenRCT2::Scripting { class ScDisposable { private: std::function _onDispose; public: ScDisposable(std::function onDispose) : _onDispose(onDispose) { } void dispose() { if (_onDispose) { _onDispose(); } } static void Register(duk_context* ctx) { dukglue_register_method(ctx, &ScDisposable::dispose, "dispose"); } }; } // namespace OpenRCT2::Scripting #endif