aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/script/ai.cpp
diff options
context:
space:
mode:
authorPeter Kohaut2017-03-23 16:20:10 +0100
committerPeter Kohaut2017-03-23 16:20:10 +0100
commit1c083fe0004c2b952da3bd8e45de0c4139f62786 (patch)
treee5c1da202a2fc646a0dfa45da4af62ba53828c40 /engines/bladerunner/script/ai.cpp
parent4fe4cc8c0e975c3d5a3888f65335003108027a22 (diff)
downloadscummvm-rg350-1c083fe0004c2b952da3bd8e45de0c4139f62786.tar.gz
scummvm-rg350-1c083fe0004c2b952da3bd8e45de0c4139f62786.tar.bz2
scummvm-rg350-1c083fe0004c2b952da3bd8e45de0c4139f62786.zip
BLADERUNNER: Reorganized script files
Diffstat (limited to 'engines/bladerunner/script/ai.cpp')
-rw-r--r--engines/bladerunner/script/ai.cpp168
1 files changed, 168 insertions, 0 deletions
diff --git a/engines/bladerunner/script/ai.cpp b/engines/bladerunner/script/ai.cpp
new file mode 100644
index 0000000000..d51200dc55
--- /dev/null
+++ b/engines/bladerunner/script/ai.cpp
@@ -0,0 +1,168 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "bladerunner/script/ai.h"
+
+#include "bladerunner/bladerunner.h"
+
+#include "bladerunner/actor.h"
+
+namespace BladeRunner {
+
+AIScripts::AIScripts(BladeRunnerEngine *vm, int actorsCount) : _vm(vm), _inScriptCounter(0) {
+ _actorsCount = actorsCount;
+ _actorUpdating = new bool[actorsCount];
+ _AIScripts = new AIScriptBase*[actorsCount];
+ for (int i = 0; i < actorsCount; ++i) {
+ _AIScripts[i] = nullptr;
+ _actorUpdating[i] = false;
+ }
+
+ _AIScripts[0] = new AIScriptMcCoy(_vm);
+ _AIScripts[15] = new AIScriptRunciter(_vm);
+ _AIScripts[23] = new AIScriptOfficerLeroy(_vm);
+}
+
+AIScripts::~AIScripts() {
+ for (int i = 0; i < _actorsCount; ++i) {
+ delete _AIScripts[i];
+ _AIScripts[i] = nullptr;
+ }
+ delete[] _AIScripts;
+ delete[] _actorUpdating;
+}
+
+void AIScripts::Initialize(int actor) {
+ assert(actor < _actorsCount);
+ if (_AIScripts[actor])
+ _AIScripts[actor]->Initialize();
+}
+
+void AIScripts::Update(int actor) {
+ assert(actor < _actorsCount);
+ if (this->_actorUpdating[actor] != 1) {
+ this->_actorUpdating[actor] = true;
+ ++this->_inScriptCounter;
+ if (_AIScripts[actor])
+ _AIScripts[actor]->Update();
+ --this->_inScriptCounter;
+ this->_actorUpdating[actor] = false;
+ }
+}
+
+void AIScripts::TimerExpired(int actor, int timer) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->TimerExpired(timer);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::CompletedMovementTrack(int actor) {
+ assert(actor < _actorsCount);
+ if (!_vm->_actors[actor]->inCombat()) {
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->CompletedMovementTrack();
+ }
+ _inScriptCounter--;
+ }
+}
+
+void AIScripts::EnteredScene(int actor, int setId) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->EnteredScene(setId);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::OtherAgentEnteredThisScene(int actor, int otherActorId) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->OtherAgentEnteredThisScene(otherActorId);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::OtherAgentExitedThisScene(int actor, int otherActorId) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->OtherAgentExitedThisScene(otherActorId);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::Retired(int actor, int retiredByActorId) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->Retired(retiredByActorId);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::GoalChanged(int actor, int currentGoalNumber, int newGoalNumber) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->GoalChanged(currentGoalNumber, newGoalNumber);
+ }
+ _inScriptCounter--;
+}
+
+bool AIScripts::ReachedMovementTrackWaypoint(int actor, int waypointId) {
+ assert(actor < _actorsCount);
+ bool result = false;
+ if (!_vm->_actors[actor]->inCombat()) {
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ result = _AIScripts[actor]->ReachedMovementTrackWaypoint(waypointId);
+ }
+ _inScriptCounter--;
+ }
+ return result;
+}
+
+void AIScripts::UpdateAnimation(int actor, int *animation, int *frame) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->UpdateAnimation(animation, frame);
+ }
+ _inScriptCounter--;
+}
+
+void AIScripts::ChangeAnimationMode(int actor, int mode) {
+ assert(actor < _actorsCount);
+ _inScriptCounter++;
+ if (_AIScripts[actor]) {
+ _AIScripts[actor]->ChangeAnimationMode(mode);
+ }
+ _inScriptCounter--;
+}
+
+} // End of namespace BladeRunner