70 | function WoodSellStationPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
71 | if not WoodSellStationPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
72 | return false |
73 | end |
74 | |
75 | local xmlFile = loadXMLFile("TempXML", xmlFilename) |
76 | |
77 | self.appearsOnPDA = Utils.getNoNil(getXMLBool(xmlFile, "placeable.woodSellStation#appearsOnPDA"), false) |
78 | local rawName = Utils.getNoNil(getXMLString(xmlFile, "placeable.woodSellStation#stationName"), "WoodSellStation") |
79 | self.stationName = g_i18n:convertText(rawName) -- returns input if it cannot be resolved |
80 | |
81 | local woodSellTrigger = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.woodSellStation#triggerNode")) |
82 | if woodSellTrigger == nil then |
83 | g_logManager:xmlWarning(xmlFilename, "Missing wood trigger node in 'placeable.woodSellStation#triggerNode'!") |
84 | delete(xmlFile) |
85 | return false |
86 | end |
87 | |
88 | local colMask = getCollisionMask(woodSellTrigger) |
89 | if bitAND(SplitTypeManager.COLLISIONMASK_TRIGGER, colMask) == 0 then |
90 | g_logManager:xmlWarning(xmlFilename, "Invalid collision mask for wood trigger 'placeable.woodSellStation#triggerNode'. Bit 24 needs to be set!") |
91 | delete(xmlFile) |
92 | return false |
93 | end |
94 | |
95 | addTrigger(woodSellTrigger, "woodTriggerCallback", self) |
96 | self.woodSellTrigger = woodSellTrigger |
97 | |
98 | |
99 | local sellTrigger = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.woodSellStation#sellTrigger")) |
100 | if sellTrigger == nil then |
101 | g_logManager:xmlWarning(xmlFilename, "Missing sell trigger in 'placeable.woodSellStation#sellTrigger'!") |
102 | delete(xmlFile) |
103 | return false |
104 | end |
105 | |
106 | colMask = getCollisionMask(sellTrigger) |
107 | if bitAND(Player.COLLISIONMASK_TRIGGER, colMask) == 0 then |
108 | g_logManager:xmlWarning(xmlFilename, "Invalid collision mask for sell trigger 'placeable.woodSellStation#triggerNode'. Bit 20 needs to be set!") |
109 | delete(xmlFile) |
110 | return false |
111 | end |
112 | |
113 | if self.appearsOnPDA then |
114 | local mapPosition = self.woodSellTrigger |
115 | local mapPositionIndex = getUserAttribute(self.woodSellTrigger, "mapPositionIndex") |
116 | if mapPositionIndex ~= nil then |
117 | mapPosition = I3DUtil.indexToObject(self.woodSellTrigger, mapPositionIndex) |
118 | if mapPosition == nil then |
119 | mapPosition = self.woodSellTrigger |
120 | end |
121 | end |
122 | local filenames = nil |
123 | local imageUVs = getNormalizedUVs(MapHotspot.UV.SELLING_POINT) |
124 | local x, _, z = getWorldTranslation(mapPosition) |
125 | |
126 | local hotspotTextOffset = Utils.getNoNil(getXMLString(xmlFile, "placeable.woodSellStation#hotspotTextOffset"), "0px 0px") |
127 | |
128 | self.mapHotspot = MapHotspot:new("woodSellStation", MapHotspot.CATEGORY_TRIGGER) |
129 | self.mapHotspot:setText(self.stationName) |
130 | self.mapHotspot:setBorderedImage(nil, imageUVs, {0.9559, 0.5647, 0.0423, 1}) |
131 | self.mapHotspot:setTextOptions(nil, nil, nil, {0.9559, 0.5647, 0.0423, 1}) |
132 | self.mapHotspot:setWorldPosition(x, z) |
133 | self.mapHotspot:setRawTextOffset(hotspotTextOffset) |
134 | |
135 | g_currentMission:addMapHotspot(self.mapHotspot) |
136 | end |
137 | |
138 | addTrigger(sellTrigger, "woodSellTriggerCallback", self) |
139 | self.sellTrigger = sellTrigger |
140 | |
141 | self.activateText = g_i18n:getText("action_sellWood") |
142 | self.objectActivated = false |
143 | |
144 | self.updateEventListeners = {} |
145 | |
146 | delete(xmlFile) |
147 | |
148 | return true |
149 | end |