Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
HighPressureWasherLance
DescriptionClass for high pressure washer lanceParent
HandToolFunctions
- cleanVehicle
- delete
- getIsActiveForInput
- isBeingUsed
- new
- onDeactivate
- postLoad
- setIsWashing
- update
- washRaycastCallback
cleanVehicle
DescriptionClean vehicleDefinition
cleanVehicle(integer node, float dt)Arguments
integer | node | node id |
float | dt | time since last call in ms |
137 | function HighPressureWasherLance:cleanVehicle(node, dt) |
138 | local x, y, z = getWorldTranslation(node) |
139 | local dx, dy, dz = localDirectionToWorld(node, 0, 0, -1) |
140 | local lastFoundVehicle = self.foundVehicle |
141 | raycastAll(x, y, z, dx, dy, dz, "washRaycastCallback", self.washDistance, self, 32+64+128+256+4096+8194) |
142 | |
143 | if self.foundVehicle ~= nil and lastFoundVehicle ~= self.foundVehicle then |
144 | self.foundVehicle:addDirtAmount(-self.washMultiplier * dt / self.foundVehicle:getWashDuration()) |
145 | end |
146 | end |
delete
DescriptionDeletingDefinition
delete()Code
67 | function HighPressureWasherLance:delete() |
68 | g_effectManager:deleteEffects(self.effects) |
69 | g_soundManager:deleteSample(self.washingSample) |
70 | HighPressureWasherLance:superClass().delete(self) |
71 | end |
getIsActiveForInput
DescriptionGet is active for inputDefinition
getIsActiveForInput()Return Values
boolean | isActiveForInput | is active for input |
186 | function HighPressureWasherLance:getIsActiveForInput() |
187 | if self.player == g_currentMission.player and not g_gui:getIsGuiVisible() then |
188 | return true |
189 | end |
190 | return false |
191 | end |
isBeingUsed
DescriptionDefinitionisBeingUsed()Code
195 | function HighPressureWasherLance:isBeingUsed() |
196 | return self.doWashing |
197 | end |
new
DescriptionDefinitionnew()Code
29 | function HighPressureWasherLance.new(isServer, isClient, customMt) |
30 | local self = HighPressureWasherLance:superClass().new(isServer, isClient, customMt or HighPressureWasherLance_mt) |
31 | |
32 | self.foundVehicle = nil |
33 | self.doWashing = false |
34 | self.washDistance = 10.0 |
35 | self.washMultiplier = 1.0 |
36 | self.pricePerSecond = 10 |
37 | self.isHPWLance = true |
38 | |
39 | return self |
40 | end |
onDeactivate
DescriptionDefinitiononDeactivate()Code
75 | function HighPressureWasherLance:onDeactivate() |
76 | self:setIsWashing(false, true, true) |
77 | HighPressureWasherLance:superClass().onDeactivate(self) |
78 | end |
postLoad
DescriptionCalled after hand tool i3d file was loadedDefinition
postLoad(table xmlFile)Arguments
table | xmlFile | xmlFile |
45 | function HighPressureWasherLance:postLoad(xmlFile) |
46 | if not HighPressureWasherLance:superClass().postLoad(self, xmlFile) then |
47 | return false |
48 | end |
49 | |
50 | self.lanceNode = xmlFile:getValue("handTool.highPressureWasherLance.lance#node", nil, self.components, self.i3dMappings) |
51 | self.lanceRaycastNode = xmlFile:getValue("handTool.highPressureWasherLance.lance#raycastNode", nil, self.components, self.i3dMappings) |
52 | self.washDistance = xmlFile:getValue("handTool.highPressureWasherLance.lance#washDistance", 10) |
53 | self.washMultiplier = xmlFile:getValue("handTool.highPressureWasherLance.lance#washMultiplier", 1) |
54 | self.pricePerSecond = xmlFile:getValue("handTool.highPressureWasherLance.lance#pricePerMinute", 10) / 1000 |
55 | |
56 | self.effects = g_effectManager:loadEffect(xmlFile, "handTool.highPressureWasherLance.effects", self.components, self, self.i3dMappings) |
57 | g_effectManager:setFillType(self.effects, FillType.WATER) |
58 | |
59 | -- Sounds |
60 | self.washingSample = g_soundManager:loadSampleFromXML(xmlFile, "handTool.highPressureWasherLance.sounds", "washing", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self) |
61 | |
62 | return true |
63 | end |
setIsWashing
DescriptionSet is washingDefinition
setIsWashing(boolean doWashing, boolean force, boolean noEventSend)Arguments
boolean | doWashing | do washing |
boolean | force | force |
boolean | noEventSend | no event send |
114 | function HighPressureWasherLance:setIsWashing(doWashing, force, noEventSend) |
115 | HPWLanceStateEvent.sendEvent(self.player, doWashing, noEventSend) |
116 | if self.doWashing ~= doWashing then |
117 | if doWashing then |
118 | g_effectManager:setFillType(self.effects, FillType.WATER) |
119 | g_effectManager:startEffects(self.effects) |
120 | g_soundManager:playSample(self.washingSample) |
121 | else |
122 | if force then |
123 | g_effectManager:resetEffects(self.effects) |
124 | else |
125 | g_effectManager:stopEffects(self.effects) |
126 | end |
127 | g_soundManager:stopSample(self.washingSample) |
128 | end |
129 | self.doWashing = doWashing |
130 | end |
131 | end |
update
DescriptionDefinitionupdate()Code
82 | function HighPressureWasherLance:update(dt, allowInput) |
83 | HighPressureWasherLance:superClass().update(self, dt) |
84 | |
85 | if allowInput then |
86 | self:setIsWashing(self.activatePressed, false, false) |
87 | end |
88 | |
89 | if self.isServer then |
90 | if self.doWashing then |
91 | self.foundVehicle = nil |
92 | self:cleanVehicle(self.player.cameraNode, dt) |
93 | if self.lanceRaycastNode ~= nil then |
94 | self:cleanVehicle(self.lanceRaycastNode, dt) |
95 | end |
96 | if self.foundVehicle ~= nil then |
97 | local farmId = self.foundVehicle:getOwnerFarmId() |
98 | local price = self.pricePerSecond * (dt / 1000) |
99 | local stats = g_farmManager:getFarmById(self.player.farmId).stats |
100 | stats:updateStats("expenses", price) |
101 | g_currentMission:addMoney(-price, farmId, MoneyType.VEHICLE_RUNNING_COSTS) |
102 | end |
103 | end |
104 | end |
105 | self.activatePressed = false |
106 | self:raiseActive() |
107 | end |
washRaycastCallback
DescriptionWash raycast callbackDefinition
washRaycastCallback(integer hitActorId, float x, float y, float z, float distance, float nx, float ny, float nz, integer subShapeIndex, integer hitShapeId)Arguments
integer | hitActorId | id of hit object actor |
float | x | x raycast position |
float | y | y raycast position |
float | z | z raycast position |
float | distance | distance to raycast position |
float | nx | x component of hit surface normal (unused) |
float | ny | y component of hit surface normal (unused) |
float | nz | z component of hit surface normal (unused) |
integer | subShapeIndex | sub shape index of hit object |
integer | hitShapeId | id of hit object shape |
160 | function HighPressureWasherLance:washRaycastCallback(hitActorId, x, y, z, distance, nx, ny, nz, subShapeIndex, hitShapeId) |
161 | local vehicle = g_currentMission.nodeToObject[hitActorId] |
162 | if hitActorId ~= hitShapeId then |
163 | -- object is a compoundChild. Try to find the compound |
164 | local parentId = hitShapeId |
165 | while parentId ~= 0 do |
166 | if g_currentMission.nodeToObject[parentId] ~= nil then |
167 | -- found valid compound |
168 | vehicle = g_currentMission.nodeToObject[parentId] |
169 | break |
170 | end |
171 | parentId = getParent(parentId) |
172 | end |
173 | end |
174 | |
175 | if vehicle ~= nil and vehicle.getAllowsWashingByType ~= nil and vehicle:getAllowsWashingByType(Washable.WASHTYPE_HIGH_PRESSURE_WASHER) then |
176 | self.foundVehicle = vehicle |
177 | return false |
178 | end |
179 | return true |
180 | end |