101
101
102
102
PRE_HOOK )
103
103
104
- Add( "PlayerSwitchWeapon", addonName, ( _, __, entity ) ->
105
- if entity.DLightController
106
- return
104
+ Add( "PlayerSwitchWeapon", addonName, ( _, old, new ) ->
105
+ dlight = old.__beam_dlight
106
+ if dlight and IsValid( dlight )
107
+ dlight\Remove!
107
108
108
- dlight = entity .__dlight
109
+ dlight = old .__dlight
109
110
if dlight and IsValid( dlight )
110
111
dlight\Remove!
111
112
112
- bdlight = entity.__beam_dlight
113
- if bdlight and IsValid( dlight )
114
- bdlight \Remove!
113
+ dlight = new.__dlight
114
+ if dlight and IsValid( dlight )
115
+ dlight \Remove!
115
116
116
- unless dlight_controllers_entities\GetBool! and IsValid( entity )
117
+ unless dlight_controllers_entities\GetBool! and IsValid( new )
117
118
return
118
119
119
- className = GetClass( entity )
120
+ className = GetClass( new )
120
121
if blacklist[ className ]
121
122
return
122
123
130
131
131
132
dlight\SetEnabled( true )
132
133
133
- if func( entity , dlight ) == false
134
+ if func( new , dlight ) == false
134
135
dlight\Remove!
135
136
return
136
137
137
- entity .__dlight = dlight
138
+ new .__dlight = dlight
138
139
dlight\Spawn!
139
140
return
140
141
@@ -155,13 +156,12 @@ Add( "EntityRemoved", addonName, ( entity, fullUpdate ) ->
155
156
156
157
entity.m_eFireDLight = nil
157
158
158
- if entity\IsPlayer!
159
- dlight = entity.__beam_dlight
160
- if dlight
161
- if IsValid( dlight )
162
- dlight\Remove!
159
+ dlight = entity.__beam_dlight
160
+ if dlight
161
+ if IsValid( dlight )
162
+ dlight\Remove!
163
163
164
- entity.__beam_dlight = nil
164
+ entity.__beam_dlight = nil
165
165
166
166
PRE_HOOK )
167
167
483
483
484
484
hook.Add "Think", addonName, ->
485
485
for _, entity in Iterator!
486
- if IsValid( entity ) and entity\IsOnFire!
486
+ unless IsValid( entity )
487
+ return
488
+
489
+ if entity\IsOnFire!
487
490
dlight = entity.m_eFireDLight
488
491
if dlight and IsValid( dlight )
489
492
continue
0 commit comments