本文整理汇总了Python中srctools.Property.bool方法的典型用法代码示例。如果您正苦于以下问题:Python Property.bool方法的具体用法?Python Property.bool怎么用?Python Property.bool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类srctools.Property
的用法示例。
在下文中一共展示了Property.bool方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def parse(cls, conf: Property) -> 'FizzlerBrush':
"""Parse from a config file."""
if 'side_color' in conf:
side_color = conf.vec('side_color')
else:
side_color = None
outputs = [
Output.parse(prop)
for prop in
conf.find_children('Outputs')
]
textures = {}
for group in TexGroup:
textures[group] = conf['tex_' + group.value, None]
keys = {
prop.name: prop.value
for prop in
conf.find_children('keys')
}
local_keys = {
prop.name: prop.value
for prop in
conf.find_children('localkeys')
}
if 'classname' not in keys:
raise ValueError(
'Fizzler Brush "{}" does not have a classname!'.format(
conf['name'],
)
)
return FizzlerBrush(
name=conf['name'],
textures=textures,
keys=keys,
local_keys=local_keys,
outputs=outputs,
thickness=conf.float('thickness', 2.0),
stretch_center=conf.bool('stretch_center', True),
side_color=side_color,
singular=conf.bool('singular'),
mat_mod_name=conf['mat_mod_name', None],
mat_mod_var=conf['mat_mod_var', None],
set_axis_var=conf.bool('set_axis_var'),
)
示例2: parse
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def parse(prop: Property):
"""Parse from property values.
The value can be in four forms:
"prop" "material"
"prop" "<scale>|material"
"prop" "<scale>|material|static"
"prop"
{
"tex" "<mat>"
"scale" "<scale>"
"static" "<is_static>"
}
"""
if prop.has_children():
tex = prop['tex']
scale = prop.float('scale', 0.25)
static = prop.bool('static')
else:
vals = prop.value.split('|')
opts = ()
scale_str = '0.25'
if len(vals) == 2:
scale_str, tex = vals
elif len(vals) > 2:
scale_str, tex, *opts = vals
else:
# Unpack to ensure it only has 1 section
[tex] = vals
scale = conv_float(scale_str, 0.25)
static = 'static' in opts
return AntTex(tex, scale, static)
示例3: res_calc_opposite_wall_dist
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_calc_opposite_wall_dist(inst: Entity, res: Property):
"""Calculate the distance between this item and the opposing wall.
The value is stored in the `$var` specified by the property value.
Alternately it is set by `ResultVar`, and `offset` adds or subtracts to the value.
`GooCollide` means that it will stop when goo is found, otherwise it is
ignored.
`GooAdjust` means additionally if the space is goo, the distance will
be modified so that it specifies the surface of the goo.
"""
if res.has_children():
result_var = res['ResultVar']
dist_off = res.float('offset')
collide_goo = res.bool('GooCollide')
adjust_goo = res.bool('GooAdjust')
else:
result_var = res.value
dist_off = 0
collide_goo = adjust_goo = False
origin = Vec.from_str(inst['origin'])
normal = Vec(z=1).rotate_by_str(inst['angles'])
mask = [
brushLoc.Block.SOLID,
brushLoc.Block.EMBED,
brushLoc.Block.PIT_BOTTOM,
brushLoc.Block.PIT_SINGLE,
]
# Only if actually downward.
if normal == (0, 0, -1) and collide_goo:
mask.append(brushLoc.Block.GOO_TOP)
mask.append(brushLoc.Block.GOO_SINGLE)
opposing_pos = brushLoc.POS.raycast_world(
origin,
normal,
mask,
)
if adjust_goo and brushLoc.POS['world': opposing_pos + 128*normal].is_goo:
# If the top is goo, adjust so the 64 below is the top of the goo.
dist_off += 32
inst.fixup[result_var] = (origin - opposing_pos).mag() + dist_off
示例4: res_make_tag_coop_spawn
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_make_tag_coop_spawn(vmf: VMF, inst: Entity, res: Property):
"""Create the spawn point for ATLAS in the entry corridor.
It produces either an instance or the normal spawn entity. This is required since ATLAS may need to have the paint gun logic.
The two parameters `origin` and `facing` must be set to determine the required position.
If `global` is set, the spawn point will be absolute instead of relative to the current instance.
"""
if vbsp.GAME_MODE != 'COOP':
return RES_EXHAUSTED
is_tag = vbsp_options.get(str, 'game_id') == utils.STEAM_IDS['TAG']
origin = res.vec('origin')
normal = res.vec('facing', z=1)
# Some styles might want to ignore the instance we're running on.
if not res.bool('global'):
origin = origin.rotate_by_str(inst['angles'])
normal = normal.rotate_by_str(inst['angles'])
origin += Vec.from_str(inst['origin'])
angles = normal.to_angle()
if is_tag:
vmf.create_ent(
classname='func_instance',
targetname='paint_gun',
origin=origin - (0, 0, 16),
angles=angles,
# Generated by the BEE2 app.
file='instances/bee2/tag_coop_gun.vmf',
)
# Blocks ATLAS from having a gun
vmf.create_ent(
classname='info_target',
targetname='supress_blue_portalgun_spawn',
origin=origin,
angles='0 0 0',
)
# Allows info_target to work
vmf.create_ent(
classname='env_global',
targetname='no_spawns',
globalstate='portalgun_nospawn',
initialstate=1,
spawnflags=1, # Use initial state
origin=origin,
)
vmf.create_ent(
classname='info_coop_spawn',
targetname='@coop_spawn_blue',
ForceGunOnSpawn=int(not is_tag),
origin=origin,
angles=angles,
enabled=1,
StartingTeam=3, # ATLAS
)
return RES_EXHAUSTED
示例5: res_cust_antline_setup
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_cust_antline_setup(res: Property):
if 'wall' in res:
wall_type = antlines.AntType.parse(res.find_key('wall'))
else:
wall_type = None
if 'floor' in res:
floor_type = antlines.AntType.parse(res.find_key('floor'))
else:
floor_type = wall_type
return (
wall_type,
floor_type,
res.bool('remove_signs'),
res['toggle_var', ''],
)
示例6: res_match_item_config
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_match_item_config(inst: Entity, res: Property) -> bool:
"""Check if an item config panel value matches another value.
* `ID` is the ID of the group.
* `Name` is the name of the widget.
* If `UseTimer` is true, it uses `$timer_delay` to choose the value to use.
* `Value` is the value to compare to.
"""
group_id = res['ID']
wid_name = res['Name'].casefold()
desired_value = res['Value']
if res.bool('UseTimer'):
timer_delay = inst.fixup.int('$timer_delay')
else:
timer_delay = None
conf = vbsp_options.get_itemconf((group_id, wid_name), None, timer_delay)
if conf is None: # Doesn't exist
return False
return conf == desired_value
示例7: res_add_global_inst
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_add_global_inst(res: Property):
"""Add one instance in a specific location.
Options:
`allow_multiple`: Allow multiple copies of this instance. If 0, the
instance will not be added if it was already added.
`name`: The targetname of the instance. If blank, the instance will
be given a name of the form `inst_1234`.
`file`: The filename for the instance.
`angles`: The orientation of the instance (defaults to `0 0 0`).
`fixup_style`: The Fixup style for the instance. `0` (default) is
Prefix, `1` is Suffix, and `2` is None.
`position`: The location of the instance. If not set, it will be placed
in a 128x128 nodraw room somewhere in the map. Objects which can
interact with nearby object should not be placed there.
"""
if not res.has_children():
res = Property('AddGlobal', [Property('File', res.value)])
if res.bool('allow_multiple') or res['file'] not in GLOBAL_INSTANCES:
# By default we will skip adding the instance
# if was already added - this is helpful for
# items that add to original items, or to avoid
# bugs.
new_inst = vbsp.VMF.create_ent(
classname="func_instance",
targetname=res['name', ''],
file=instanceLocs.resolve_one(res['file'], error=True),
angles=res['angles', '0 0 0'],
fixup_style=res['fixup_style', '0'],
)
try:
new_inst['origin'] = res['position']
except IndexError:
new_inst['origin'] = vbsp_options.get(Vec, 'global_ents_loc')
GLOBAL_INSTANCES.add(res['file'])
if new_inst['targetname'] == '':
new_inst['targetname'] = "inst_"
new_inst.make_unique()
return RES_EXHAUSTED
示例8: res_item_config_to_fixup
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_item_config_to_fixup(inst: Entity, res: Property):
"""Load a config from the item config panel onto a fixup.
* `ID` is the ID of the group.
* `Name` is the name of the widget.
* `resultVar` is the location to store the value into.
* If `UseTimer` is true, it uses `$timer_delay` to choose the value to use.
* `Default` is the default value, if the config isn't found.
"""
group_id = res['ID']
wid_name = res['Name']
default = res['default']
if res.bool('UseTimer'):
timer_delay = inst.fixup.int('$timer_delay')
else:
timer_delay = None
inst.fixup[res['ResultVar']] = vbsp_options.get_itemconf(
(group_id, wid_name),
default,
timer_delay,
)
示例9: res_resizeable_trigger
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_resizeable_trigger(vmf: VMF, res: Property):
"""Replace two markers with a trigger brush.
This is run once to affect all of an item.
Options:
* `markerInst`: <ITEM_ID:1,2> value referencing the marker instances, or a filename.
* `markerItem`: The item's ID
* `previewConf`: A item config which enables/disables the preview overlay.
* `previewInst`: An instance to place at the marker location in preview mode.
This should contain checkmarks to display the value when testing.
* `previewMat`: If set, the material to use for an overlay func_brush.
The brush will be parented to the trigger, so it vanishes once killed.
It is also non-solid.
* `previewScale`: The scale for the func_brush materials.
* `previewActivate`, `previewDeactivate`: The VMF output to turn the
previewInst on and off.
* `triggerActivate, triggerDeactivate`: The `instance:name;Output`
outputs used when the trigger turns on or off.
* `coopVar`: The instance variable which enables detecting both Coop players.
The trigger will be a trigger_playerteam.
* `coopActivate, coopDeactivate`: The `instance:name;Output` outputs used
when coopVar is enabled. These should be suitable for a logic_coop_manager.
* `coopOnce`: If true, kill the manager after it first activates.
* `keys`: A block of keyvalues for the trigger brush. Origin and targetname
will be set automatically.
* `localkeys`: The same as above, except values will be changed to use
instance-local names.
"""
marker = instanceLocs.resolve(res['markerInst'])
marker_names = set()
for inst in vmf.by_class['func_instance']:
if inst['file'].casefold() in marker:
marker_names.add(inst['targetname'])
# Unconditionally delete from the map, so it doesn't
# appear even if placed wrongly.
inst.remove()
if not marker_names: # No markers in the map - abort
return RES_EXHAUSTED
item_id = res['markerItem']
# Synthesise the item type used for the final trigger.
item_type_sp = connections.ItemType(
id=item_id + ':TRIGGER',
output_act=Output.parse_name(res['triggerActivate', 'OnStartTouchAll']),
output_deact=Output.parse_name(res['triggerDeactivate', 'OnEndTouchAll']),
)
# For Coop, we add a logic_coop_manager in the mix so both players can
# be handled.
try:
coop_var = res['coopVar']
except LookupError:
coop_var = item_type_coop = None
coop_only_once = False
else:
coop_only_once = res.bool('coopOnce')
item_type_coop = connections.ItemType(
id=item_id + ':TRIGGER_COOP',
output_act=Output.parse_name(
res['coopActivate', 'OnChangeToAllTrue']
),
output_deact=Output.parse_name(
res['coopDeactivate', 'OnChangeToAnyFalse']
),
)
# Display preview overlays if it's preview mode, and the config is true
pre_act = pre_deact = None
if vbsp.IS_PREVIEW and vbsp_options.get_itemconf(res['previewConf', ''], False):
preview_mat = res['previewMat', '']
preview_inst_file = res['previewInst', '']
preview_scale = res.float('previewScale', 0.25)
# None if not found.
with suppress(LookupError):
pre_act = Output.parse(res.find_key('previewActivate'))
with suppress(LookupError):
pre_deact = Output.parse(res.find_key('previewDeactivate'))
else:
# Deactivate the preview_ options when publishing.
preview_mat = preview_inst_file = ''
preview_scale = 0.25
# Now go through each brush.
# We do while + pop to allow removing both names each loop through.
todo_names = set(marker_names)
while todo_names:
targ = todo_names.pop()
mark1 = connections.ITEMS.pop(targ)
for conn in mark1.outputs:
if conn.to_item.name in marker_names:
mark2 = conn.to_item
#.........这里部分代码省略.........
示例10: res_add_overlay_inst
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def res_add_overlay_inst(inst: Entity, res: Property):
"""Add another instance on top of this one.
Values:
File: The filename.
Fixup Style: The Fixup style for the instance. '0' (default) is
Prefix, '1' is Suffix, and '2' is None.
Copy_Fixup: If true, all the $replace values from the original
instance will be copied over.
move_outputs: If true, outputs will be moved to this instance.
offset: The offset (relative to the base) that the instance
will be placed. Can be set to '<piston_top>' and
'<piston_bottom>' to offset based on the configuration.
'<piston_start>' will set it to the starting position, and
'<piston_end>' will set it to the ending position.
of piston platform handles.
angles: If set, overrides the base instance angles. This does
not affect the offset property.
fixup/localfixup: Keyvalues in this block will be copied to the
overlay entity.
If the value starts with $, the variable will be copied over.
If this is present, copy_fixup will be disabled.
"""
angle = res["angles", inst["angles", "0 0 0"]]
overlay_inst = vbsp.VMF.create_ent(
classname="func_instance",
targetname=inst["targetname", ""],
file=resolve_inst(res["file", ""])[0],
angles=angle,
origin=inst["origin"],
fixup_style=res["fixup_style", "0"],
)
# Don't run if the fixup block exists..
if srctools.conv_bool(res["copy_fixup", "1"]):
if "fixup" not in res and "localfixup" not in res:
# Copy the fixup values across from the original instance
for fixup, value in inst.fixup.items():
overlay_inst.fixup[fixup] = value
conditions.set_ent_keys(overlay_inst.fixup, inst, res, "fixup")
if res.bool("move_outputs", False):
overlay_inst.outputs = inst.outputs
inst.outputs = []
if "offset" in res:
folded_off = res["offset"].casefold()
# Offset the overlay by the given distance
# Some special placeholder values:
if folded_off == "<piston_start>":
if srctools.conv_bool(inst.fixup["$start_up", ""]):
folded_off = "<piston_top>"
else:
folded_off = "<piston_bottom>"
elif folded_off == "<piston_end>":
if srctools.conv_bool(inst.fixup["$start_up", ""]):
folded_off = "<piston_bottom>"
else:
folded_off = "<piston_top>"
if folded_off == "<piston_bottom>":
offset = Vec(z=srctools.conv_int(inst.fixup["$bottom_level"]) * 128)
elif folded_off == "<piston_top>":
offset = Vec(z=srctools.conv_int(inst.fixup["$top_level"], 1) * 128)
else:
# Regular vector
offset = Vec.from_str(conditions.resolve_value(inst, res["offset"]))
offset.rotate_by_str(inst["angles", "0 0 0"])
overlay_inst["origin"] = (offset + Vec.from_str(inst["origin"])).join(" ")
return overlay_inst
示例11: res_track_plat
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
#.........这里部分代码省略.........
# The direction away from the wall/floor/ceil
normal = Vec(0, 0, 1).rotate_by_str(
plat_inst['angles']
)
for tr_origin, first_track in track_instances.items():
if plat_loc == tr_origin:
# Check direction
if normal == Vec(0, 0, 1).rotate(
*Vec.from_str(first_track['angles'])
):
break
else:
raise Exception('Platform "{}" has no track!'.format(
plat_inst['targetname']
))
track_type = first_track['file'].casefold()
if track_type == inst_single:
# Track is one block long, use a single-only instance and
# remove track!
plat_inst['file'] = single_plat_inst
first_track.remove()
continue # Next platform
track_set = set() # type: Set[Entity]
if track_type == inst_top or track_type == inst_middle:
# search left
track_scan(
track_set,
track_instances,
first_track,
middle_file=inst_middle,
x_dir=-1,
)
if track_type == inst_bottom or track_type == inst_middle:
# search right
track_scan(
track_set,
track_instances,
first_track,
middle_file=inst_middle,
x_dir=+1,
)
# Give every track a targetname matching the platform
for ind, track in enumerate(track_set, start=1):
if track_targets == '':
track['targetname'] = plat_inst['targetname']
else:
track['targetname'] = (
plat_inst['targetname'] +
'-' +
track_targets + str(ind)
)
# Now figure out which way the track faces:
# The direction of the platform surface
facing = Vec(-1, 0, 0).rotate_by_str(plat_inst['angles'])
# The direction horizontal track is offset
uaxis = Vec(x=1).rotate_by_str(first_track['angles'])
vaxis = Vec(y=1).rotate_by_str(first_track['angles'])
if uaxis == facing:
plat_facing = 'vert'
track_facing = 'E'
elif uaxis == -facing:
plat_facing = 'vert'
track_facing = 'W'
elif vaxis == facing:
plat_facing = 'horiz'
track_facing = 'N'
elif vaxis == -facing:
plat_facing = 'horiz'
track_facing = 'S'
else:
raise ValueError('Facing {} is not U({}) or V({})!'.format(
facing,
uaxis,
vaxis,
))
if res.bool('plat_suffix'):
conditions.add_suffix(plat_inst, '_' + plat_facing)
plat_var = res['plat_var', '']
if plat_var:
plat_inst.fixup[plat_var] = plat_facing
track_var = res['track_var', '']
if track_var:
plat_inst.fixup[track_var] = track_facing
for track in track_set:
track.fixup.update(plat_inst.fixup)
return RES_EXHAUSTED # Don't re-run
示例12: generate_music_script
# 需要导入模块: from srctools import Property [as 别名]
# 或者: from srctools.Property import bool [as 别名]
def generate_music_script(data: Property, pack_list: PackList) -> bytes:
"""Generate a soundscript file for music."""
# We also pack the filenames used for the tracks - that way funnel etc
# only get packed when needed. Stock sounds are in VPKS or in aperturetag/,
# we don't check there.
# The voice attrs used in the map - we can skip tracks
voice_attr = CONF['VoiceAttr', ''].casefold().split(';')
funnel = data.find_key('tbeam', '')
bounce = data.find_key('bouncegel', '')
speed = data.find_key('speedgel', '')
sync_funnel = data.bool('sync_funnel')
if 'base' not in data:
base = Property('base', 'bee2/silent_lp.wav')
# Don't sync to a 2-second sound.
sync_funnel = False
else:
base = data.find_key('base')
# The sounds must be present, and the items should be in the map.
has_funnel = funnel.value and (
'funnel' in voice_attr or
'excursionfunnel' in voice_attr
)
has_bounce = bounce.value and (
'bouncegel' in voice_attr or
'bluegel' in voice_attr
)
# Speed-gel sounds also play when flinging, so keep it always.
file = StringIO()
# Write the base music track
file.write(MUSIC_START.format(name='', vol='1'))
write_sound(file, base, pack_list, snd_prefix='#*')
file.write(MUSIC_BASE)
# The 'soundoperators' section is still open now.
# Add the operators to play the auxilluary sounds..
if has_funnel:
file.write(MUSIC_FUNNEL_MAIN)
if has_bounce:
file.write(MUSIC_GEL_BOUNCE_MAIN)
if speed.value:
file.write(MUSIC_GEL_SPEED_MAIN)
# End the main sound block
file.write(MUSIC_END)
if has_funnel:
# Write the 'music.BEE2_funnel' sound entry
file.write('\n')
file.write(MUSIC_START.format(name='_funnel', vol='1'))
write_sound(file, funnel, pack_list, snd_prefix='*')
# Some tracks want the funnel music to sync with the normal
# track, others randomly choose a start.
file.write(
MUSIC_FUNNEL_SYNC_STACK
if sync_funnel else
MUSIC_FUNNEL_RAND_STACK
)
file.write(MUSIC_FUNNEL_UPDATE_STACK)
if has_bounce:
file.write('\n')
file.write(MUSIC_START.format(name='_gel_bounce', vol='0.5'))
write_sound(file, bounce, pack_list, snd_prefix='*')
# Fade in fast (we never get false positives, but fade out slow
# since this disables when falling back..
file.write(MUSIC_GEL_STACK.format(fadein=0.25, fadeout=1.5))
if speed.value:
file.write('\n')
file.write(MUSIC_START.format(name='_gel_speed', vol='0.5'))
write_sound(file, speed, pack_list, snd_prefix='*')
# We need to shut off the sound fast, so portals don't confuse it.
# Fade in slow so it doesn't make much sound (and also as we get
# up to speed). We stop almost immediately on gel too.
file.write(MUSIC_GEL_STACK.format(fadein=0.5, fadeout=0.1))
return file.getvalue().encode()