本文整理汇总了Python中srctools.Vec.localise方法的典型用法代码示例。如果您正苦于以下问题:Python Vec.localise方法的具体用法?Python Vec.localise怎么用?Python Vec.localise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类srctools.Vec
的用法示例。
在下文中一共展示了Vec.localise方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: res_make_funnel_light
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def res_make_funnel_light(inst: Entity):
"""Place a light for Funnel items."""
oran_on = inst.fixup.bool('$start_reversed')
need_blue = need_oran = False
name = ''
if inst.fixup['$connectioncount_polarity'] != '0':
import vbsp
if not vbsp.settings['style_vars']['funnelallowswitchedlights']:
# Allow disabling adding switchable lights.
return
name = conditions.local_name(inst, 'light')
need_blue = need_oran = True
else:
if oran_on:
need_oran = True
else:
need_blue = True
loc = Vec(0, 0, -56)
loc.localise(Vec.from_str(inst['origin']), Vec.from_str(inst['angles']))
if need_blue:
inst.map.create_ent(
classname='light',
targetname=name + '_b' if name else '',
spawnflags=int(oran_on), # 1 = Initially Dark
origin=loc,
_light='50 120 250 50',
_lightHDR='-1 -1 -1 1',
_lightscaleHDR=2,
_fifty_percent_distance=48,
_zero_percent_distance=96,
_hardfalloff=1,
_distance=0,
style=0,
)
if need_oran:
inst.map.create_ent(
classname='light',
targetname=name + '_o' if name else '',
spawnflags=int(not oran_on),
origin=loc,
_light='250 120 50 50',
_lightHDR='-1 -1 -1 1',
_lightscaleHDR=2,
_fifty_percent_distance=48,
_zero_percent_distance=96,
_hardfalloff=1,
_distance=0,
style=0,
)
示例2: res_monitor
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def res_monitor(inst: Entity, res: Property) -> None:
"""Result for the monitor component.
"""
import vbsp
(
break_inst,
bullseye_name,
bullseye_loc,
bullseye_parent,
) = res.value
ALL_MONITORS.append(Monitor(inst))
has_laser = vbsp.settings['has_attr']['laser']
# Allow turrets if the monitor is setup to allow it, and the actor should
# be shot.
needs_turret = bullseye_name and vbsp_options.get(bool, 'voice_studio_should_shoot')
inst.fixup['$is_breakable'] = has_laser or needs_turret
# We need to generate an ai_relationship, which makes turrets hate
# a bullseye.
if needs_turret:
loc = Vec(bullseye_loc)
loc.localise(
Vec.from_str(inst['origin']),
Vec.from_str(inst['angles']),
)
bullseye_name = local_name(inst, bullseye_name)
inst.map.create_ent(
classname='npc_bullseye',
targetname=bullseye_name,
parentname=local_name(inst, bullseye_parent),
spawnflags=221186, # Non-solid, invisible, etc..
origin=loc,
)
relation = inst.map.create_ent(
classname='ai_relationship',
targetname='@monitor_turr_hate',
spawnflags=2, # Notify turrets about monitor locations
disposition=1, # Hate
origin=loc,
subject='npc_portal_turret_floor',
target=bullseye_name,
)
MONITOR_RELATIONSHIP_ENTS.append(relation)
示例3: mon_remove_bullseyes
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def mon_remove_bullseyes(inst: Entity) -> Optional[object]:
"""Remove bullsyes used for cameras."""
if not BULLSYE_LOCS:
return RES_EXHAUSTED
if inst['file'].casefold() not in instanceLocs.resolve('<ITEM_CATAPULT_TARGET>'):
return
origin = Vec(0, 0, -64)
origin.localise(Vec.from_str(inst['origin']), Vec.from_str(inst['angles']))
origin = origin.as_tuple()
LOGGER.info('Pos: {} -> ', origin, BULLSYE_LOCS[origin])
if BULLSYE_LOCS[origin]:
BULLSYE_LOCS[origin] -= 1
inst.remove()
示例4: resolve_offset
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def resolve_offset(inst, value: str, scale: float=1, zoff: float=0) -> Vec:
"""Retrieve an offset from an instance var. This allows several special values:
* $var to read from a variable
* <piston_start> or <piston> to get the unpowered position of a piston plat
* <piston_end> to get the powered position of a piston plat
* <piston_top> to get the extended position of a piston plat
* <piston_bottom> to get the retracted position of a piston plat
If scale is set, read values are multiplied by this, and zoff is added to Z.
"""
value = value.casefold()
# Offset the overlay by the given distance
# Some special placeholder values:
if value == '<piston_start>' or value == '<piston>':
if inst.fixup.bool(const.FixupVars.PIST_IS_UP):
value = '<piston_top>'
else:
value = '<piston_bottom>'
elif value == '<piston_end>':
if inst.fixup.bool(const.FixupVars.PIST_IS_UP):
value = '<piston_bottom>'
else:
value = '<piston_top>'
if value == '<piston_bottom>':
offset = Vec(
z=inst.fixup.int(const.FixupVars.PIST_BTM) * 128,
)
elif value == '<piston_top>':
offset = Vec(
z=inst.fixup.int(const.FixupVars.PIST_TOP) * 128,
)
else:
# Regular vector
offset = Vec.from_str(resolve_value(inst, value)) * scale
offset.z += zoff
offset.localise(
Vec.from_str(inst['origin']),
Vec.from_str(inst['angles']),
)
return offset
示例5: res_cutout_tile
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def res_cutout_tile(vmf: srctools.VMF, res: Property):
"""Generate random quarter tiles, like in Destroyed or Retro maps.
- "MarkerItem" is the instance to look for.
- "TileSize" can be "2x2" or "4x4".
- rotateMax is the amount of degrees to rotate squarebeam models.
Materials:
- "squarebeams" is the squarebeams variant to use.
- "ceilingwalls" are the sides of the ceiling section.
- "floorbase" is the texture under floor sections.
- "tile_glue" is used on top of a thinner tile segment.
- "clip" is the player_clip texture used over floor segments.
(This allows customising the surfaceprop.)
- "Floor4x4Black", "Ceil2x2White" and other combinations can be used to
override the textures used.
"""
marker_filenames = instanceLocs.resolve(res['markeritem'])
INST_LOCS = {} # Map targetnames -> surface loc
CEIL_IO = [] # Pairs of ceil inst corners to cut out.
FLOOR_IO = [] # Pairs of floor inst corners to cut out.
overlay_ids = {} # When we replace brushes, we need to fix any overlays
# on that surface.
MATS.clear()
floor_edges = [] # Values to pass to add_floor_sides() at the end
sign_locs = set()
# If any signage is present in the map, we need to force tiles to
# appear at that location!
for over in vmf.by_class['info_overlay']:
if (
over['material'].casefold() in FORCE_TILE_MATS and
# Only check floor/ceiling overlays
over['basisnormal'] in ('0 0 1', '0 0 -1')
):
add_signage_loc(sign_locs, Vec.from_str(over['origin']))
for item in connections.ITEMS.values():
for ind_pan in item.ind_panels:
loc = Vec(0, 0, -64)
loc.localise(
Vec.from_str(ind_pan['origin']),
Vec.from_str(ind_pan['angles']),
)
add_signage_loc(sign_locs, loc)
SETTINGS = {
'floor_chance': srctools.conv_int(
res['floorChance', '100'], 100),
'ceil_chance': srctools.conv_int(
res['ceilingChance', '100'], 100),
'floor_glue_chance': srctools.conv_int(
res['floorGlueChance', '0']),
'ceil_glue_chance': srctools.conv_int(
res['ceilingGlueChance', '0']),
'rotate_beams': int(srctools.conv_float(
res['rotateMax', '0']) * BEAM_ROT_PRECISION),
'beam_skin': res['squarebeamsSkin', '0'],
'base_is_disp': srctools.conv_bool(res['dispBase', '0']),
'quad_floor': res['FloorSize', '4x4'].casefold() == '2x2',
'quad_ceil': res['CeilingSize', '4x4'].casefold() == '2x2',
}
random.seed(vbsp.MAP_RAND_SEED + '_CUTOUT_TILE_NOISE')
noise = SimplexNoise(period=4 * 40) # 4 tiles/block, 50 blocks max
# We want to know the number of neighbouring tile cutouts before
# placing tiles - blocks away from the sides generate fewer tiles.
floor_neighbours = defaultdict(dict) # all_floors[z][x,y] = count
for mat_prop in res.find_key('Materials', []):
MATS[mat_prop.name].append(mat_prop.value)
if SETTINGS['base_is_disp']:
# We want the normal brushes to become nodraw.
MATS['floorbase_disp'] = MATS['floorbase']
MATS['floorbase'] = ['tools/toolsnodraw']
# Since this uses random data for initialisation, the alpha and
# regular will use slightly different patterns.
alpha_noise = SimplexNoise(period=4 * 50)
else:
alpha_noise = None
for key, default in TEX_DEFAULT:
if key not in MATS:
MATS[key] = [default]
# Find our marker ents
for inst in vmf.by_class['func_instance']:
if inst['file'].casefold() not in marker_filenames:
continue
targ = inst['targetname']
#.........这里部分代码省略.........
示例6: res_water_splash
# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import localise [as 别名]
def res_water_splash(vmf: VMF, inst: Entity, res: Property):
"""Creates splashes when something goes in and out of water.
Arguments:
- parent: The name of the parent entity.
- name: The name given to the env_splash.
- scale: The size of the effect (8 by default).
- position: The offset position to place the entity.
- position2: The offset to which the entity will move.
- type: Use certain fixup values to calculate pos2 instead:
'piston_1/2/3/4': Use $bottom_level and $top_level as offsets.
'track_platform': Use $travel_direction, $travel_distance, etc.
- fast_check: Check faster for movement. Needed for items which
move quickly.
"""
(
name,
parent,
scale,
pos1,
pos2,
calc_type,
fast_check,
) = res.value # type: str, str, float, Vec, str, str
pos1 = pos1.copy() # type: Vec
splash_pos = pos1.copy() # type: Vec
if calc_type == 'track_platform':
lin_off = srctools.conv_int(inst.fixup['$travel_distance'])
travel_ang = inst.fixup['$travel_direction']
start_pos = srctools.conv_float(inst.fixup['$starting_position'])
if start_pos:
start_pos = round(start_pos * lin_off)
pos1 += Vec(x=-start_pos).rotate_by_str(travel_ang)
pos2 = Vec(x=lin_off).rotate_by_str(travel_ang)
pos2 += pos1
elif calc_type.startswith('piston'):
# Use piston-platform offsetting.
# The number is the highest offset to move to.
max_pist = srctools.conv_int(calc_type.split('_', 2)[1], 4)
bottom_pos = srctools.conv_int(inst.fixup['$bottom_level'])
top_pos = min(srctools.conv_int(inst.fixup['$top_level']), max_pist)
pos2 = pos1.copy()
pos1 += Vec(z=128 * bottom_pos)
pos2 += Vec(z=128 * top_pos)
LOGGER.info('Bottom: {}, top: {}', bottom_pos, top_pos)
else:
# Directly from the given value.
pos2 = Vec.from_str(conditions.resolve_value(inst, pos2))
origin = Vec.from_str(inst['origin'])
angles = Vec.from_str(inst['angles'])
splash_pos.localise(origin, angles)
pos1.localise(origin, angles)
pos2.localise(origin, angles)
# Since it's a straight line and you can't go through walls,
# if pos1 and pos2 aren't in goo we aren't ever in goo.
check_pos = [pos1, pos2]
if pos1.z < origin.z:
# If embedding in the floor, the positions can both be below the
# actual surface. In that case check the origin too.
check_pos.append(Vec(pos1.x, pos1.y, origin.z))
for pos in check_pos:
grid_pos = pos // 128 * 128 # type: Vec
grid_pos += (64, 64, 64)
try:
surf = conditions.GOO_LOCS[grid_pos.as_tuple()]
except KeyError:
continue
break
else:
return # Not in goo at all
if pos1.z == pos2.z:
# Flat - this won't do anything...
return
water_pos = surf.get_origin()
# Check if both positions are above or below the water..
# that means it won't ever trigger.
LOGGER.info('pos1: {}, pos2: {}, water_pos: {}', pos1.z, pos2.z, water_pos.z)
if max(pos1.z, pos2.z) < water_pos.z - 8:
return
if min(pos1.z, pos2.z) > water_pos.z + 8:
return
# Pass along the water_pos encoded into the targetname.
# Restrict the number of characters to allow direct slicing
# in the script.
enc_data = '_{:09.3f}{}'.format(
water_pos.z + 12,
'f' if fast_check else 's',
#.........这里部分代码省略.........