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
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- 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
PlaceableTipOcclusionAreas
DescriptionSpecialization for placeablesFunctions
- loadTipOcclusionArea
- onDelete
- onFinalizePlacement
- onLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerXMLPaths
- updateTipOcclusionAreas
loadTipOcclusionArea
DescriptionDefinitionloadTipOcclusionArea()Code
104 | function PlaceableTipOcclusionAreas:loadTipOcclusionArea(xmlFile, key, area) |
105 | local startNode = xmlFile:getValue(key .. "#startNode", nil, self.components, self.i3dMappings) |
106 | local endNode = xmlFile:getValue(key .. "#endNode", nil, self.components, self.i3dMappings) |
107 | |
108 | if startNode == nil then |
109 | Logging.xmlWarning(xmlFile, "Missing tip occlusion update area start node for '%s'", key) |
110 | return false |
111 | end |
112 | |
113 | if endNode == nil then |
114 | Logging.xmlWarning(xmlFile, "Missing tip occlusion update area end node for '%s'", key) |
115 | return false |
116 | end |
117 | |
118 | |
119 | local startX, _, startZ = localToLocal(startNode, self.rootNode, 0, 0, 0) |
120 | local endX, _, endZ = localToLocal(endNode, self.rootNode, 0, 0, 0) |
121 | |
122 | local sizeX = math.abs(endX - startX) |
123 | local sizeZ = math.abs(endZ - startZ) |
124 | |
125 | area.center = {} |
126 | area.center.x = (endX + startX) * 0.5 |
127 | area.center.z = (endZ + startZ) * 0.5 |
128 | |
129 | area.size = {} |
130 | area.size.x = sizeX |
131 | area.size.z = sizeZ |
132 | |
133 | area.startNode = startNode |
134 | area.endNode = endNode |
135 | |
136 | return true |
137 | end |
onDelete
DescriptionDefinitiononDelete()Code
90 | function PlaceableTipOcclusionAreas:onDelete() |
91 | if self.isServer then |
92 | if not self.isReloading then |
93 | local spec = self.spec_tipOcclusionAreas |
94 | if spec.updateTipOcclusionAreasOnDelete then |
95 | self:updateTipOcclusionAreas() |
96 | spec.updateTipOcclusionAreasOnDelete = false |
97 | end |
98 | end |
99 | end |
100 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
141 | function PlaceableTipOcclusionAreas:onFinalizePlacement() |
142 | if self.isServer then |
143 | local missionInfo = g_currentMission.missionInfo |
144 | if not self.isLoadedFromSavegame or not missionInfo.isValid or not missionInfo:getIsTipCollisionValid(g_currentMission) or not missionInfo:getIsPlacementCollisionValid(g_currentMission) then |
145 | self:updateTipOcclusionAreas() |
146 | end |
147 | |
148 | local spec = self.spec_tipOcclusionAreas |
149 | spec.updateTipOcclusionAreasOnDelete = true |
150 | end |
151 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
53 | function PlaceableTipOcclusionAreas:onLoad(savegame) |
54 | local spec = self.spec_tipOcclusionAreas |
55 | local xmlFile = self.xmlFile |
56 | |
57 | spec.updateTipOcclusionAreasOnDelete = false |
58 | spec.areas = {} |
59 | xmlFile:iterate("placeable.tipOcclusionUpdateAreas.tipOcclusionUpdateArea", function(_, key) |
60 | local area = {} |
61 | if self:loadTipOcclusionArea(xmlFile, key, area) then |
62 | table.insert(spec.areas, area) |
63 | end |
64 | end) |
65 | |
66 | if xmlFile:hasProperty("placeable.tipOcclusionUpdateArea") then |
67 | local sizeX = xmlFile:getValue("placeable.tipOcclusionUpdateArea#sizeX") |
68 | local sizeZ = xmlFile:getValue("placeable.tipOcclusionUpdateArea#sizeZ") |
69 | |
70 | if sizeX ~= nil and sizeZ ~= nil then |
71 | local centerX = xmlFile:getValue("placeable.tipOcclusionUpdateArea#centerX", 0) |
72 | local centerZ = xmlFile:getValue("placeable.tipOcclusionUpdateArea#centerZ", 0) |
73 | |
74 | local area = {} |
75 | area.center = {} |
76 | area.center.x = centerX |
77 | area.center.z = centerZ |
78 | |
79 | area.size = {} |
80 | area.size.x = sizeX |
81 | area.size.z = sizeZ |
82 | |
83 | table.insert(spec.areas, area) |
84 | end |
85 | end |
86 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
18 | function PlaceableTipOcclusionAreas.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
31 | function PlaceableTipOcclusionAreas.registerEventListeners(placeableType) |
32 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableTipOcclusionAreas) |
33 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableTipOcclusionAreas) |
34 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableTipOcclusionAreas) |
35 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableTipOcclusionAreas.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "loadTipOcclusionArea", PlaceableTipOcclusionAreas.loadTipOcclusionArea) |
26 | SpecializationUtil.registerFunction(placeableType, "updateTipOcclusionAreas", PlaceableTipOcclusionAreas.updateTipOcclusionAreas) |
27 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
39 | function PlaceableTipOcclusionAreas.registerXMLPaths(schema, basePath) |
40 | schema:setXMLSpecializationType("TipOcclusionAreas") |
41 | schema:register(XMLValueType.FLOAT, basePath .. ".tipOcclusionUpdateArea#sizeX", "Size X") |
42 | schema:register(XMLValueType.FLOAT, basePath .. ".tipOcclusionUpdateArea#sizeZ", "Size Z") |
43 | schema:register(XMLValueType.FLOAT, basePath .. ".tipOcclusionUpdateArea#centerX", "Center position X", 0) |
44 | schema:register(XMLValueType.FLOAT, basePath .. ".tipOcclusionUpdateArea#centerZ", "Center position Z", 0) |
45 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".tipOcclusionUpdateAreas.tipOcclusionUpdateArea(?)#startNode", "Start node of tipOcclusion update area") |
46 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".tipOcclusionUpdateAreas.tipOcclusionUpdateArea(?)#endNode", "End node of tipOcclusion update area") |
47 | schema:setXMLSpecializationType() |
48 | end |
updateTipOcclusionAreas
DescriptionDefinitionupdateTipOcclusionAreas()Code
155 | function PlaceableTipOcclusionAreas:updateTipOcclusionAreas() |
156 | if self.isServer then |
157 | local spec = self.spec_tipOcclusionAreas |
158 | for _, area in pairs(spec.areas) do |
159 | local x, z = area.center.x, area.center.z |
160 | local sizeX, sizeZ = area.size.x, area.size.z |
161 | |
162 | local x1, _, z1 = localToWorld(self.rootNode, x + sizeX * 0.5, 0, z + sizeZ * 0.5) |
163 | local x2, _, z2 = localToWorld(self.rootNode, x - sizeX * 0.5, 0, z + sizeZ * 0.5) |
164 | local x3, _, z3 = localToWorld(self.rootNode, x + sizeX * 0.5, 0, z - sizeZ * 0.5) |
165 | local x4, _, z4 = localToWorld(self.rootNode, x - sizeX * 0.5, 0, z - sizeZ * 0.5) |
166 | |
167 | local minX = math.min(x1, x2, x3, x4) |
168 | local maxX = math.max(x1, x2, x3, x4) |
169 | local minZ = math.min(z1, z2, z3, z4) |
170 | local maxZ = math.max(z1, z2, z3, z4) |
171 | g_densityMapHeightManager:setCollisionMapAreaDirty(minX, minZ, maxX, maxZ, true) |
172 | end |
173 | end |
174 | end |