-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCStaticEffect.cpp
111 lines (78 loc) · 1.83 KB
/
CStaticEffect.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
108
109
110
// CStaticEffect.cpp
//
// CStaticEffect class
#include "PreComp.h"
static CObjectClass<CStaticEffect>g_Class(OBJID_CSTATICEFFECT, NULL);
CStaticEffect::CStaticEffect (void) : CSpaceObject(&g_Class), m_pPainter(NULL)
// CStaticEffect constructor
{
}
CStaticEffect::~CStaticEffect (void)
// CStaticEffect destructor
{
if (m_pPainter)
m_pPainter->Delete();
}
ALERROR CStaticEffect::Create (CEffectCreator *pType,
CSystem *pSystem,
const CVector &vPos,
CStaticEffect **retpEffect)
// Create
//
// Creates a new effects object
{
ALERROR error;
CStaticEffect *pEffect;
pEffect = new CStaticEffect;
if (pEffect == NULL)
return ERR_MEMORY;
pEffect->Place(vPos);
ASSERT(pType);
pEffect->m_pPainter = pType->CreatePainter(CCreatePainterCtx());
// Set the size of the object
if (pEffect->m_pPainter)
pEffect->SetBounds(pEffect->m_pPainter);
// Add to system
if (error = pEffect->AddToSystem(pSystem))
{
delete pEffect;
return error;
}
// Done
if (retpEffect)
*retpEffect = pEffect;
return NOERROR;
}
void CStaticEffect::OnPaint (CG32bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)
// OnPaint
//
// Paints the effect
{
CViewportPaintCtxSmartSave Save(Ctx);
Ctx.iTick = 0;
Ctx.iVariant = GetDestiny();
Ctx.iRotation = 0;
Ctx.iDestiny = GetDestiny();
m_pPainter->Paint(Dest, x, y, Ctx);
}
void CStaticEffect::OnReadFromStream (SLoadCtx &Ctx)
// OnReadFromStream
//
// Read object data from a stream
//
// DWORD IEffectPainter
{
#ifdef DEBUG_LOAD
::OutputDebugString("CStaticEffect::OnReadFromStream\n");
#endif
m_pPainter = CEffectCreator::CreatePainterFromStream(Ctx);
}
void CStaticEffect::OnWriteToStream (IWriteStream *pStream)
// OnWriteToStream
//
// Write the object's data to stream
//
// DWORD IEffectPainter
{
CEffectCreator::WritePainterToStream(pStream, m_pPainter);
}