Skip to content

Commit dac8ca2

Browse files
committed
Reworked effects_c module
1 parent 69438a5 commit dac8ca2

File tree

5 files changed

+140
-180
lines changed

5 files changed

+140
-180
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,9 @@ Set(SOURCEPYTHON_VECMATH_MODULE_SOURCES
277277
# Effects module
278278
# ------------------------------------------------------------------
279279
Set(SOURCEPYTHON_EFFECTS_MODULE_HEADERS
280-
core/modules/effects/effects_wrap.h
281280
)
282281

283282
Set(SOURCEPYTHON_EFFECTS_MODULE_SOURCES
284-
core/modules/effects/effects_wrap.cpp
285283
core/modules/effects/effects_wrap_python.cpp
286284
)
287285

src/core/modules/effects/effects_wrap.cpp

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/core/modules/effects/effects_wrap.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@
3030
//-----------------------------------------------------------------------------
3131
// Includes
3232
//-----------------------------------------------------------------------------
33-
// These includes are really important. Be careful if you try to change the
34-
// order or remove an include!
35-
#include <stddef.h>
36-
#include "wchartypes.h"
37-
#include "string_t.h"
38-
#include "../vecmath/vecmath_wrap.h"
39-
#include "shake.h"
40-
#include "IEffects.h"
33+
4134

4235

4336
//-----------------------------------------------------------------------------

src/core/modules/effects/effects_wrap_python.cpp

Lines changed: 107 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,101 +24,160 @@
2424
* Development Team grants this exception to all derivative works.
2525
*/
2626

27-
2827
//-----------------------------------------------------------------------------
2928
// Includes
3029
//-----------------------------------------------------------------------------
30+
// These includes are really important. Be careful if you try to change the
31+
// order or remove an include!
32+
#include <stddef.h>
33+
#include "wchartypes.h"
34+
#include "string_t.h"
35+
#include "../vecmath/vecmath_wrap.h"
36+
#include "shake.h"
37+
#include "IEffects.h"
38+
#include "utility/wrap_macros.h"
3139
#include "modules/export_main.h"
32-
#include "effects_wrap.h"
3340

34-
void export_effects();
41+
42+
//-----------------------------------------------------------------------------
43+
// Externals
44+
//-----------------------------------------------------------------------------
45+
extern IEffects* effects;
46+
47+
// This is required to fix a linker error
48+
IPredictionSystem* IPredictionSystem::g_pPredictionSystems = NULL;
3549

3650
//-----------------------------------------------------------------------------
3751
// Exposes the effects_c module.
3852
//-----------------------------------------------------------------------------
53+
void export_effects();
54+
3955
DECLARE_SP_MODULE(effects_c)
4056
{
4157
export_effects();
4258
}
4359

44-
DECLARE_CLASS_METHOD_OVERLOAD(CEffects, sparks, 1, 4);
45-
DECLARE_CLASS_METHOD_OVERLOAD(CEffects, energy_splash, 2, 3);
60+
//-----------------------------------------------------------------------------
61+
// Expose effects
62+
//-----------------------------------------------------------------------------
63+
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(sparks_overload, Sparks, 1, 4)
64+
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(energy_splash_overload, EnergySplash, 2, 3)
4665

4766
void export_effects()
4867
{
49-
BOOST_ABSTRACT_CLASS(CEffects)
68+
// TODO: Rename?
69+
class_<IPredictionSystem>("IPredictionSystem")
70+
.def("get_next",
71+
&IPredictionSystem::GetNext,
72+
"Returns the next prediction system.",
73+
reference_existing_object_policy()
74+
)
75+
76+
.def("set_suppress_event",
77+
&IPredictionSystem::SetSuppressEvent
78+
)
79+
80+
.def("set_suppress_host",
81+
&IPredictionSystem::SetSuppressHost
82+
)
5083

51-
CLASS_METHOD(CEffects,
52-
beam,
84+
/*
85+
TODO: CBaseEntity
86+
.def("get_suppress_host",
87+
&IPredictionSystem::GetSuppressHost,
88+
reference_existing_object_policy()
89+
)
90+
*/
91+
92+
.def("can_predict",
93+
&IPredictionSystem::CanPredict
94+
)
95+
96+
.def_readwrite("prediction_systems",
97+
&IPredictionSystem::g_pPredictionSystems
98+
)
99+
100+
.def("suppress_events",
101+
&IPredictionSystem::SuppressEvents
102+
)
103+
.staticmethod("suppress_events")
104+
105+
.def("suppress_host_events",
106+
&IPredictionSystem::SuppressHostEvents
107+
)
108+
.staticmethod("suppress_host_events")
109+
;
110+
111+
// TODO: Rename?
112+
class_<IEffects, bases<IPredictionSystem>, boost::noncopyable>("CEffects", no_init)
113+
.def("beam",
114+
&IEffects::Beam,
53115
"Creates a beam particle effect.",
54-
args("vecStart", "vecEnd", "iModelIndex", "iHaloIndex", "frameStart", "frameRate", "fLife", "width", "endWidth", "fadeLength", "noise", "red", "green", "blue", "brightness", "speed")
116+
args("start_vec", "end_vec", "model_index", "halo_index", "start_frame", "frame_rate", "life", "width", "end_width", "fade_length", "noise", "red", "green", "blue", "brightness", "speed")
55117
)
56118

57-
CLASS_METHOD(CEffects,
58-
smoke,
119+
.def("smoke",
120+
&IEffects::Smoke,
59121
"Creates a smoke effect.",
60-
args("vecOrigin", "iModelIndex", "fScale", "fFrameRate")
122+
args("origin", "model_index", "scale", "frame_rate")
61123
)
62124

63-
CLASS_METHOD_OVERLOAD(CEffects,
64-
sparks,
65-
"Creates a sparks effect.",
66-
args("vecOrigin", "iMagnitude", "iTrailLength", "vecDirection")
125+
.def("sparks",
126+
&IEffects::Sparks,
127+
sparks_overload(
128+
"Creates a sparks effect.",
129+
args("origin", "magnitude", "trail_length", "direction")
130+
)
67131
)
68132

69-
CLASS_METHOD(CEffects,
70-
dust,
133+
.def("dust",
134+
&IEffects::Dust,
71135
"Creates a dust effect.",
72-
args("vecOrigin", "vecDirection", "fSize", "fSpeed")
136+
args("origin", "direction", "size", "speed")
73137
)
74138

75-
CLASS_METHOD(CEffects,
76-
muzzle_flash,
139+
.def("muzzle_flash",
140+
&IEffects::MuzzleFlash,
77141
"Creates a muzzle flash effect.",
78-
args("vecOrigin", "vecAngles", "fScale", "iType")
142+
args("origin", "angles", "scale", "type")
79143
)
80144

81-
CLASS_METHOD(CEffects,
82-
metal_sparks,
145+
.def("metal_sparks",
146+
&IEffects::MetalSparks,
83147
"Creates a muzzle flash effect.",
84-
args("vecOrigin", "vecDirection")
148+
args("origin", "direction")
85149
)
86150

87-
CLASS_METHOD_OVERLOAD(CEffects,
88-
energy_splash,
89-
"Creates a metal sparks effect.",
90-
args("vecOrigin", "vecDirection", "bExplosive")
151+
.def("energy_splash",
152+
&IEffects::EnergySplash,
153+
energy_splash_overload(
154+
"Creates a metal sparks effect.",
155+
args("origin", "direction", "explosive")
156+
)
91157
)
92158

93-
CLASS_METHOD(CEffects,
94-
ricochet,
159+
.def("ricochet",
160+
&IEffects::Ricochet,
95161
"Creates a ricochet effect.",
96-
args("vecOrigin", "vecDirection")
162+
args("origin", "direction")
97163
)
98164

99-
CLASS_METHOD(CEffects,
100-
ricochet,
101-
"Creates a ricochet.",
102-
args("vecOrigin", "vecDirection")
103-
)
104-
105-
CLASS_METHOD(CEffects,
106-
get_time,
165+
.def("get_time",
166+
&IEffects::Time,
107167
"Returns the current time."
108168
)
109169

110-
CLASS_METHOD(CEffects,
111-
is_server,
170+
.def("is_server",
171+
&IEffects::IsServer,
112172
"Returns True if this is a server."
113173
)
114174

115-
CLASS_METHOD(CEffects,
116-
suppress_effects_sounds,
175+
.def("suppress_effects_sounds",
176+
&IEffects::SuppressEffectsSounds,
117177
"Set to True to suppress effect sounds.",
118-
args("bSuppress")
178+
args("suppress")
119179
)
180+
;
120181

121-
BOOST_END_CLASS()
122-
123-
BOOST_FUNCTION(get_effects, reference_existing_object_policy());
182+
def("get_effects_interface", make_getter(&effects, reference_existing_object_policy()));
124183
}

0 commit comments

Comments
 (0)