File size: 1,204 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
local UIL = UIL

DefineClass.XParticle = {
	__parents = { "XControl" },

	properties = {
		{ category = "Particle", id = "ParticleSystem", editor = "text", default = "", help="Particle system asset", },
		{ category = "Particle", id = "ParticleAngle",  editor = "number", default = 0, min = 0, max = 360*60 - 1, slider = true, scale = "deg", invalidate = true, },
		{ category = "Particle", id = "ParticlePosition", editor = "point", default = point(0, 0, 0), help = "Position of the particle system", },
	},
	
	particle_id = -1,
}

function XParticle:SetParticleSystem(particle)
	local old_particle_system = self.ParticleSystem
	if old_particle_system == (particle or "") then return end
	
	if self.particle_id >= 0 then
		UIL.DeleteUIParticles(particle_id)
	end
	
	if particle and particle ~= "" then
		self.particle_id = UIL.PlaceUIParticles(particle)
	end

	self.ParticleSystem = particle or nil
end

function XParticle:Done(parent, context)
	if self.particle_id >= 0 then
		UIL.DeleteUIParticles(self.particle_id)
	end
end

function XParticle:DrawContent()
	if DataLoaded then
		UIL.DrawParticles(self.particle_id, self.ParticlePosition, self.scale:x(), self.scale:y(), self.ParticleAngle)
	end
end