NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

heatAttribute.py (4698B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dogma\attributes\heatAttribute.py
      2 import gametime
      3 from dogma.attributes import Attribute
      4 from dogma.const import attributeHeatHi, attributeHeatDissipationRateHi, attributeHeatCapacityHi
      5 from dogma.const import attributeHeatMed, attributeHeatDissipationRateMed, attributeHeatCapacityMed
      6 from dogma.const import attributeHeatLow, attributeHeatDissipationRateLow, attributeHeatCapacityLow
      7 from dogma.const import attributeHeatGenerationMultiplier, dgmTauConstant
      8 from math import exp
      9 import weakref
     10 
     11 def CalculateHeat(currentHeat, timeDiff, incomingHeat, dissipationRate, heatGenerationMul, heatCap):
     12     if incomingHeat < 5e-08:
     13         currentHeat *= exp(-timeDiff / 1000 * dissipationRate)
     14         if round(currentHeat, 0) <= 0:
     15             currentHeat = 0.0
     16     else:
     17         hgm = heatGenerationMul
     18         hc = heatCap
     19         currentHeat = hc - hc * exp(-timeDiff / 1000 * incomingHeat * hgm) + currentHeat * exp(-timeDiff / 1000 * incomingHeat * hgm)
     20     return currentHeat
     21 
     22 
     23 class HeatAttribute(Attribute):
     24     __slots__ = ['heatGenerationMultiplierAttribute',
     25      'heatDissipationRateAttribute',
     26      'prevCap',
     27      'lastCalcTime',
     28      'incomingHeat']
     29 
     30     def __init__(self, attribID, baseValue, dogmaItem, dogmaLM, staticAttr):
     31         super(HeatAttribute, self).__init__(attribID, baseValue, dogmaItem, dogmaLM, staticAttr)
     32         dissipationAttributeByHeatID = {attributeHeatHi: attributeHeatDissipationRateHi,
     33          attributeHeatMed: attributeHeatDissipationRateMed,
     34          attributeHeatLow: attributeHeatDissipationRateLow}
     35         heatCapacityByHeatID = {attributeHeatHi: attributeHeatCapacityHi,
     36          attributeHeatMed: attributeHeatCapacityMed,
     37          attributeHeatLow: attributeHeatCapacityLow}
     38         self.heatGenerationMultiplierAttribute = weakref.proxy(self.item.attributes[attributeHeatGenerationMultiplier])
     39         self.capAttrib = weakref.proxy(self.item.attributes[heatCapacityByHeatID[attribID]])
     40         self.heatDissipationRateAttribute = weakref.proxy(self.item.attributes[dissipationAttributeByHeatID[attribID]])
     41         capVal = self.capAttrib.GetValue()
     42         self.currentValue = min(capVal, self.currentValue)
     43         self.prevCap = capVal
     44         self.lastCalcTime = gametime.GetSimTime()
     45         self.incomingHeat = Attribute(None, 0, dogmaItem, dogmaLM, staticAttr)
     46 
     47     def Update(self):
     48         currentTime = gametime.GetSimTime()
     49         timeDiff = (currentTime - self.lastCalcTime) / float(dgmTauConstant)
     50         incHeat = self.incomingHeat.GetValue()
     51         self.currentValue = CalculateHeat(self.currentValue, timeDiff, incHeat, self.heatDissipationRateAttribute.GetValue(), self.heatGenerationMultiplierAttribute.GetValue(), self.capAttrib.GetValue())
     52         self.dirty = False
     53         self.lastCalcTime = currentTime
     54         return self.currentValue
     55 
     56     def GetValue(self):
     57         if self.dirty or self.lastCalcTime != gametime.GetSimTime():
     58             self.Update()
     59         return self.currentValue
     60 
     61     def GetFullHeatInfo(self):
     62         if self.dirty or self.lastCalcTime != gametime.GetSimTime():
     63             self.MarkDirty()
     64             self.Update()
     65         return (self.currentValue, self.lastCalcTime, self.capAttrib.GetValue())
     66 
     67     def GetHeatMessage(self):
     68         if self.dirty or self.lastCalcTime != gametime.GetSimTime():
     69             self.MarkDirty()
     70             self.Update()
     71         return (self.currentValue,
     72          self.capAttrib.currentValue,
     73          self.incomingHeat.GetValue(),
     74          self.heatGenerationMultiplierAttribute.currentValue,
     75          self.heatDissipationRateAttribute.currentValue,
     76          self.lastCalcTime)
     77 
     78     def SetBaseValue(self, newBaseValue, asPercentage = False):
     79         if self.currentValue != newBaseValue:
     80             if asPercentage:
     81                 newBaseValue *= self.capAttrib.GetValue()
     82             self.currentValue = newBaseValue
     83             self.lastCalcTime = gametime.GetSimTime()
     84             self.MarkDirty()
     85 
     86     def AddIncomingModifier(self, op, attribute):
     87         self.Update()
     88         self.incomingHeat.AddIncomingModifier(op, attribute)
     89 
     90     def RemoveIncomingModifier(self, op, attribute):
     91         self.Update()
     92         self.incomingHeat.RemoveIncomingModifier(op, attribute)
     93 
     94     def ResetBaseValue(self):
     95         self.Update()
     96         self.currentValue = self.typeValue
     97 
     98     def IncreaseBaseValue(self, addAmount):
     99         self.Update()
    100         self.currentValue += addAmount
    101 
    102     def DecreaseBaseValue(self, decAmount):
    103         self.Update()
    104         self.currentValue -= decAmount
    105 
    106     def GetPersistData(self):
    107         self.Update()
    108         return self.currentValue