forked from OpenDungeons/OpenDungeons
/
RoomDungeonTemple.cpp
107 lines (91 loc) · 3.12 KB
/
RoomDungeonTemple.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright (C) 2011-2014 OpenDungeons Team
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "RoomDungeonTemple.h"
#include "GameMap.h"
#include "Creature.h"
#include "Weapon.h"
#include "CreatureAction.h"
#include "CreatureSound.h"
#include "RoomObject.h"
RoomDungeonTemple::RoomDungeonTemple():
mWaitTurns(0),
mTempleObject(NULL)
{
mType = dungeonTemple;
}
void RoomDungeonTemple::absorbRoom(Room* room)
{
Room::absorbRoom(room);
// Get back the temple mesh reference
if (!mRoomObjects.empty())
{
mTempleObject = mRoomObjects.begin()->second;
}
else
{
// Make sure the reference gets updated when createMesh() is called
mTempleObject = NULL;
}
}
void RoomDungeonTemple::createMesh()
{
Room::createMesh();
// Don't recreate the portal if it's already done.
if (mTempleObject != NULL)
return;
mTempleObject = loadRoomObject("DungeonTempleObject");
createRoomObjectMeshes();
}
void RoomDungeonTemple::destroyMesh()
{
Room::destroyMesh();
}
void RoomDungeonTemple::produceKobold()
{
if (mWaitTurns > 0)
{
--mWaitTurns;
return;
}
mWaitTurns = 30;
// If the room has been destroyed, or has not yet been assigned any tiles, then we
// cannot determine where to place the new creature and we should just give up.
if (mCoveredTiles.empty())
return;
// Create a new creature and copy over the class-based creature parameters.
CreatureDefinition *classToSpawn = getGameMap()->getClassDescription("Kobold");
if (classToSpawn == NULL)
{
std::cout << "Error: No 'Kobold' creature definition" << std::endl;
return;
}
//TODO: proper assignemt of creature definition through constrcutor
Creature* newCreature = new Creature(getGameMap());
newCreature->setCreatureDefinition(classToSpawn);
newCreature->setName(newCreature->getUniqueCreatureName());
newCreature->setPosition(Ogre::Vector3((Ogre::Real)mCoveredTiles[0]->x,
(Ogre::Real)mCoveredTiles[0]->y,
(Ogre::Real)0));
newCreature->setColor(getColor());
// Default weapon is empty
newCreature->setWeaponL(new Weapon("none", 0.0, 1.0, 0.0, "L", newCreature));
newCreature->setWeaponR(new Weapon("none", 0.0, 1.0, 0.0, "R", newCreature));
newCreature->createMesh();
newCreature->getWeaponL()->createMesh();
newCreature->getWeaponR()->createMesh();
getGameMap()->addCreature(newCreature);
}