Shut down base power if NTU runs out, and restore it once refilled.

This commit is contained in:
Mazo 2018-05-26 17:13:24 +01:00
parent 0ecceebf34
commit fc71bbfd2a
4 changed files with 21 additions and 6 deletions

View file

@ -46,13 +46,14 @@ class ResourceSiloControl(resourceSilo : ResourceSilo) extends Actor with Factio
avatarService ! AvatarServiceMessage(resourceSilo.Owner.asInstanceOf[Building].Zone.Id, AvatarAction.PlanetsideAttribute(PlanetSideGUID(resourceSilo.Owner.asInstanceOf[Building].ModelId), 47, resourceSilo.LowNtuWarningOn))
case ResourceSilo.UpdateChargeLevel(amount: Int) =>
val siloChargeBeforeChange = resourceSilo.ChargeLevel
// Increase if positive passed in or decrease charge level if negative number is passed in
resourceSilo.ChargeLevel += amount
if(resourceSilo.ChargeLevel > 0) {
log.trace(s"UpdateChargeLevel: Silo ${resourceSilo.GUID} set to ${resourceSilo.ChargeLevel}")
}
val ntuIsLow = resourceSilo.ChargeLevel.toFloat / resourceSilo.MaximumCharge.toFloat < 0.2f
val ntuBarLevel = scala.math.round((resourceSilo.ChargeLevel.toFloat / resourceSilo.MaximumCharge.toFloat) * 10).toInt
// Only send updated capacitor display value to all clients if it has actually changed
@ -63,13 +64,23 @@ class ResourceSiloControl(resourceSilo : ResourceSilo) extends Actor with Factio
avatarService ! AvatarServiceMessage(resourceSilo.Owner.asInstanceOf[Building].Zone.Id, AvatarAction.PlanetsideAttribute(resourceSilo.GUID, 45, resourceSilo.CapacitorDisplay))
}
val ntuIsLow = resourceSilo.ChargeLevel.toFloat / resourceSilo.MaximumCharge.toFloat < 0.2f
if(resourceSilo.LowNtuWarningOn == 1 && !ntuIsLow){
self ! ResourceSilo.LowNtuWarning(0)
} else if (resourceSilo.LowNtuWarningOn == 0 && ntuIsLow) {
self ! ResourceSilo.LowNtuWarning(1)
}
//todo: Shut down base power and make base neutral if silo hits zero NTU
if(resourceSilo.ChargeLevel == 0 && siloChargeBeforeChange > 0) {
// Oops, someone let the base run out of power. Shut it all down.
//todo: Make base neutral if silo hits zero NTU
avatarService ! AvatarServiceMessage(resourceSilo.Owner.asInstanceOf[Building].Zone.Id, AvatarAction.PlanetsideAttribute(PlanetSideGUID(resourceSilo.Owner.asInstanceOf[Building].ModelId), 48, 1))
} else if (siloChargeBeforeChange == 0 && resourceSilo.ChargeLevel > 0) {
// Power restored. Reactor Online. Sensors Online. Weapons Online. All systems nominal.
//todo: Check generator is online before starting up
avatarService ! AvatarServiceMessage(resourceSilo.Owner.asInstanceOf[Building].Zone.Id, AvatarAction.PlanetsideAttribute(PlanetSideGUID(resourceSilo.Owner.asInstanceOf[Building].ModelId), 48, 0))
}
case _ => ;
}

View file

@ -106,7 +106,7 @@ import scodec.codecs._
* `43 - Info on avatar name : 0 = Nothing, 1 = "(LD)" message`<br>
* `45 - NTU charge bar 0-10, 5 = 50% full. Seems to apply to both ANT and NTU Silo (possibly siphons?)`<br>
* 47 - Sets base NTU level to CRITICAL. MUST use base modelId not base GUID
* 48 - Send base power loss message & turns on red warning lights throughout base. MUST use base modelId not base GUID
* 48 - Set to 1 to send base power loss message & turns on red warning lights throughout base. MUST use base modelId not base GUID
* 49 - Vehicle texture effects state? (>0 turns on ANT panel glow or ntu silo panel glow + orbs) (bit?)
* `52 - Vehicle particle effects? (>0 turns on orbs going towards ANT. Doesn't affect silo) (bit?)
* `53 - LFS. Value is 1 to flag LFS`<br>

View file

@ -38,7 +38,6 @@ class GalaxyService extends Actor {
case GalaxyServiceMessage(action) =>
action match {
case GalaxyAction.MapUpdate(msg: BuildingInfoUpdateMessage) =>
log.warn(s"Publishing msg ${msg}")
GalaxyEvents.publish(
GalaxyServiceResponse(s"/Galaxy", GalaxyResponse.MapUpdate(msg))
)

View file

@ -4380,8 +4380,13 @@ class WorldSessionActor extends Actor with MDCContextAware {
amenity.Definition match {
case GlobalDefinitions.resource_silo =>
// Synchronise warning light & silo capacity
sendResponse(PlanetsideAttributeMessage(amenityId, 45, amenity.asInstanceOf[ResourceSilo].CapacitorDisplay))
sendResponse(PlanetsideAttributeMessage(amenityId, 47, amenity.asInstanceOf[ResourceSilo].LowNtuWarningOn))
var silo = amenity.asInstanceOf[ResourceSilo]
sendResponse(PlanetsideAttributeMessage(amenityId, 45, silo.CapacitorDisplay))
sendResponse(PlanetsideAttributeMessage(amenityId, 47, silo.LowNtuWarningOn))
if(silo.ChargeLevel == 0) {
sendResponse(PlanetsideAttributeMessage(PlanetSideGUID(silo.Owner.asInstanceOf[Building].ModelId), 48, 1))
}
case _ => ;
}
})