Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- AIConveyorBelt
- AIImplement
- AIVehicle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BunkerSiloCompacter
- BunkerSiloInteractor
- BuyableBale
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- JigglingParts
- Leveler
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- MixerWagon
- Motorized
- Mountable
- Mower
- Pickup
- Pipe
- Plow
- PowerConsumer
- PowerTakeOffs
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StrawBlower
- StumpCutter
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TipOccluder
- Trailer
- TreePlanter
- TreeSaw
- TurnOnVehicle
- Washable
- WaterTrailer
- Wearable
- Weeder
- Wheels
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
TipOccluder
DescriptionSpecialization allowing vehicles to prevent tipping filltypes in specified areas (e.g. below wheels)Functions
- finalizeWheel
- getRequiresTipOcclusionArea
- getTipOcclusionAreas
- getWheelsWithTipOcclisionAreaGroupId
- onLoad
- onPostLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
finalizeWheel
DescriptionDefinitionfinalizeWheel()Code
105 | function TipOccluder:finalizeWheel(superFunc, wheel, parentWheel) |
106 | superFunc(self, wheel, parentWheel) |
107 | |
108 | local spec = self.spec_tipOccluder |
109 | if wheel.tipOcclusionAreaGroupId ~= nil then |
110 | local vehicleRootNode = self.components[1].node |
111 | local doCreate = true |
112 | local area |
113 | for groupId, occluderArea in pairs(spec.createdTipOcclusionAreaGroupIds) do |
114 | if groupId == wheel.tipOcclusionAreaGroupId then |
115 | doCreate = false |
116 | area = occluderArea |
117 | break |
118 | end |
119 | end |
120 | |
121 | -- the first wheel with the group id creates the area, the other just recalculate the area |
122 | if doCreate then |
123 | local start = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
124 | local width = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
125 | local height = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
126 | link(vehicleRootNode, start) |
127 | link(vehicleRootNode, width) |
128 | link(vehicleRootNode, height) |
129 | |
130 | area = {start=start, width=width, height=height} |
131 | table.insert(spec.tipOcclusionAreas, area) |
132 | spec.createdTipOcclusionAreaGroupIds[wheel.tipOcclusionAreaGroupId] = area |
133 | end |
134 | |
135 | if area ~= nil then |
136 | local xMax = -math.huge |
137 | local xMin = math.huge |
138 | local zMax = -math.huge |
139 | local zMin = math.huge |
140 | |
141 | -- get other wheels with the same area group id |
142 | local usedWheels = self:getWheelsWithTipOcclisionAreaGroupId(self:getWheels(), wheel.tipOcclusionAreaGroupId) |
143 | |
144 | -- also include myself into the calculation |
145 | table.insert(usedWheels, wheel) |
146 | |
147 | for _,usedWheel in pairs(usedWheels) do |
148 | local x,_,z = localToLocal(usedWheel.driveNode, vehicleRootNode, usedWheel.wheelshapeWidth - 0.5 * usedWheel.width, 0, -usedWheel.radius) |
149 | xMax = math.max(x, xMax) |
150 | zMin = math.min(z, zMin) |
151 | x,_,z = localToLocal(usedWheel.driveNode, vehicleRootNode, -usedWheel.wheelshapeWidth + 0.5 * usedWheel.width, 0, usedWheel.radius) |
152 | xMin = math.min(x, xMin) |
153 | zMax = math.max(z, zMax) |
154 | end |
155 | |
156 | setTranslation(area.start, xMax,0,zMin) |
157 | setTranslation(area.width, xMin,0,zMin) |
158 | setTranslation(area.height, xMax,0,zMax) |
159 | end |
160 | end |
161 | end |
getRequiresTipOcclusionArea
DescriptionDefinitiongetRequiresTipOcclusionArea()Code
99 | function TipOccluder:getRequiresTipOcclusionArea() |
100 | return false |
101 | end |
getTipOcclusionAreas
DescriptionDefinitiongetTipOcclusionAreas()Code
71 | function TipOccluder:getTipOcclusionAreas() |
72 | return self.spec_tipOccluder.tipOcclusionAreas |
73 | end |
getWheelsWithTipOcclisionAreaGroupId
DescriptionDefinitiongetWheelsWithTipOcclisionAreaGroupId()Code
77 | function TipOccluder:getWheelsWithTipOcclisionAreaGroupId(wheels, groupId) |
78 | local returnWheels = {} |
79 | for _,wheel in pairs(wheels) do |
80 | if wheel.tipOcclusionAreaGroupId == groupId then |
81 | table.insert(returnWheels, wheel) |
82 | end |
83 | end |
84 | return returnWheels |
85 | end |
onLoad
DescriptionDefinitiononLoad()Code
43 | function TipOccluder:onLoad(savegame) |
44 | local spec = self.spec_tipOccluder |
45 | |
46 | XMLUtil.checkDeprecatedXMLElements(self.xmlFile, self.configFileName, "vehicle.tipOcclusionAreas.tipOcclusionArea", "vehicle.tipOccluder.occlusionArea") --FS17 to FS19 |
47 | |
48 | -- load tip occlusion areas |
49 | spec.tipOcclusionAreas = {} |
50 | local i = 0 |
51 | while true do |
52 | local key = string.format("vehicle.tipOccluder.occlusionArea(%d)", i) |
53 | if not hasXMLProperty(self.xmlFile, key) then |
54 | break |
55 | end |
56 | local entry = {} |
57 | entry.start = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile, key .. "#start"), self.i3dMappings) |
58 | entry.width = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile, key .. "#width"), self.i3dMappings) |
59 | entry.height = I3DUtil.indexToObject(self.components, getXMLString(self.xmlFile, key .. "#height"), self.i3dMappings) |
60 | if entry.start ~= nil and entry.width ~= nil and entry.height ~= nil then |
61 | table.insert(spec.tipOcclusionAreas, entry) |
62 | end |
63 | i = i + 1 |
64 | end |
65 | |
66 | spec.createdTipOcclusionAreaGroupIds = {} |
67 | end |
onPostLoad
DescriptionDefinitiononPostLoad()Code
89 | function TipOccluder:onPostLoad() |
90 | if self:getRequiresTipOcclusionArea() then |
91 | if table.getn(self.spec_tipOccluder.tipOcclusionAreas) == 0 then |
92 | g_logManager:xmlDevWarning(self.configFileName, "No TipOcclusionArea defined") |
93 | end |
94 | end |
95 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
16 | function TipOccluder.prerequisitesPresent(specializations) |
17 | return true |
18 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
36 | function TipOccluder.registerEventListeners(vehicleType) |
37 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", TipOccluder) |
38 | SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", TipOccluder) |
39 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
22 | function TipOccluder.registerFunctions(vehicleType) |
23 | SpecializationUtil.registerFunction(vehicleType, "getTipOcclusionAreas", TipOccluder.getTipOcclusionAreas) |
24 | SpecializationUtil.registerFunction(vehicleType, "getWheelsWithTipOcclisionAreaGroupId", TipOccluder.getWheelsWithTipOcclisionAreaGroupId) |
25 | SpecializationUtil.registerFunction(vehicleType, "getRequiresTipOcclusionArea", TipOccluder.getRequiresTipOcclusionArea) |
26 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
30 | function TipOccluder.registerOverwrittenFunctions(vehicleType) |
31 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "finalizeWheel", TipOccluder.finalizeWheel) |
32 | end |