TrinityCore
Loading...
Searching...
No Matches
ScriptActions.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptActions.h"
19#include "GameTime.h"
20
21namespace Scripting::v2
22{
23ActionBase::ActionBase() : _isReady(false)
24{
25}
26
27ActionBase::ActionBase(ActionBase const& other) = default;
28ActionBase::ActionBase(ActionBase&& other) noexcept = default;
29ActionBase& ActionBase::operator=(ActionBase const& other) = default;
30ActionBase& ActionBase::operator=(ActionBase&& other) noexcept = default;
31
32ActionBase::~ActionBase() = default;
33
34bool ActionBase::IsReady() const noexcept
35{
36 return _isReady;
37}
38
40{
41 _isReady = true;
42}
43
45{
46 action.MarkCompleted();
47}
48
49WaitAction::WaitAction(TimePoint waitEnd) : _waitEnd(waitEnd)
50{
51}
52
53bool WaitAction::IsReady() const noexcept
54{
55 return _waitEnd <= GameTime::Now();
56}
57}
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
Definition Duration.h:40
void MarkCompleted() noexcept
ActionBase & operator=(ActionBase const &other)
virtual bool IsReady() const noexcept
bool IsReady() const noexcept override
WaitAction(TimePoint waitEnd)
TimePoint Now()
Current chrono steady_clock time point.
Definition GameTime.cpp:67
void MarkActionCompleted(ActionBase &action)