|
1 | | -EFFECT.Mat = Material( "effects/select_ring" ) |
2 | | - |
3 | | -/*--------------------------------------------------------- |
4 | | - Initializes the effect. The data is a table of data |
5 | | - which was passed from the server. |
6 | | ----------------------------------------------------------*/ |
7 | | -function EFFECT:Init( data ) |
8 | | - |
9 | | - local TargetEntity = data:GetEntity() |
10 | | - |
11 | | - if ( not TargetEntity or not TargetEntity:IsValid() ) then return end |
12 | | - |
13 | | - //local vOffset = TargetEntity:GetPos() |
14 | | - |
15 | | - local Low, High = TargetEntity:WorldSpaceAABB() |
16 | | - local Center = data:GetOrigin() //High - (( High - Low ) * 0.5) |
17 | | - |
18 | | - local NumParticles = TargetEntity:BoundingRadius() |
19 | | - NumParticles = NumParticles * 2 |
20 | | - |
21 | | - NumParticles = math.Clamp( NumParticles, 10, 500 ) |
22 | | - |
23 | | - local emitter = ParticleEmitter( Center ) |
24 | | - |
25 | | - for i=0, NumParticles do |
26 | | - |
27 | | - local vPos = Vector( math.Rand(Low.x,High.x), math.Rand(Low.y,High.y), math.Rand(Low.z,High.z) ) |
28 | | - local vVel = (vPos - Center) * 6 |
29 | | - local particle = emitter:Add( "effects/spark", Center ) |
30 | | - if (particle) then |
31 | | - particle:SetVelocity( vVel ) |
32 | | - particle:SetLifeTime( 0 ) |
33 | | - particle:SetDieTime( math.Rand( 0.1, 0.4 ) ) |
34 | | - particle:SetStartAlpha( 0 ) |
35 | | - particle:SetEndAlpha( math.Rand( 200, 255 ) ) |
36 | | - particle:SetStartSize( 0 ) |
37 | | - particle:SetEndSize( 20 ) |
38 | | - particle:SetRoll( math.Rand(0, 360) ) |
39 | | - particle:SetRollDelta( 0 ) |
40 | | - end |
41 | | - |
| 1 | +function EFFECT:Init(data) |
| 2 | + local entity = data:GetEntity() |
| 3 | + if not entity:IsValid() then return end |
| 4 | + |
| 5 | + local low, high = entity:WorldSpaceAABB() |
| 6 | + local origin = data:GetOrigin() |
| 7 | + |
| 8 | + local emitter = ParticleEmitter(origin) |
| 9 | + |
| 10 | + for i = 0, math.Clamp(entity:BoundingRadius() * 2, 10, 500) do |
| 11 | + local particle = emitter:Add("effects/spark", origin) |
| 12 | + |
| 13 | + if particle then |
| 14 | + local velocity = Vector(math.Rand(low.x, high.x), math.Rand(low.y, high.y), math.Rand(low.z, high.z)) |
| 15 | + velocity:Sub(origin) |
| 16 | + velocity:Mul(6) |
| 17 | + |
| 18 | + particle:SetVelocity(velocity) |
| 19 | + particle:SetLifeTime(0) |
| 20 | + particle:SetDieTime(math.Rand(0.1, 0.4)) |
| 21 | + particle:SetStartAlpha(0) |
| 22 | + particle:SetEndAlpha(math.Rand(200, 255)) |
| 23 | + particle:SetStartSize(0) |
| 24 | + particle:SetEndSize(20) |
| 25 | + particle:SetRoll(math.Rand(0, 360)) |
| 26 | + particle:SetRollDelta(0) |
42 | 27 | end |
| 28 | + end |
43 | 29 |
|
44 | 30 | emitter:Finish() |
45 | | - |
46 | 31 | end |
47 | 32 |
|
48 | | - |
49 | | -/*--------------------------------------------------------- |
50 | | - THINK |
51 | | ----------------------------------------------------------*/ |
52 | 33 | function EFFECT:Think() |
53 | 34 | return false |
54 | 35 | end |
55 | 36 |
|
56 | | -/*--------------------------------------------------------- |
57 | | - Draw the effect |
58 | | ----------------------------------------------------------*/ |
59 | 37 | function EFFECT:Render() |
60 | 38 | end |
0 commit comments