Serious-Engine/Sources/EntitiesMP/Fireworks.cpp

231 lines
10 KiB
C++
Raw Normal View History

2016-03-11 14:57:17 +01:00
/*
* This file is generated by Entity Class Compiler, (c) CroTeam 1997-98
*/
#line 4 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
#include "StdH.h"
#define RAND_05 (FLOAT(rand())/RAND_MAX-0.5f)
#define LAUNCH_SPEED 32.0f
#include <EntitiesMP/Fireworks.h>
#include <EntitiesMP/Fireworks_tables.h>
void CFireworks::SetDefaultProperties(void) {
m_rRndRadius = 50.0f;
m_soFly.SetOwner(this);
m_soFly.Stop_internal();
m_soExplosion.SetOwner(this);
m_soExplosion.Stop_internal();
m_tmActivated = 0.0f;
m_strName = "";
m_tmLastAnimation = 0.0f;
CRationalEntity::SetDefaultProperties();
}
#line 38 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
void CFireworks::Read_t(CTStream * istr)
#line 39 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 40 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
CRationalEntity :: Read_t (istr );
#line 41 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . Read_t (* istr );
#line 42 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 44 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
void CFireworks::Write_t(CTStream * istr)
#line 45 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 46 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
CRationalEntity :: Write_t (istr );
#line 47 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . Write_t (* istr );
#line 48 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 50 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
void CFireworks::RenderParticles(void)
#line 51 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 52 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT tmNow = _pTimer -> CurrentTick ();
#line 53 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
if(tmNow > m_tmLastAnimation )
#line 54 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 55 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fRatio = CalculateRatio (m_tmActivated - tmNow , 0.0f , 6.0f , 1 , 0);
#line 56 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fGPower = (Min (fRatio , 0.5f) - 0.5f) * 2.0f * 10.0f;
#line 57 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . em_vG = FLOAT3D (0 , fGPower , 0);
#line 58 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . AnimateParticles ();
#line 59 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_tmLastAnimation = tmNow ;
#line 61 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
for(INDEX i = 0;i < m_emEmiter . em_aepParticles . Count ();i ++)
#line 62 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 63 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
CEmittedParticle & ep = m_emEmiter . em_aepParticles [ i ];
#line 64 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
if(ep . ep_tmEmitted < 0){continue ;};
#line 65 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fLiving = tmNow - ep . ep_tmEmitted ;
#line 66 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fSpeed = 0.0f;
#line 68 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
if(fLiving >= 6.0f)
#line 69 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 70 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
fSpeed = 0.0f;
#line 71 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 72 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
else
#line 73 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 76 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
fSpeed = (1.77f * pow (0.421f , fLiving )) * LAUNCH_SPEED ;
#line 81 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 82 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT3D vNormalized = ep . ep_vSpeed ;
#line 83 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
vNormalized . Normalize ();
#line 84 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
ep . ep_vSpeed = vNormalized * (4.0f + fSpeed );
#line 85 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 86 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 87 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . RenderParticles ();
#line 88 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
BOOL CFireworks::
#line 91 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SpawnFireworks(const CEntityEvent &__eeInput) {
#undef STATE_CURRENT
#define STATE_CURRENT STATE_CFireworks_SpawnFireworks
ASSERTMSG(__eeInput.ee_slEvent==EVENTCODE_EVoid, "CFireworks::SpawnFireworks expects 'EVoid' as input!"); const EVoid &e = (const EVoid &)__eeInput;
#line 93 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
PlaySound (m_soFly , SOUND_FLY , 0);
#line 94 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetTimerAfter(GetSoundLength (SOUND_FLY ));
Jump(STATE_CURRENT, 0x02680001, FALSE, EBegin());return TRUE;}BOOL CFireworks::H0x02680001_SpawnFireworks_01(const CEntityEvent &__eeInput) {
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680001
switch(__eeInput.ee_slEvent) {case EVENTCODE_EBegin: return TRUE;case EVENTCODE_ETimer: Jump(STATE_CURRENT,0x02680002, FALSE, EInternal()); return TRUE;default: return FALSE; }}BOOL CFireworks::H0x02680002_SpawnFireworks_02(const CEntityEvent &__eeInput){
ASSERT(__eeInput.ee_slEvent==EVENTCODE_EInternal);
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680002
;
#line 95 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
PlaySound (m_soExplosion , SOUND_EXPLODE , 0);
#line 98 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT3D vRndPos = FLOAT3D (RAND_05 , RAND_05 , RAND_05 ) * m_rRndRadius ;
#line 99 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT3D vPos = GetPlacement () . pl_PositionVector + vRndPos ;
#line 101 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . em_vG = FLOAT3D (0 , 0 , 0);
#line 102 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . em_iGlobal = FRnd () * 16;
#line 104 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
UBYTE ubRndH = UBYTE (FRnd () * 255);
#line 105 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
UBYTE ubRndS = UBYTE (255);
#line 106 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
UBYTE ubRndV = UBYTE (255);
#line 107 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . em_colGlobal = C_WHITE | CT_OPAQUE ;
#line 109 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT tmNow = _pTimer -> CurrentTick ();
#line 110 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_tmActivated = tmNow ;
#line 111 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
INDEX ctSparks = 128;
#line 112 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
for(INDEX iSpark = 0;iSpark < ctSparks ;iSpark ++)
#line 113 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{
#line 114 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT tmBirth = tmNow + (iSpark + RAND_05 ) * _pTimer -> TickQuantum / ctSparks * 2.0f;
#line 115 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fLife = 4.0f + RAND_05 * 2.0f;
#line 116 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fStretch = (1.0f + RAND_05 * 0.25f) * 2.5f;
#line 117 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT3D vSpeed = FLOAT3D (RAND_05 , RAND_05 , RAND_05 );
#line 118 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
vSpeed = vSpeed . Normalize () * LAUNCH_SPEED ;
#line 119 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
FLOAT fRotSpeed = RAND_05 * 360.0f;
#line 127 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
COLOR col = C_WHITE | CT_OPAQUE ;
#line 128 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . AddParticle (vPos , vSpeed , RAND_05 * 360.0f , fRotSpeed , tmBirth , fLife , fStretch , col );
#line 129 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}
#line 130 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
Return(STATE_CURRENT,EReturn ());
#line 130 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
return TRUE; ASSERT(FALSE); return TRUE;};BOOL CFireworks::
#line 133 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
Main(const CEntityEvent &__eeInput) {
#undef STATE_CURRENT
#define STATE_CURRENT STATE_CFireworks_Main
ASSERTMSG(__eeInput.ee_slEvent==EVENTCODE_EVoid, "CFireworks::Main expects 'EVoid' as input!"); const EVoid &e = (const EVoid &)__eeInput;
#line 136 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
InitAsEditorModel ();
#line 137 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetPhysicsFlags (EPF_MODEL_IMMATERIAL );
#line 138 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetCollisionFlags (ECF_IMMATERIAL );
#line 141 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetModel (MODEL_MARKER );
#line 142 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetModelMainTexture (TEXTURE_MARKER );
#line 143 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
GetModelObject () -> StretchModel (FLOAT3D (4.0f , 4.0f , 4.0f));
#line 145 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetTimerAfter(_pTimer -> TickQuantum );
Jump(STATE_CURRENT, 0x02680003, FALSE, EBegin());return TRUE;}BOOL CFireworks::H0x02680003_Main_01(const CEntityEvent &__eeInput) {
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680003
switch(__eeInput.ee_slEvent) {case EVENTCODE_EBegin: return TRUE;case EVENTCODE_ETimer: Jump(STATE_CURRENT,0x02680004, FALSE, EInternal()); return TRUE;default: return FALSE; }}BOOL CFireworks::H0x02680004_Main_02(const CEntityEvent &__eeInput){
ASSERT(__eeInput.ee_slEvent==EVENTCODE_EInternal);
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680004
;
#line 147 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . Initialize (this );
#line 148 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
m_emEmiter . em_etType = ET_FIREWORKS01 ;
#line 151 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
SetTimerAt(THINKTIME_NEVER);
Jump(STATE_CURRENT, 0x02680005, FALSE, EBegin());return TRUE;}BOOL CFireworks::H0x02680005_Main_03(const CEntityEvent &__eeInput) {
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680005
switch(__eeInput.ee_slEvent){case(EVENTCODE_EBegin):{const EBegin&e= (EBegin&)__eeInput;
return TRUE;}ASSERT(FALSE);break;case(EVENTCODE_ETrigger):
#line 154 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
{const ETrigger&e= (ETrigger&)__eeInput;
#line 155 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
Call(STATE_CURRENT, STATE_CFireworks_SpawnFireworks, TRUE, EVoid());return TRUE;
#line 156 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}ASSERT(FALSE);break;default:{return TRUE;}ASSERT(FALSE);break;
#line 158 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
}return TRUE;}BOOL CFireworks::H0x02680006_Main_04(const CEntityEvent &__eeInput){
ASSERT(__eeInput.ee_slEvent==EVENTCODE_EInternal);
#undef STATE_CURRENT
#define STATE_CURRENT 0x02680006
#line 160 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
Return(STATE_CURRENT,EVoid());
#line 160 "D:/SE1_GPL/Sources/EntitiesMP/Fireworks.es"
return TRUE; ASSERT(FALSE); return TRUE;};