-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.lua
More file actions
54 lines (46 loc) · 1.56 KB
/
Vehicle.lua
File metadata and controls
54 lines (46 loc) · 1.56 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
require 'Properties'
require 'Effector'
require 'Materials'
Vehicle = {}
local function doEffect(vehicle)
if Effector:doEffect(vehicle) then
vehicle.removeThis = true
end
end
local function stickTo(vehicle, material)
vehicle.sticking = true
if vehicle.VehicleAttribute == "Spider" then
vehicle.crawling = true
local angle = betweenangle(vehicle.Vel.x, vehicle.Vel.y, vehicle.Ov.x, vehicle.Ov.y)
vehicle.FacingRight = angle > 0
end
vehicle.Vel = {x=0,y=0}
end
local function doStick(vehicle)
if vehicle.collisions then
for _,c in ipairs(vehicle.collisions) do
local material = Materials:GetMaterial(c.r, c.g, c.b, c.a)
-- TODO: stickiness and VehicleMaxPower is pretty tenuous... find something better here? Better than VehicleTime anyway...
if material and material.crawlresist <= vehicle.VehicleMass then
stickTo(vehicle, material)
break
end
end
end
end
function Vehicle:collide(vehicle,terrain)
if vehicle.Special == "Cascade" then
local emissions = vehicle.SpecialPower * Properties.CascadeNumber
Tool:makeChildren(vehicle, emissions, terrain, Properties.CascadedToolThingSize, Properties.CascadeSpread)
doEffect(vehicle)
return
end
if (not vehicle.isProjector) and
(terrain and (vehicle.VehicleAttribute == "Sticky" or
vehicle.VehicleAttribute == "Spider") ) then
doStick(vehicle)
elseif vehicle.isProjector or
(vehicle.VehicleAttribute ~= "Timed") then
doEffect(vehicle)
end
end