本文整理汇总了Python中srctools.Vec.iter_grid方法的典型用法代码示例。如果您正苦于以下问题:Python Vec.iter_grid方法的具体用法?Python Vec.iter_grid怎么用?Python Vec.iter_grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类srctools.Vec
的用法示例。
在下文中一共展示了Vec.iter_grid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flag_blockpos_type
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import iter_grid [as 别名]
def flag_blockpos_type(inst: Entity, flag: Property):
"""Determine the type of a grid position.
If the value is single value, that should be the type.
Otherwise, the value should be a block with 'offset' and 'type' values.
The offset is in block increments, with 0 0 0 equal to the mounting surface.
If 'offset2' is also provided, all positions in the bounding box will
be checked.
The type should be a space-seperated list of locations:
* `VOID` (Outside the map)
* `SOLID` (Full wall cube)
* `EMBED` (Hollow wall cube)
* `AIR` (Inside the map, may be occupied by items)
* `OCCUPIED` (Known to be occupied by items)
* `PIT` (Bottomless pits, any)
* `PIT_SINGLE` (one-high)
* `PIT_TOP`
* `PIT_MID`
* `PIT_BOTTOM`
* `GOO`
* `GOO_SINGLE` (one-deep goo)
* `GOO_TOP` (goo surface)
* `GOO_MID`
* `GOO_BOTTOM` (floor)
"""
pos2 = None
if flag.has_children():
pos1 = resolve_offset(inst, flag['offset', '0 0 0'], scale=128, zoff=-128)
types = flag['type'].split()
if 'offset2' in flag:
pos2 = resolve_offset(inst, flag.value, scale=128, zoff=-128)
else:
types = flag.value.split()
pos1 = Vec()
if pos2 is not None:
bbox = Vec.iter_grid(*Vec.bbox(pos1, pos2), stride=128)
else:
bbox = [pos1]
for pos in bbox:
block = brushLoc.POS['world': pos]
for block_type in types:
try:
allowed = brushLoc.BLOCK_LOOKUP[block_type.casefold()]
except KeyError:
raise ValueError('"{}" is not a valid block type!'.format(block_type))
if block in allowed:
break # To next position
else:
return False # Didn't match any in this list.
return True # Matched all positions.
示例2: list
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import iter_grid [as 别名]
)
# Position -> entity
# We merge ones within 3 blocks of our item.
CHECKPOINT_TRIG = {} # type: Dict[Tuple[float, float, float], Entity]
# Approximately a 3-distance from
# the center.
# x
# xxx
# xx xx
# xxx
# x
CHECKPOINT_NEIGHBOURS = list(Vec.iter_grid(
Vec(-128, -128, 0),
Vec(128, 128, 0),
stride=128,
))
CHECKPOINT_NEIGHBOURS.extend([
Vec(-256, 0, 0),
Vec(256, 0, 0),
Vec(0, -256, 0),
Vec(0, 256, 0),
])
# Don't include ourself..
CHECKPOINT_NEIGHBOURS.remove(Vec(0, 0, 0))
@make_result('CheckpointTrigger')
def res_checkpoint_trigger(inst: Entity, res: Property):
"""Generate a trigger underneath coop checkpoint items