tinting robots based on their level; including distance of zero in normal network messages to have a uniform signal signature

This commit is contained in:
Florian Nücke 2013-12-07 17:03:22 +01:00
parent eee27e49de
commit d0e97e8d4b
6 changed files with 22 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

After

Width:  |  Height:  |  Size: 926 B

View File

@ -132,7 +132,9 @@ class PacketHandler extends CommonPacketHandler {
def onRobotXp(p: PacketParser) =
p.readTileEntity[RobotProxy]() match {
case Some(t) => t.robot.xp = p.readDouble()
case Some(t) =>
t.robot.xp = p.readDouble()
t.robot.updateXpInfo()
case _ => // Invalid packet.
}

View File

@ -99,7 +99,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
compileList()
def renderChassis(isRunning: Boolean = false, offset: Double = 0) {
def renderChassis(isRunning: Boolean = false, level: Int = 0, offset: Double = 0) {
val size = 0.3f
val l = 0.5f - size
val h = 0.5f + size
@ -114,6 +114,15 @@ object RobotRenderer extends TileEntitySpecialRenderer {
}
bindTexture(texture)
if (level > 19) {
GL11.glColor3f(0.4f, 1, 1)
}
else if (level > 9) {
GL11.glColor3f(1, 1, 0.4f)
}
else {
GL11.glColor3f(0.5f, 0.5f, 0.5f)
}
if (!isRunning) {
GL11.glTranslatef(0, -2 * gap, 0)
}
@ -122,6 +131,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
GL11.glTranslatef(0, 2 * gap, 0)
}
GL11.glCallList(displayList + 1)
GL11.glColor3f(1, 1, 1)
if (MinecraftForgeClient.getRenderPass == 0) {
RenderState.disableLighting()
@ -202,7 +212,7 @@ object RobotRenderer extends TileEntitySpecialRenderer {
if (MinecraftForgeClient.getRenderPass == 0) {
val offset = timeJitter + worldTime / 20.0
renderChassis(robot.isRunning, offset)
renderChassis(robot.isRunning, robot.level, offset)
}
robot.equippedItem match {

View File

@ -98,7 +98,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
// xp(level) = base + (level * const) ^ exp
// pow(xp(level) - base, 1/exp) / const = level
level = (Math.pow(xp - Settings.get.baseXpToLevel, 1 / Settings.get.exponentialXpGrowth) / Settings.get.constantXpGrowth).toInt min 30
battery.setLocalBufferSize(Settings.get.bufferRobot + Settings.get.bufferPerLevel * level)
if (battery != null) {
battery.setLocalBufferSize(Settings.get.bufferRobot + Settings.get.bufferPerLevel * level)
}
}
// ----------------------------------------------------------------------- //
@ -337,6 +339,7 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
equippedItem = Option(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("equipped")))
}
xp = nbt.getDouble(Settings.namespace + "xp")
updateXpInfo()
animationTicksTotal = nbt.getInteger("animationTicksTotal")
animationTicksLeft = nbt.getInteger("animationTicksLeft")
moveFromX = nbt.getInteger("moveFromX")

View File

@ -49,7 +49,7 @@ abstract class GraphicsCard extends ManagedComponent {
def bind(context: Context, args: Arguments): Array[AnyRef] = {
val address = args.checkString(0)
node.network.node(address) match {
case null => Array(Unit, "invalid address")
case null => result(false, "invalid address")
case node: Node if node.host.isInstanceOf[Buffer] =>
screenAddress = Option(address)
screenInstance = Some(node.host.asInstanceOf[Buffer])
@ -62,7 +62,7 @@ abstract class GraphicsCard extends ManagedComponent {
s.background = 0x000000
result(true)
})
case _ => Array(Unit, "not a screen")
case _ => result(false, "not a screen")
}
}

View File

@ -75,7 +75,7 @@ class NetworkCard extends ManagedComponent {
openPorts.clear()
if (message.name == "network.message") message.data match {
case Array(port: Integer, args@_*) if openPorts.contains(port) =>
node.sendToReachable("computer.signal", Seq("modem_message", message.source.address, Int.box(port)) ++ args: _*)
node.sendToReachable("computer.signal", Seq("modem_message", message.source.address, Int.box(port), Int.box(0)) ++ args: _*)
case _ =>
}
}