Zwischen speichern
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||||
<placeable type="mineSilo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../shared/xml/schema/placeable.xsd">
|
<placeable type="mineSilo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../shared/xml/schema/placeable.xsd">
|
||||||
|
|
||||||
|
<produktion fillType="PAYDIRT" amountPerHour="80000" />
|
||||||
|
|
||||||
<storeData>
|
<storeData>
|
||||||
<name>LS25 Mine</name>
|
<name>LS25 Mine</name>
|
||||||
<functions>
|
<functions>
|
||||||
|
|||||||
+45
-7
@@ -1,4 +1,4 @@
|
|||||||
-- Variablen
|
-- Variablen
|
||||||
|
|
||||||
Produktion = {}
|
Produktion = {}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ Produktion.debugPrefix = "[LS25-Mine] "
|
|||||||
|
|
||||||
Produktion.fillType = "PAYDIRT"
|
Produktion.fillType = "PAYDIRT"
|
||||||
Produktion.amountPerHour = 40000
|
Produktion.amountPerHour = 40000
|
||||||
|
Produktion.debugProductionInterval = 30000
|
||||||
Produktion.animationAcceleration = 0.25
|
Produktion.animationAcceleration = 0.25
|
||||||
Produktion.animationSpeedMax = 1.0
|
Produktion.animationSpeedMax = 1.0
|
||||||
|
|
||||||
@@ -29,21 +29,49 @@ function Produktion.registerEventListeners(placeableType)
|
|||||||
SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", Produktion)
|
SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", Produktion)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Produktion.registerXMLPaths(schema, basePath)
|
||||||
|
schema:setXMLSpecializationType("Produktion")
|
||||||
|
schema:register(XMLValueType.STRING, basePath .. ".produktion#fillType", "Fill type produced by this mine", Produktion.fillType)
|
||||||
|
schema:register(XMLValueType.FLOAT, basePath .. ".produktion#amountPerHour", "Amount produced per game hour", Produktion.amountPerHour)
|
||||||
|
schema:setXMLSpecializationType()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Initialisierung
|
-- Initialisierung
|
||||||
|
|
||||||
function Produktion:onLoad(savegame)
|
function Produktion:onLoad(savegame)
|
||||||
|
local xmlFillType = self.xmlFile:getValue("placeable.produktion#fillType", Produktion.fillType)
|
||||||
|
local xmlAmountPerHour = self.xmlFile:getValue("placeable.produktion#amountPerHour", Produktion.amountPerHour)
|
||||||
|
if Produktion.debug then
|
||||||
|
local debugCapacity = self.xmlFile:getValue("placeable.silo.storages.storage(0)#capacity")
|
||||||
|
print(Produktion.debugPrefix .. "XML-Test amount raw: " .. tostring(xmlAmountPerHour))
|
||||||
|
print(Produktion.debugPrefix .. "XML-Test capacity: " .. tostring(debugCapacity))
|
||||||
|
end
|
||||||
|
|
||||||
|
self.produktionFillType = xmlFillType
|
||||||
|
if self.produktionFillType == nil or self.produktionFillType == "" then
|
||||||
|
self.produktionFillType = Produktion.fillType
|
||||||
|
end
|
||||||
|
|
||||||
|
self.produktionAmountPerHour = tonumber(xmlAmountPerHour)
|
||||||
|
if self.produktionAmountPerHour == nil then
|
||||||
|
self.produktionAmountPerHour = Produktion.amountPerHour
|
||||||
|
end
|
||||||
|
|
||||||
self.produktionFirstUpdatePrinted = false
|
self.produktionFirstUpdatePrinted = false
|
||||||
self.produktionAnimationSpeed = 0
|
self.produktionAnimationSpeed = 0
|
||||||
self.produktionAnimationTargetSpeed = 0
|
self.produktionAnimationTargetSpeed = 0
|
||||||
self.produktionWasFull = false
|
self.produktionWasFull = false
|
||||||
self.produktionBuffer = 0
|
self.produktionBuffer = 0
|
||||||
|
self.produktionDebugTimer = 0
|
||||||
|
self.produktionDebugAmount = 0
|
||||||
|
|
||||||
if self.raiseActive ~= nil then
|
if self.raiseActive ~= nil then
|
||||||
self:raiseActive()
|
self:raiseActive()
|
||||||
end
|
end
|
||||||
|
|
||||||
if Produktion.debug then
|
if Produktion.debug then
|
||||||
|
print(Produktion.debugPrefix .. "Konfiguration: " .. tostring(self.produktionFillType) .. " / " .. tostring(self.produktionAmountPerHour) .. " L/h")
|
||||||
print(Produktion.debugPrefix .. "Produktion.lua wurde geladen")
|
print(Produktion.debugPrefix .. "Produktion.lua wurde geladen")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -77,7 +105,11 @@ function Produktion:onUpdate(dt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local gameTimeHours = (dt * timeScale) / 3600000
|
local gameTimeHours = (dt * timeScale) / 3600000
|
||||||
local amountToProduce = Produktion.amountPerHour * gameTimeHours
|
local amountToProduce = self.produktionAmountPerHour * gameTimeHours
|
||||||
|
|
||||||
|
if Produktion.debug then
|
||||||
|
self.produktionDebugTimer = self.produktionDebugTimer + dt
|
||||||
|
end
|
||||||
|
|
||||||
self.produktionBuffer = self.produktionBuffer + amountToProduce
|
self.produktionBuffer = self.produktionBuffer + amountToProduce
|
||||||
|
|
||||||
@@ -121,11 +153,11 @@ function Produktion:produce(amount)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local fillTypeIndex = g_fillTypeManager:getFillTypeIndexByName(Produktion.fillType)
|
local fillTypeIndex = g_fillTypeManager:getFillTypeIndexByName(self.produktionFillType)
|
||||||
|
|
||||||
if fillTypeIndex == nil then
|
if fillTypeIndex == nil then
|
||||||
if Produktion.debug then
|
if Produktion.debug then
|
||||||
print(Produktion.debugPrefix .. "FillType nicht gefunden: " .. Produktion.fillType)
|
print(Produktion.debugPrefix .. "FillType nicht gefunden: " .. self.produktionFillType)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -160,7 +192,13 @@ function Produktion:produce(amount)
|
|||||||
self.produktionWasFull = false
|
self.produktionWasFull = false
|
||||||
|
|
||||||
if producedAmount >= 1 then
|
if producedAmount >= 1 then
|
||||||
print(Produktion.debugPrefix .. "Produziert: " .. tostring(math.floor(producedAmount)) .. " L " .. Produktion.fillType)
|
self.produktionDebugAmount = self.produktionDebugAmount + producedAmount
|
||||||
|
|
||||||
|
if self.produktionDebugTimer >= Produktion.debugProductionInterval then
|
||||||
|
print(Produktion.debugPrefix .. "Produziert: " .. tostring(math.floor(self.produktionDebugAmount)) .. " L " .. self.produktionFillType .. " in den letzten " .. tostring(Produktion.debugProductionInterval / 1000) .. "s")
|
||||||
|
self.produktionDebugTimer = 0
|
||||||
|
self.produktionDebugAmount = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif hasFreeCapacity == false and self.produktionWasFull ~= true then
|
elseif hasFreeCapacity == false and self.produktionWasFull ~= true then
|
||||||
self.produktionWasFull = true
|
self.produktionWasFull = true
|
||||||
@@ -194,4 +232,4 @@ function Produktion:updateAnimationState(isProducing, dt)
|
|||||||
-- self:setAnimationTime("mineWorkAnimation", self.produktionAnimationSpeed, true)
|
-- self:setAnimationTime("mineWorkAnimation", self.produktionAnimationSpeed, true)
|
||||||
-- oder:
|
-- oder:
|
||||||
-- setRotation(self.animationNode, 0, self.produktionAnimationSpeed, 0)
|
-- setRotation(self.animationNode, 0, self.produktionAnimationSpeed, 0)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user