Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc @ 2006

Last change on this file since 2006 was 2006, checked in by landauf, 16 years ago

many changes, can't remember everything, but these are the most important:

  • attaching entities to other entities works
  • displaying models, lights and shadows works
  • controlling a spectator works
  • removed an update hack in PositionableEntity because I've found a much better solution

and with "works" I mean: it works on client, server and standalone

File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "Gametype.h"
31
32#include "core/CoreIncludes.h"
33#include "objects/infos/PlayerInfo.h"
34#include "objects/worldentities/pawns/Spectator.h"
35
36#include "network/Host.h"
37
38namespace orxonox
39{
40    CreateUnloadableFactory(Gametype);
41
42    Gametype::Gametype()
43    {
44        RegisterObject(Gametype);
45
46        this->defaultPawn_ = Class(Spectator);
47
48        COUT(0) << "created Gametype" << std::endl;
49    }
50
51    void Gametype::addPlayer(PlayerInfo* player)
52    {
53        this->players_.insert(player);
54        this->playerJoined(player);
55
56        ControllableEntity* newpawn = this->defaultPawn_.fabricate();
57        player->startControl(newpawn);
58    }
59
60    void Gametype::removePlayer(PlayerInfo* player)
61    {
62        if (this->players_.find(player) != this->players_.end())
63        {
64            player->stopControl();
65            this->players_.erase(player);
66            this->playerLeft(player);
67        }
68    }
69
70    void Gametype::playerJoined(PlayerInfo* player)
71    {
72        std::string message = player->getName() + " entered the game";
73        COUT(0) << message << std::endl;
74        network::Host::Broadcast(message);
75    }
76
77    void Gametype::playerLeft(PlayerInfo* player)
78    {
79        std::string message = player->getName() + " left the game";
80        COUT(0) << message << std::endl;
81        network::Host::Broadcast(message);
82    }
83
84    void Gametype::playerChangedName(PlayerInfo* player)
85    {
86        if (this->players_.find(player) != this->players_.end())
87        {
88            if (player->getName() != player->getOldName())
89            {
90                std::string message = player->getOldName() + " changed name to " + player->getName();
91                COUT(0) << message << std::endl;
92                network::Host::Broadcast(message);
93            }
94        }
95    }
96}
Note: See TracBrowser for help on using the repository browser.