-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEffector.lua
More file actions
78 lines (68 loc) · 2.11 KB
/
Effector.lua
File metadata and controls
78 lines (68 loc) · 2.11 KB
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
require 'Properties'
require 'Probe'
require 'Annihilator'
require 'Converter'
require 'Dilator'
require 'Fizzle'
require 'Harvester'
require 'Extruder'
require 'Level'
Effector = {}
local function tag(effector)
if effector.Operation == "Probe" then
Probe:tag(effector)
elseif effector.Operation == "Annihilator" then
Annihilator:tag(effector)
elseif effector.Operation == "Harvester" then
Harvester:tag(effector)
elseif effector.Operation == "Converter" then
Converter:tag(effector)
elseif effector.Operation == "Dilator" then
Dilator:tag(effector)
elseif effector.Operation == "Extruder" then
Extruder:tag(effector)
end
end
local function sphereAround(center, effector)
local sphere = getCircleCoords(center, effector.EffectorSize, true)
return {center,unpack(sphere)}
end
local function blastAround(center, effector)
--TODO blast
return {center}
end
function Effector:doEffect(effector)
local effective = false
if effector.collisions then
if effector.Effector == "Precision" then
local x,y = effector.collisions[1].x, effector.collisions[1].y
local r,g,b,a = Level:getPixel(x,y)
effector.collisions = {{x=x,y=y,r=r,g=g,b=b,a=a}}
else
for _,c in ipairs(effector.collisions) do
local material = Materials:GetMaterial(c.r, c.g, c.b, c.a)
if material and material.triggerresist <= effector.OperationStrength then
effector.collisions = {c}
break
end
end
end
else
local x,y = effector.Pos.x,effector.Pos.y
local r,g,b,a = Level:getPixel(x,y)
effector.collisions = {{x=x,y=y,r=r,g=g,b=b,a=a}}
end
if #(effector.collisions) == 1 then
effective = true
end
if effector.Effector == "Precision" then
tag(effector)
elseif effector.Effector == "Sphere" then
effector.collisions = sphereAround(effector.collisions[1],effector)
tag(effector)
elseif effector.Effector == "Blast" then
effector.collisions = blastAround(effector.collisions[1],effector)
tag(effector)
end
return effective
end