2011-12-25 13:33:05 +00:00
|
|
|
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
|
2010-08-11 10:33:37 +00:00
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/server/gamecontext.h>
|
|
|
|
#include <engine/shared/config.h>
|
2010-11-13 13:22:19 +00:00
|
|
|
#include <game/server/gamemodes/DDRace.h>
|
2010-08-11 10:33:37 +00:00
|
|
|
|
|
|
|
#include "door.h"
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
CDoor::CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
|
|
|
|
int Number) :
|
|
|
|
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
2010-08-11 10:33:37 +00:00
|
|
|
{
|
2010-11-13 13:22:19 +00:00
|
|
|
m_Number = Number;
|
2010-08-11 10:33:37 +00:00
|
|
|
m_Pos = Pos;
|
2010-09-25 16:39:52 +00:00
|
|
|
m_Length = Length;
|
|
|
|
m_Direction = vec2(sin(Rotation), cos(Rotation));
|
|
|
|
vec2 To = Pos + normalize(m_Direction) * m_Length;
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-08-11 18:29:08 +00:00
|
|
|
GameServer()->Collision()->IntersectNoLaser(Pos, To, &this->m_To, 0);
|
2010-09-25 16:39:52 +00:00
|
|
|
ResetCollision();
|
2010-08-11 10:33:37 +00:00
|
|
|
GameWorld()->InsertEntity(this);
|
|
|
|
}
|
|
|
|
|
2010-09-01 08:52:59 +00:00
|
|
|
void CDoor::Open(int Tick, bool ActivatedTeam[])
|
2010-08-11 10:33:37 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
m_EvalTick = Server()->Tick();
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-25 16:39:52 +00:00
|
|
|
void CDoor::ResetCollision()
|
2010-08-11 10:33:37 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
for (int i = 0; i < m_Length - 1; i++)
|
2010-09-25 16:39:52 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
vec2 CurrentPos(m_Pos.x + (m_Direction.x * i),
|
|
|
|
m_Pos.y + (m_Direction.y * i));
|
|
|
|
if (GameServer()->Collision()->CheckPoint(CurrentPos)
|
|
|
|
|| GameServer()->Collision()->GetTile(m_Pos.x, m_Pos.y)
|
|
|
|
|| GameServer()->Collision()->GetFTile(m_Pos.x, m_Pos.y))
|
2011-01-21 13:18:50 +00:00
|
|
|
break;
|
|
|
|
else
|
2011-12-25 13:51:04 +00:00
|
|
|
GameServer()->Collision()->SetDCollisionAt(
|
|
|
|
m_Pos.x + (m_Direction.x * i),
|
|
|
|
m_Pos.y + (m_Direction.y * i), TILE_STOPA, 0/*Flags*/,
|
|
|
|
m_Number);
|
2010-09-25 16:39:52 +00:00
|
|
|
}
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-25 16:39:52 +00:00
|
|
|
void CDoor::Open(int Team)
|
2010-08-11 10:33:37 +00:00
|
|
|
{
|
2010-09-25 16:39:52 +00:00
|
|
|
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
2010-09-10 06:55:04 +00:00
|
|
|
|
2010-09-25 16:39:52 +00:00
|
|
|
void CDoor::Close(int Team)
|
|
|
|
{
|
2010-11-13 13:22:19 +00:00
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 10:33:37 +00:00
|
|
|
void CDoor::Reset()
|
|
|
|
{
|
2010-11-13 13:22:19 +00:00
|
|
|
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDoor::Tick()
|
|
|
|
{
|
2010-11-13 13:22:19 +00:00
|
|
|
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDoor::Snap(int SnappingClient)
|
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (NetworkClipped(SnappingClient, m_Pos)
|
|
|
|
&& NetworkClipped(SnappingClient, m_To))
|
2010-08-11 10:33:37 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
|
|
|
|
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
2014-01-13 16:00:49 +00:00
|
|
|
|
|
|
|
if (!pObj)
|
|
|
|
return;
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
pObj->m_X = (int) m_Pos.x;
|
|
|
|
pObj->m_Y = (int) m_Pos.y;
|
2010-08-11 10:33:37 +00:00
|
|
|
|
2010-09-08 16:22:11 +00:00
|
|
|
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
2011-12-25 13:51:04 +00:00
|
|
|
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
|
2014-01-13 16:00:49 +00:00
|
|
|
|
|
|
|
if((GameServer()->m_apPlayers[SnappingClient]->GetTeam() == -1
|
|
|
|
|| GameServer()->m_apPlayers[SnappingClient]->m_Paused)
|
|
|
|
&& GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID != SPEC_FREEVIEW)
|
|
|
|
Char = GameServer()->GetPlayerChar(GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID);
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Char == 0)
|
|
|
|
return;
|
2014-01-13 16:00:49 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Char->IsAlive()
|
|
|
|
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
|
|
|
|
&& (!Tick))
|
|
|
|
return;
|
2010-09-08 16:22:11 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Char->Team() == TEAM_SUPER)
|
2010-11-13 13:22:19 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pObj->m_FromX = (int) m_Pos.x;
|
|
|
|
pObj->m_FromY = (int) m_Pos.y;
|
2010-11-13 13:22:19 +00:00
|
|
|
}
|
|
|
|
else if (GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()])
|
2010-08-11 10:33:37 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pObj->m_FromX = (int) m_To.x;
|
|
|
|
pObj->m_FromY = (int) m_To.y;
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pObj->m_FromX = (int) m_Pos.x;
|
|
|
|
pObj->m_FromY = (int) m_Pos.y;
|
2010-08-11 10:33:37 +00:00
|
|
|
}
|
|
|
|
pObj->m_StartTick = Server()->Tick();
|
|
|
|
}
|