-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rd_map_texture entity, so we can finally say WHA-? No! QADIM!!!
- Loading branch information
Showing
6 changed files
with
245 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#include "cbase.h" | ||
#include "rd_map_texture_shared.h" | ||
#ifdef CLIENT_DLL | ||
#include <vgui_controls/Controls.h> | ||
#include <vgui/ISurface.h> | ||
#endif | ||
|
||
// memdbgon must be the last include file in a .cpp file!!! | ||
#include "tier0/memdbgon.h" | ||
|
||
|
||
#ifdef CLIENT_DLL | ||
IMPLEMENT_AUTO_LIST( IRDMapTexture ); | ||
#else | ||
LINK_ENTITY_TO_CLASS( rd_map_texture, CRD_Map_Texture ); | ||
|
||
BEGIN_DATADESC( CRD_Map_Texture ) | ||
DEFINE_KEYFIELD( m_szMaterialName, FIELD_STRING, "material" ), | ||
DEFINE_KEYFIELD( m_MapMins, FIELD_VECTOR, "mins" ), | ||
DEFINE_KEYFIELD( m_MapMaxs, FIELD_VECTOR, "maxs" ), | ||
DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ), | ||
DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), | ||
DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), | ||
DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), | ||
END_DATADESC(); | ||
|
||
extern void SendProxy_String_tToString( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID ); | ||
#endif | ||
|
||
IMPLEMENT_NETWORKCLASS_ALIASED( RD_Map_Texture, DT_RD_Map_Texture ); | ||
|
||
BEGIN_NETWORK_TABLE( CRD_Map_Texture, DT_RD_Map_Texture ) | ||
#ifdef CLIENT_DLL | ||
RecvPropString( RECVINFO( m_szMaterialName ) ), | ||
RecvPropVectorXY( RECVINFO( m_MapMins ) ), | ||
RecvPropVectorXY( RECVINFO( m_MapMaxs ) ), | ||
RecvPropBool( RECVINFO( m_bDisabled ) ), | ||
#else | ||
SendPropString( SENDINFO( m_szMaterialName ), 0, SendProxy_String_tToString ), | ||
SendPropVectorXY( SENDINFO( m_MapMins ) ), | ||
SendPropVectorXY( SENDINFO( m_MapMaxs ) ), | ||
SendPropBool( SENDINFO( m_bDisabled ) ), | ||
#endif | ||
END_NETWORK_TABLE(); | ||
|
||
CRD_Map_Texture::CRD_Map_Texture() | ||
{ | ||
#ifdef CLIENT_DLL | ||
m_szMaterialName.GetForModify()[0] = '\0'; | ||
|
||
m_hVGuiTexture = NULL; | ||
#else | ||
m_szMaterialName.Set( NULL_STRING ); | ||
#endif | ||
|
||
m_MapMins.Init(); | ||
m_MapMaxs.Init(); | ||
m_bDisabled = false; | ||
} | ||
|
||
CRD_Map_Texture::~CRD_Map_Texture() | ||
{ | ||
#ifdef CLIENT_DLL | ||
if ( m_hVGuiTexture && vgui::surface() ) | ||
{ | ||
vgui::surface()->DestroyTextureID( m_hVGuiTexture ); | ||
m_hVGuiTexture = NULL; | ||
} | ||
#endif | ||
} | ||
|
||
void CRD_Map_Texture::Precache() | ||
{ | ||
BaseClass::Precache(); | ||
|
||
if ( const char *szMaterialName = STRING( m_szMaterialName.Get() ) ) | ||
{ | ||
PrecacheMaterial( szMaterialName ); | ||
} | ||
} | ||
|
||
Vector CRD_Map_Texture::GetTopLeftCorner() const | ||
{ | ||
Vector pos; | ||
EntityToWorldSpace( Vector{ m_MapMins.GetX(), m_MapMins.GetY(), 0.0f }, &pos ); | ||
return pos; | ||
} | ||
Vector CRD_Map_Texture::GetTopRightCorner() const | ||
{ | ||
Vector pos; | ||
EntityToWorldSpace( Vector{ m_MapMaxs.GetX(), m_MapMins.GetY(), 0.0f }, &pos ); | ||
return pos; | ||
} | ||
Vector CRD_Map_Texture::GetBottomLeftCorner() const | ||
{ | ||
Vector pos; | ||
EntityToWorldSpace( Vector{ m_MapMins.GetX(), m_MapMaxs.GetY(), 0.0f }, &pos ); | ||
return pos; | ||
} | ||
Vector CRD_Map_Texture::GetBottomRightCorner() const | ||
{ | ||
Vector pos; | ||
EntityToWorldSpace( Vector{ m_MapMaxs.GetX(), m_MapMaxs.GetY(), 0.0f }, &pos ); | ||
return pos; | ||
} | ||
|
||
#ifndef CLIENT_DLL | ||
void CRD_Map_Texture::Spawn() | ||
{ | ||
Precache(); | ||
|
||
if ( m_szMaterialName.Get() == NULL_STRING ) | ||
{ | ||
Warning( "rd_map_texture entity (%d:%s) @ %f %f %f has no material assigned. Deleting.\n", GetHammerID(), GetDebugName(), VectorExpand( GetAbsOrigin() ) ); | ||
UTIL_Remove( this ); | ||
return; | ||
} | ||
|
||
BaseClass::Spawn(); | ||
} | ||
|
||
int CRD_Map_Texture::UpdateTransmitState() | ||
{ | ||
return SetTransmitState( FL_EDICT_ALWAYS ); | ||
} | ||
|
||
void CRD_Map_Texture::InputEnable( inputdata_t &inputdata ) | ||
{ | ||
m_bDisabled = false; | ||
} | ||
|
||
void CRD_Map_Texture::InputDisable( inputdata_t &inputdata ) | ||
{ | ||
m_bDisabled = true; | ||
} | ||
|
||
void CRD_Map_Texture::InputToggle( inputdata_t &inputdata ) | ||
{ | ||
m_bDisabled = !m_bDisabled; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#ifdef CLIENT_DLL | ||
#define CRD_Map_Texture C_RD_Map_Texture | ||
|
||
DECLARE_AUTO_LIST( IRDMapTextures ); | ||
#endif | ||
|
||
class CRD_Map_Texture : public CBaseEntity | ||
#ifdef CLIENT_DLL | ||
, public IRDMapTextures | ||
#endif | ||
{ | ||
DECLARE_CLASS( CRD_Map_Texture, CBaseEntity ); | ||
public: | ||
DECLARE_NETWORKCLASS(); | ||
|
||
CRD_Map_Texture(); | ||
virtual ~CRD_Map_Texture(); | ||
|
||
void Precache() override; | ||
|
||
Vector GetTopLeftCorner() const; | ||
Vector GetTopRightCorner() const; | ||
Vector GetBottomLeftCorner() const; | ||
Vector GetBottomRightCorner() const; | ||
|
||
#ifndef CLIENT_DLL | ||
DECLARE_DATADESC(); | ||
|
||
void Spawn() override; | ||
int UpdateTransmitState() override; | ||
|
||
CNetworkVar( string_t, m_szMaterialName ); | ||
|
||
void InputEnable( inputdata_t &inputdata ); | ||
void InputDisable( inputdata_t &inputdata ); | ||
void InputToggle( inputdata_t &inputdata ); | ||
#else | ||
IMPLEMENT_AUTO_LIST_GET(); | ||
|
||
CNetworkString( m_szMaterialName, 255 ); | ||
vgui::HTexture m_hVGuiTexture; | ||
#endif | ||
|
||
CNetworkVector( m_MapMins ); | ||
CNetworkVector( m_MapMaxs ); | ||
CNetworkVar( bool, m_bDisabled ); | ||
}; |