mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Cheaper position update when target is reached.
Specific power settings for drones.
This commit is contained in:
parent
5d0d662c56
commit
b65141afec
@ -513,9 +513,15 @@ opencomputers {
|
|||||||
# computer up and running without also having to build a capacitor.
|
# computer up and running without also having to build a capacitor.
|
||||||
computer: 500.0
|
computer: 500.0
|
||||||
|
|
||||||
|
# The amount a tablet can store in its internal buffer.
|
||||||
|
tablet: 10000
|
||||||
|
|
||||||
# The amount of energy robots can store in their internal buffer.
|
# The amount of energy robots can store in their internal buffer.
|
||||||
robot: 20000.0
|
robot: 20000.0
|
||||||
|
|
||||||
|
# The amount of energy a drone can store in its internal buffer.
|
||||||
|
drone: 5000.0
|
||||||
|
|
||||||
# The amount of energy a converter can store. This allows directly
|
# The amount of energy a converter can store. This allows directly
|
||||||
# connecting a converter to a distributor, without having to have a
|
# connecting a converter to a distributor, without having to have a
|
||||||
# capacitor on the side of the converter.
|
# capacitor on the side of the converter.
|
||||||
@ -528,9 +534,6 @@ opencomputers {
|
|||||||
# add capacitors between two distributors to increase this bandwidth.
|
# add capacitors between two distributors to increase this bandwidth.
|
||||||
distributor: 500
|
distributor: 500
|
||||||
|
|
||||||
# The amount a tablet can store in its internal buffer.
|
|
||||||
tablet: 10000
|
|
||||||
|
|
||||||
# The amount of energy an access point can store.
|
# The amount of energy an access point can store.
|
||||||
accessPoint: 600.0
|
accessPoint: 600.0
|
||||||
}
|
}
|
||||||
@ -540,6 +543,9 @@ opencomputers {
|
|||||||
# The amount of energy a computer consumes per tick when running.
|
# The amount of energy a computer consumes per tick when running.
|
||||||
computer: 0.5
|
computer: 0.5
|
||||||
|
|
||||||
|
# Amount of energy a microcontroller consumes per tick while running.
|
||||||
|
microcontroller: 0.1
|
||||||
|
|
||||||
# The amount of energy a robot consumes per tick when running. This is
|
# The amount of energy a robot consumes per tick when running. This is
|
||||||
# per default less than a normal computer uses because... well... they
|
# per default less than a normal computer uses because... well... they
|
||||||
# are better optimized? It balances out due to the cost for movement,
|
# are better optimized? It balances out due to the cost for movement,
|
||||||
@ -548,6 +554,9 @@ opencomputers {
|
|||||||
# computers.
|
# computers.
|
||||||
robot: 0.25
|
robot: 0.25
|
||||||
|
|
||||||
|
# The amount of energy a drone consumes per tick when running.
|
||||||
|
drone: 0.2
|
||||||
|
|
||||||
# The actual cost per tick for computers and robots is multiplied
|
# The actual cost per tick for computers and robots is multiplied
|
||||||
# with this value if they are currently in a "sleeping" state. They
|
# with this value if they are currently in a "sleeping" state. They
|
||||||
# enter this state either by calling `os.sleep()` or by pulling
|
# enter this state either by calling `os.sleep()` or by pulling
|
||||||
@ -648,6 +657,13 @@ opencomputers {
|
|||||||
# each point of complexity.
|
# each point of complexity.
|
||||||
robotAssemblyComplexity: 10000
|
robotAssemblyComplexity: 10000
|
||||||
|
|
||||||
|
# The base energy cost for assembling a microcontroller.
|
||||||
|
microcontrollerAssemblyBase: 10000
|
||||||
|
|
||||||
|
# The additional amount of energy required to assemble a
|
||||||
|
# microcontroller for each point of complexity.
|
||||||
|
microcontrollerAssemblyComplexity: 10000
|
||||||
|
|
||||||
# The base energy cost for assembling a tablet.
|
# The base energy cost for assembling a tablet.
|
||||||
tabletAssemblyBase: 20000
|
tabletAssemblyBase: 20000
|
||||||
|
|
||||||
@ -655,6 +671,13 @@ opencomputers {
|
|||||||
# each point of complexity.
|
# each point of complexity.
|
||||||
tabletAssemblyComplexity: 5000
|
tabletAssemblyComplexity: 5000
|
||||||
|
|
||||||
|
# The base energy cost for assembling a microcontroller.
|
||||||
|
droneAssemblyBase: 25000
|
||||||
|
|
||||||
|
# The additional amount of energy required to assemble a
|
||||||
|
# microcontroller for each point of complexity.
|
||||||
|
droneAssemblyComplexity: 15000
|
||||||
|
|
||||||
# The amount of energy it takes to extract one ingredient from an
|
# The amount of energy it takes to extract one ingredient from an
|
||||||
# item that is being disassembled. For example, if an item that was
|
# item that is being disassembled. For example, if an item that was
|
||||||
# crafted from three other items gets disassembled, a total of 15000
|
# crafted from three other items gets disassembled, a total of 15000
|
||||||
@ -674,16 +697,6 @@ opencomputers {
|
|||||||
# Energy it costs to re-program an EEPROM. This is deliberately
|
# Energy it costs to re-program an EEPROM. This is deliberately
|
||||||
# expensive, to discourage frequent re-writing of EEPROMs.
|
# expensive, to discourage frequent re-writing of EEPROMs.
|
||||||
eepromWrite: 50
|
eepromWrite: 50
|
||||||
|
|
||||||
# Amount of energy a microcontroller consumes per tick while running.
|
|
||||||
microcontroller: 0.1
|
|
||||||
|
|
||||||
# The base energy cost for assembling a microcontroller.
|
|
||||||
microcontrollerAssemblyBase: 10000
|
|
||||||
|
|
||||||
# The additional amount of energy required to assemble a
|
|
||||||
# microcontroller for each point of complexity.
|
|
||||||
microcontrollerAssemblyComplexity: 10000
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# The rate at which different blocks accept external power. All of these
|
# The rate at which different blocks accept external power. All of these
|
||||||
|
@ -129,7 +129,7 @@ class Settings(val config: Config) {
|
|||||||
val pureIgnorePower = config.getBoolean("power.ignorePower")
|
val pureIgnorePower = config.getBoolean("power.ignorePower")
|
||||||
lazy val ignorePower = pureIgnorePower || !Mods.isPowerProvidingModPresent
|
lazy val ignorePower = pureIgnorePower || !Mods.isPowerProvidingModPresent
|
||||||
val tickFrequency = config.getDouble("power.tickFrequency") max 1
|
val tickFrequency = config.getDouble("power.tickFrequency") max 1
|
||||||
val chargeRateRobot = config.getDouble("power.chargerChargeRate")
|
val chargeRateExternal = config.getDouble("power.chargerChargeRate")
|
||||||
val chargeRateTablet = config.getDouble("power.chargerChargeRateTablet")
|
val chargeRateTablet = config.getDouble("power.chargerChargeRateTablet")
|
||||||
val generatorEfficiency = config.getDouble("power.generatorEfficiency")
|
val generatorEfficiency = config.getDouble("power.generatorEfficiency")
|
||||||
val solarGeneratorEfficiency = config.getDouble("power.solarGeneratorEfficiency")
|
val solarGeneratorEfficiency = config.getDouble("power.solarGeneratorEfficiency")
|
||||||
@ -153,10 +153,13 @@ class Settings(val config: Config) {
|
|||||||
}
|
}
|
||||||
val bufferTablet = config.getDouble("power.buffer.tablet") max 0
|
val bufferTablet = config.getDouble("power.buffer.tablet") max 0
|
||||||
val bufferAccessPoint = config.getDouble("power.buffer.accessPoint") max 0
|
val bufferAccessPoint = config.getDouble("power.buffer.accessPoint") max 0
|
||||||
|
val bufferDrone = config.getDouble("power.buffer.drone") max 0
|
||||||
|
|
||||||
// power.cost
|
// power.cost
|
||||||
val computerCost = config.getDouble("power.cost.computer") max 0
|
val computerCost = config.getDouble("power.cost.computer") max 0
|
||||||
|
val microcontrollerCost = config.getDouble("power.cost.microcontroller") max 0
|
||||||
val robotCost = config.getDouble("power.cost.robot") max 0
|
val robotCost = config.getDouble("power.cost.robot") max 0
|
||||||
|
val droneCost = config.getDouble("power.cost.drone") max 0
|
||||||
val sleepCostFactor = config.getDouble("power.cost.sleepFactor") max 0
|
val sleepCostFactor = config.getDouble("power.cost.sleepFactor") max 0
|
||||||
val screenCost = config.getDouble("power.cost.screen") max 0
|
val screenCost = config.getDouble("power.cost.screen") max 0
|
||||||
val hologramCost = config.getDouble("power.cost.hologram") max 0
|
val hologramCost = config.getDouble("power.cost.hologram") max 0
|
||||||
@ -174,15 +177,16 @@ class Settings(val config: Config) {
|
|||||||
val geolyzerScanCost = config.getDouble("power.cost.geolyzerScan") max 0
|
val geolyzerScanCost = config.getDouble("power.cost.geolyzerScan") max 0
|
||||||
val robotBaseCost = config.getDouble("power.cost.robotAssemblyBase") max 0
|
val robotBaseCost = config.getDouble("power.cost.robotAssemblyBase") max 0
|
||||||
val robotComplexityCost = config.getDouble("power.cost.robotAssemblyComplexity") max 0
|
val robotComplexityCost = config.getDouble("power.cost.robotAssemblyComplexity") max 0
|
||||||
|
val microcontrollerBaseCost = config.getDouble("power.cost.microcontrollerAssemblyBase") max 0
|
||||||
|
val microcontrollerComplexityCost = config.getDouble("power.cost.microcontrollerAssemblyComplexity") max 0
|
||||||
val tabletBaseCost = config.getDouble("power.cost.tabletAssemblyBase") max 0
|
val tabletBaseCost = config.getDouble("power.cost.tabletAssemblyBase") max 0
|
||||||
val tabletComplexityCost = config.getDouble("power.cost.tabletAssemblyComplexity") max 0
|
val tabletComplexityCost = config.getDouble("power.cost.tabletAssemblyComplexity") max 0
|
||||||
|
val droneBaseCost = config.getDouble("power.cost.droneAssemblyBase") max 0
|
||||||
|
val droneComplexityCost = config.getDouble("power.cost.droneAssemblyComplexity") max 0
|
||||||
val disassemblerItemCost = config.getDouble("power.cost.disassemblerPerItem") max 0
|
val disassemblerItemCost = config.getDouble("power.cost.disassemblerPerItem") max 0
|
||||||
val chunkloaderCost = config.getDouble("power.cost.chunkloaderCost") max 0
|
val chunkloaderCost = config.getDouble("power.cost.chunkloaderCost") max 0
|
||||||
val pistonCost = config.getDouble("power.cost.pistonPush") max 0
|
val pistonCost = config.getDouble("power.cost.pistonPush") max 0
|
||||||
val microcontrollerCost = config.getDouble("power.cost.microcontroller") max 0
|
|
||||||
val eepromWriteCost = config.getDouble("power.cost.eepromWrite") max 0
|
val eepromWriteCost = config.getDouble("power.cost.eepromWrite") max 0
|
||||||
val microcontrollerBaseCost = config.getDouble("power.cost.microcontrollerAssemblyBase") max 0
|
|
||||||
val microcontrollerComplexityCost = config.getDouble("power.cost.microcontrollerAssemblyComplexity") max 0
|
|
||||||
|
|
||||||
// power.rate
|
// power.rate
|
||||||
val accessPointRate = config.getDouble("power.rate.accessPoint") max 0
|
val accessPointRate = config.getDouble("power.rate.accessPoint") max 0
|
||||||
|
@ -57,7 +57,11 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
// Logic stuff, components, machine and such.
|
// Logic stuff, components, machine and such.
|
||||||
val info = new ItemUtils.MicrocontrollerData()
|
val info = new ItemUtils.MicrocontrollerData()
|
||||||
val machine = if (!world.isRemote) Machine.create(this) else null
|
val machine = if (!world.isRemote) {
|
||||||
|
val m = Machine.create(this)
|
||||||
|
m.node.asInstanceOf[Connector].setLocalBufferSize(0)
|
||||||
|
m
|
||||||
|
} else null
|
||||||
val control = if (!world.isRemote) new component.Drone(this) else null
|
val control = if (!world.isRemote) new component.Drone(this) else null
|
||||||
val components = new ComponentInventory {
|
val components = new ComponentInventory {
|
||||||
override def host = Drone.this
|
override def host = Drone.this
|
||||||
@ -111,8 +115,6 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
override def canBePushed = true
|
override def canBePushed = true
|
||||||
|
|
||||||
override def isEntityInvulnerable = super.isEntityInvulnerable
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def xPosition = posX
|
override def xPosition = posX
|
||||||
@ -200,6 +202,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
api.Network.joinNewNetwork(machine.node)
|
api.Network.joinNewNetwork(machine.node)
|
||||||
components.connectComponents()
|
components.connectComponents()
|
||||||
machine.node.connect(control.node)
|
machine.node.connect(control.node)
|
||||||
|
machine.setCostPerTick(Settings.get.droneCost)
|
||||||
}
|
}
|
||||||
|
|
||||||
def isRunning = dataWatcher.getWatchableObjectByte(2) != 0
|
def isRunning = dataWatcher.getWatchableObjectByte(2) != 0
|
||||||
@ -263,15 +266,15 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
// We're not water-proof!
|
// We're not water-proof!
|
||||||
machine.stop()
|
machine.stop()
|
||||||
}
|
}
|
||||||
machine.node.asInstanceOf[Connector].changeBuffer(100)
|
|
||||||
machine.update()
|
machine.update()
|
||||||
components.updateComponents()
|
components.updateComponents()
|
||||||
setRunning(machine.isRunning)
|
setRunning(machine.isRunning)
|
||||||
|
|
||||||
if (math.abs(lastEnergyUpdate - globalBuffer) > 50 || world.getTotalWorldTime % 200 == 0) {
|
val buffer = math.round(machine.node.asInstanceOf[Connector].globalBuffer).toInt
|
||||||
globalBuffer = math.round(machine.node.asInstanceOf[Connector].globalBuffer / 50f).toInt * 50
|
if (math.abs(lastEnergyUpdate - buffer) > 1 || world.getTotalWorldTime % 200 == 0) {
|
||||||
|
lastEnergyUpdate = buffer
|
||||||
|
globalBuffer = buffer
|
||||||
globalBufferSize = machine.node.asInstanceOf[Connector].globalBufferSize.toInt
|
globalBufferSize = machine.node.asInstanceOf[Connector].globalBufferSize.toInt
|
||||||
lastEnergyUpdate = globalBuffer
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -313,26 +316,38 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevPosX = posX
|
||||||
|
prevPosY = posY
|
||||||
|
prevPosZ = posZ
|
||||||
|
noClip = func_145771_j(posX, (boundingBox.minY + boundingBox.maxY) / 2, posZ)
|
||||||
|
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
val delta = Vec3.createVectorHelper(targetX - posX, targetY - posY, targetZ - posZ)
|
val toTarget = Vec3.createVectorHelper(targetX - posX, targetY - posY, targetZ - posZ)
|
||||||
val acceleration = math.min(targetAcceleration, delta.lengthVector())
|
val distance = toTarget.lengthVector()
|
||||||
val velocity = delta.normalize()
|
val velocity = Vec3.createVectorHelper(motionX, motionY, motionZ)
|
||||||
velocity.xCoord = motionX + velocity.xCoord * acceleration
|
if (distance > 0 && (distance > 0.005f || velocity.dotProduct(velocity) > 0.005f)) {
|
||||||
velocity.yCoord = motionY + velocity.yCoord * acceleration
|
val acceleration = math.min(targetAcceleration, distance) / distance
|
||||||
velocity.zCoord = motionZ + velocity.zCoord * acceleration
|
velocity.xCoord += toTarget.xCoord * acceleration
|
||||||
|
velocity.yCoord += toTarget.yCoord * acceleration
|
||||||
|
velocity.zCoord += toTarget.zCoord * acceleration
|
||||||
motionX = math.max(-maxVelocity, math.min(maxVelocity, velocity.xCoord))
|
motionX = math.max(-maxVelocity, math.min(maxVelocity, velocity.xCoord))
|
||||||
motionY = math.max(-maxVelocity, math.min(maxVelocity, velocity.yCoord))
|
motionY = math.max(-maxVelocity, math.min(maxVelocity, velocity.yCoord))
|
||||||
motionZ = math.max(-maxVelocity, math.min(maxVelocity, velocity.zCoord))
|
motionZ = math.max(-maxVelocity, math.min(maxVelocity, velocity.zCoord))
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
motionX = 0
|
||||||
|
motionY = 0
|
||||||
|
motionZ = 0
|
||||||
|
posX = targetX
|
||||||
|
posY = targetY
|
||||||
|
posZ = targetZ
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// No power, free fall: engage!
|
// No power, free fall: engage!
|
||||||
motionY -= gravity
|
motionY -= gravity
|
||||||
}
|
}
|
||||||
|
|
||||||
prevPosX = posX
|
|
||||||
prevPosY = posY
|
|
||||||
prevPosZ = posZ
|
|
||||||
noClip = func_145771_j(posX, (boundingBox.minY + boundingBox.maxY) / 2, posZ)
|
|
||||||
moveEntity(motionX, motionY, motionZ)
|
moveEntity(motionX, motionY, motionZ)
|
||||||
|
|
||||||
// Make sure we don't get infinitely faster.
|
// Make sure we don't get infinitely faster.
|
||||||
@ -354,16 +369,16 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
override def hitByEntity(entity: Entity) = {
|
override def hitByEntity(entity: Entity) = {
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
val direction = Vec3.createVectorHelper(entity.posX - posX, entity.posY - posY, entity.posZ - posZ).normalize()
|
val direction = Vec3.createVectorHelper(entity.posX - posX, entity.posY + entity.getEyeHeight - posY, entity.posZ - posZ).normalize()
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (Settings.get.inputUsername)
|
if (Settings.get.inputUsername)
|
||||||
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getCommandSenderName)
|
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getCommandSenderName)
|
||||||
else
|
else
|
||||||
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord))
|
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord))
|
||||||
}
|
}
|
||||||
motionX -= direction.xCoord * 0.5f
|
motionX = (motionX - direction.xCoord) * 0.5f
|
||||||
motionY -= direction.yCoord * 0.5f
|
motionY = (motionY - direction.yCoord) * 0.5f
|
||||||
motionZ -= direction.zCoord * 0.5f
|
motionZ = (motionZ - direction.zCoord) * 0.5f
|
||||||
}
|
}
|
||||||
super.hitByEntity(entity)
|
super.hitByEntity(entity)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ object DroneTemplate extends Template {
|
|||||||
data.components = items.drop(1).filter(_ != null).toArray
|
data.components = items.drop(1).filter(_ != null).toArray
|
||||||
val stack = api.Items.get("drone").createItemStack(1)
|
val stack = api.Items.get("drone").createItemStack(1)
|
||||||
data.save(stack)
|
data.save(stack)
|
||||||
val energy = Settings.get.microcontrollerBaseCost + complexity(inventory) * Settings.get.microcontrollerComplexityCost
|
val energy = Settings.get.droneBaseCost + complexity(inventory) * Settings.get.droneComplexityCost
|
||||||
|
|
||||||
Array(stack, double2Double(energy))
|
Array(stack, double2Double(energy))
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isServer && world.getWorldInfo.getWorldTotalTime % Settings.get.tickFrequency == 0) {
|
if (isServer && world.getWorldInfo.getWorldTotalTime % Settings.get.tickFrequency == 0) {
|
||||||
val charge = Settings.get.chargeRateRobot * chargeSpeed * Settings.get.tickFrequency
|
val charge = Settings.get.chargeRateExternal * chargeSpeed * Settings.get.tickFrequency
|
||||||
val canCharge = charge > 0 && node.globalBuffer >= charge
|
val canCharge = charge > 0 && node.globalBuffer >= charge
|
||||||
if (hasPower && !canCharge) {
|
if (hasPower && !canCharge) {
|
||||||
hasPower = false
|
hasPower = false
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package li.cil.oc.server.component
|
package li.cil.oc.server.component
|
||||||
|
|
||||||
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api.Network
|
import li.cil.oc.api.Network
|
||||||
import li.cil.oc.api.machine.Arguments
|
import li.cil.oc.api.machine.Arguments
|
||||||
import li.cil.oc.api.machine.Callback
|
import li.cil.oc.api.machine.Callback
|
||||||
@ -16,6 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection
|
|||||||
class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with traits.WorldControl with traits.InventoryControl with traits.InventoryWorldControl with traits.TankAware with traits.TankControl with traits.TankWorldControl {
|
class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with traits.WorldControl with traits.InventoryControl with traits.InventoryWorldControl with traits.TankAware with traits.TankControl with traits.TankWorldControl {
|
||||||
override val node = Network.newNode(this, Visibility.Network).
|
override val node = Network.newNode(this, Visibility.Network).
|
||||||
withComponent("drone").
|
withComponent("drone").
|
||||||
|
withConnector(Settings.get.bufferDrone).
|
||||||
create()
|
create()
|
||||||
|
|
||||||
override protected def position = BlockPosition(host)
|
override protected def position = BlockPosition(host)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user