本文整理汇总了Python中bravo.location.Location.save_to_packet方法的典型用法代码示例。如果您正苦于以下问题:Python Location.save_to_packet方法的具体用法?Python Location.save_to_packet怎么用?Python Location.save_to_packet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bravo.location.Location
的用法示例。
在下文中一共展示了Location.save_to_packet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestLocation
# 需要导入模块: from bravo.location import Location [as 别名]
# 或者: from bravo.location.Location import save_to_packet [as 别名]
class TestLocation(unittest.TestCase):
def setUp(self):
self.l = Location()
def test_trivial(self):
pass
def test_str(self):
str(self.l)
def test_save_to_packet(self):
self.assertTrue(self.l.save_to_packet())
def test_in_front_of(self):
other = self.l.in_front_of(1)
self.assertEqual(other.pos.x, 0)
self.assertEqual(other.pos.z, 32)
def test_in_front_of_yaw(self):
self.l.ori = Orientation.from_degs(90, 0)
other = self.l.in_front_of(1)
self.assertEqual(other.pos.x, -32)
self.assertEqual(other.pos.z, 0)
示例2: TestLocation
# 需要导入模块: from bravo.location import Location [as 别名]
# 或者: from bravo.location.Location import save_to_packet [as 别名]
class TestLocation(unittest.TestCase):
def setUp(self):
self.l = Location()
def test_trivial(self):
pass
def test_str(self):
str(self.l)
def test_clamp_stance(self):
"""
Clamped stance should be 1.62 blocks above the current block.
"""
self.l.pos = Position(0, 32, 0)
self.l.clamp()
self.assertAlmostEqual(self.l.stance, 2.62)
def test_save_to_packet(self):
self.assertTrue(self.l.save_to_packet())
def test_in_front_of(self):
other = self.l.in_front_of(1)
self.assertEqual(other.pos.x, 0)
self.assertEqual(other.pos.z, 32)
def test_in_front_of_yaw(self):
self.l.ori = Orientation.from_degs(90, 0)
other = self.l.in_front_of(1)
self.assertEqual(other.pos.x, -32)
self.assertEqual(other.pos.z, 0)
示例3: OnPlayerLocationUpdate
# 需要导入模块: from bravo.location import Location [as 别名]
# 或者: from bravo.location.Location import save_to_packet [as 别名]
def OnPlayerLocationUpdate(self, packet):
self.bot.update_location_from_packet(packet)
print packet
# everytime the player spawns, it must send back the location that it was given
# this is a check for the server. not entirely part of authentication, but
# the bot won't run without it
if self.confirmed_spawn == False:
location = Location()
location.load_from_packet(packet)
p = location.save_to_packet()
self.transport.write(p)
self.confirmed_spawn = True
self.bot.set_location(location)
self.bot.OnReady()
示例4: TestLocation
# 需要导入模块: from bravo.location import Location [as 别名]
# 或者: from bravo.location.Location import save_to_packet [as 别名]
class TestLocation(unittest.TestCase):
def setUp(self):
self.l = Location()
def test_trivial(self):
pass
def test_default_stance(self):
self.assertEqual(self.l.stance, 1.0)
def test_save_to_packet(self):
self.assertTrue(self.l.save_to_packet())
def test_distance(self):
other = Location()
other.x = 2
other.y = 3
other.z = 6
self.assertEqual(self.l.distance(other), 7)
示例5: BetaServerProtocol
# 需要导入模块: from bravo.location import Location [as 别名]
# 或者: from bravo.location.Location import save_to_packet [as 别名]
#.........这里部分代码省略.........
"""
self.transport.write(make_packet(header, **payload))
def update_ping(self):
"""
Send a keepalive to the client.
"""
timestamp = timestamp_from_clock(reactor)
self.write_packet("ping", pid=timestamp)
def update_location(self):
"""
Send this client's location to the client.
Also let other clients know where this client is.
"""
# Don't bother trying to update things if the position's not yet
# synchronized. We could end up jettisoning them into the void.
if self.state != STATE_LOCATED:
return
x, y, z = self.location.pos
yaw, pitch = self.location.ori.to_fracs()
# Inform everybody of our new location.
packet = make_packet("teleport", eid=self.player.eid, x=x, y=y, z=z,
yaw=yaw, pitch=pitch)
self.factory.broadcast_for_others(packet, self)
# Inform ourselves of our new location.
packet = self.location.save_to_packet()
self.transport.write(packet)
def ascend(self, count):
"""
Ascend to the next XZ-plane.
``count`` is the number of ascensions to perform, and may be zero in
order to force this player to not be standing inside a block.
:returns: bool of whether the ascension was successful
This client must be located for this method to have any effect.
"""
if self.state != STATE_LOCATED:
return False
x, y, z = self.location.pos.to_block()
bigx, smallx, bigz, smallz = split_coords(x, z)
chunk = self.chunks[bigx, bigz]
column = [chunk.get_block((smallx, i, smallz)) for i in range(256)]
# Special case: Ascend at most once, if the current spot isn't good.
if count == 0:
if not column[y] or column[y + 1] or column[y + 2]:
# Yeah, we're gonna need to move.
count += 1
else:
# Nope, we're fine where we are.
return True