本文整理匯總了Python中srctools.Vec.copy方法的典型用法代碼示例。如果您正苦於以下問題:Python Vec.copy方法的具體用法?Python Vec.copy怎麽用?Python Vec.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類srctools.Vec
的用法示例。
在下文中一共展示了Vec.copy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: find_glass_items
# 需要導入模塊: from srctools import Vec [as 別名]
# 或者: from srctools.Vec import copy [as 別名]
def find_glass_items(config, vmf: VMF) -> Iterator[Tuple[str, Vec, Vec, Vec, dict]]:
"""Find the bounding boxes for all the glass items matching a config.
This yields (targetname, min, max, normal, config) tuples.
"""
# targetname -> min, max, normal, config
glass_items = {}
for inst in vmf.by_class['func_instance']: # type: Entity
try:
conf = config[inst['file'].casefold()]
except KeyError:
continue
targ = inst['targetname']
norm = Vec(x=1).rotate_by_str(inst['angles'])
origin = Vec.from_str(inst['origin']) - 64 * norm
try:
bbox_min, bbox_max, group_norm, group_conf = glass_items[targ]
except KeyError:
# First of this group..
bbox_min, bbox_max = origin.copy(), origin.copy()
group_norm = norm.copy()
glass_items[targ] = bbox_min, bbox_max, group_norm, conf
else:
bbox_min.min(origin)
bbox_max.max(origin)
assert group_norm == norm, '"{}" is inconsistently rotated!'.format(targ)
assert group_conf is conf, '"{}" has multiple configs!'.format(targ)
inst.remove()
for targ, (bbox_min, bbox_max, norm, conf) in glass_items.items():
yield targ, bbox_min, bbox_max, norm, conf
示例2: res_antlaser
# 需要導入模塊: from srctools import Vec [as 別名]
# 或者: from srctools.Vec import copy [as 別名]
#.........這裏部分代碼省略.........
node.delete_antlines()
# Do the same for inputs, so we can catch that.
for conn in list(node.inputs):
neighbour = conn.from_item
todo.discard(neighbour)
pair_state = node_pairing.get(neighbour, None)
if pair_state is None:
# Not a node, an input to the group.
conn.to_item = group.item
continue
elif pair_state is False:
# Another node.
group.nodes.append(neighbour)
# else: True, node already added.
# For nodes, connect link.
conn.remove()
group.links.add(frozenset({neighbour, node}))
# Now every node is in a group. Generate the actual entities.
for group in groups:
# We generate two ent types. For each marker, we add a sprite
# and a beam pointing at it. Then for each connection
# another beam.
# Choose a random antlaser name to use for our group.
base_name = group.nodes[0].name
out_enable = [Output('', '', 'FireUser2')]
out_disable = [Output('', '', 'FireUser1')]
for output in conf_outputs:
if output.output.casefold() == 'onenabled':
out_enable.append(output.copy())
else:
out_disable.append(output.copy())
if conf_toggle_targ:
# Make the group info_target into a texturetoggle.
toggle = group.item.inst
toggle['classname'] = 'env_texturetoggle'
toggle['target'] = conditions.local_name(group.nodes[0].inst, conf_toggle_targ)
group.item.enable_cmd = tuple(out_enable)
group.item.disable_cmd = tuple(out_disable)
# Node -> index for targetnames.
indexes = {} # type: Dict[Item, int]
# For cables, it's a bit trickier than the beams.
# The cable ent itself is the one which decides what it links to,
# so we need to potentially make endpoint cables at locations with
# only "incoming" lines.
# So this dict is either a targetname to indicate cables with an
# outgoing connection, or the entity for endpoints without an outgoing
# connection.
cable_points = {} # type: Dict[Item, Union[Entity, str]]
for i, node in enumerate(group.nodes, start=1):
indexes[node] = i
node.name = base_name
sprite_pos = conf_glow_height.copy()
sprite_pos.localise(
Vec.from_str(node.inst['origin']),
Vec.from_str(node.inst['angles']),