def res_cust_antline(inst, res): """Customise the output antline texture, toggle instances. This allows adding extra outputs between the instance and the toggle. Values: straight: The straight overlay texture. corner: The corner overlay texture. straightFloor: Alt texture used on straight floor segements (P1 style) cornerFloor: Alt texture for floor corners (P1 style) If these aren't set, the wall textures will be used. instance: Use the given indicator_toggle instance instead addOut: A set of additional ouputs to add, pointing at the toggle instance """ straight_args, corner_args, toggle_inst, toggle_out = res.value # The original textures for straight and corner antlines straight_ant = vbsp.ANTLINES['straight'] corner_ant = vbsp.ANTLINES['corner'] over_name = '@' + inst['targetname'] + '_indicator' for over in ( vbsp.VMF.by_class['info_overlay'] & vbsp.VMF.by_target[over_name] ): folded_mat = over['material'].casefold() if folded_mat == straight_ant: vbsp.set_antline_mat(over, *straight_args) elif folded_mat == corner_ant: vbsp.set_antline_mat(over, *corner_args) # Ensure this isn't overriden later! vbsp.IGNORED_OVERLAYS.add(over) # allow replacing the indicator_toggle instance if toggle_inst: for toggle in vbsp.VMF.by_class['func_instance']: if toggle.fixup['indicator_name', ''] != over_name: continue toggle['file'] = toggle_inst if len(toggle_out) > 0: for out in inst.outputs[:]: if out.target == toggle['targetname']: # remove the original outputs inst.outputs.remove(out) for out in toggle_out: # Allow adding extra outputs to customly # trigger the toggle conditions.add_output(inst, out, toggle['targetname']) break # Stop looking!
def res_cust_antline(inst: Entity, res: Property): """Customise the output antline texture, toggle instances. This allows adding extra outputs between the instance and the toggle. Values: straight: The straight overlay texture. corner: The corner overlay texture. straightFloor: Alt texture used on straight floor segements (P1 style) cornerFloor: Alt texture for floor corners (P1 style) If these aren't set, the wall textures will be used. instance: Use the given indicator_toggle instance instead addOut: A set of additional ouputs to add, pointing at the toggle instance """ straight_args, corner_args, toggle_inst, toggle_out = res.value # The original textures for straight and corner antlines straight_ant = consts.Antlines.STRAIGHT corner_ant = consts.Antlines.CORNER over_name = '@' + inst['targetname'] + '_indicator' for over in ( vbsp.VMF.by_class['info_overlay'] & vbsp.VMF.by_target[over_name] ): folded_mat = over['material'].casefold() if folded_mat == straight_ant: vbsp.set_antline_mat(over, *straight_args) elif folded_mat == corner_ant: vbsp.set_antline_mat(over, *corner_args) # Ensure this isn't overriden later! vbsp.IGNORED_OVERLAYS.add(over) # allow replacing the indicator_toggle instance if toggle_inst: for toggle in vbsp.VMF.by_class['func_instance']: if toggle.fixup['indicator_name', ''] != over_name: continue toggle['file'] = toggle_inst if len(toggle_out) > 0: for out in inst.outputs[:]: if out.target == toggle['targetname']: # remove the original outputs inst.outputs.remove(out) for out in toggle_out: # Allow adding extra outputs to customly # trigger the toggle conditions.add_output(inst, out, toggle['targetname']) break # Stop looking!
def res_cust_output(inst, res): """Add an additional output to the instance with any values. Always points to the targeted item. If DecConCount is 1, connections """ ( outputs, dec_con_count, targ_conditions, force_sign_type, (sign_act_name, sign_act_out), (sign_deact_name, sign_deact_out), ) = res.value over_name = '@' + inst['targetname'] + '_indicator' for toggle in vbsp.VMF.by_class['func_instance']: if toggle.fixup['indicator_name', ''] == over_name: toggle_name = toggle['targetname'] break else: toggle_name = '' # we want to ignore the toggle instance, if it exists # Build a mapping from names to targets. # This is also the set of all output items, plus indicators. targets = defaultdict(list) for out in inst.outputs: if out.target != toggle_name: targets[out.target].append(out) pan_files = resolve_inst('[indPan]') # These all require us to search through the instances. if force_sign_type or dec_con_count or targ_conditions: for con_inst in vbsp.VMF.by_class['func_instance']: # type: VLib.Entity if con_inst['targetname'] not in targets: # Not our instance continue # Is it an indicator panel, and should we be modding it? if force_sign_type is not None and con_inst['file'].casefold() in pan_files: # Remove the panel if force_sign_type == '': con_inst.remove() continue # Overwrite the signage instance, and then add the # appropriate outputs to control it. sign_id, sign_file_id = force_sign_type con_inst['file'] = resolve_inst(sign_file_id)[0] # First delete the original outputs: for out in targets[con_inst['targetname']]: inst.outputs.remove(out) inputs = CONNECTIONS[sign_id] act_name, act_inp = inputs.in_act deact_name, deact_inp = inputs.in_deact LOGGER.info( 'outputs: a="{}" d="{}"\n' 'inputs: a="{}" d="{}"'.format( (sign_act_name, sign_act_out), (sign_deact_name, sign_deact_out), inputs.in_act, inputs.in_deact ) ) if act_inp and sign_act_out: inst.add_out(VLib.Output( inst_out=sign_act_name, out=sign_act_out, inst_in=act_name, inp=act_inp, targ=con_inst['targetname'], )) if deact_inp and sign_deact_out: inst.add_out(VLib.Output( inst_out=sign_deact_name, out=sign_deact_out, inst_in=deact_name, inp=deact_inp, targ=con_inst['targetname'], )) if dec_con_count and 'connectioncount' in con_inst.fixup: # decrease ConnectionCount on the ents, # so they can still process normal inputs try: val = int(con_inst.fixup['connectioncount']) con_inst.fixup['connectioncount'] = str(val-1) except ValueError: # skip if it's invalid LOGGER.warning( con_inst['targetname'] + ' has invalid ConnectionCount!' ) if targ_conditions: for cond in targ_conditions: # type: Condition cond.test(con_inst) if outputs: for targ in targets: for out in outputs: conditions.add_output(inst, out, targ)
def res_cust_output(inst: Entity, res: Property): """Add an additional output to the instance with any values. Always points to the targeted item. If DecConCount is 1, connections """ ( outputs, dec_con_count, targ_conditions, force_sign_type, (sign_act_name, sign_act_out), (sign_deact_name, sign_deact_out), ) = res.value over_name = '@' + inst['targetname'] + '_indicator' for toggle in vbsp.VMF.by_class['func_instance']: if toggle.fixup['indicator_name', ''] == over_name: toggle_name = toggle['targetname'] break else: toggle_name = '' # we want to ignore the toggle instance, if it exists # Build a mapping from names to targets. # This is also the set of all output items, plus indicators. targets = defaultdict(list) for out in inst.outputs: if out.target != toggle_name: targets[out.target].append(out) pan_files = instanceLocs.resolve('[indPan]') # These all require us to search through the instances. if force_sign_type or dec_con_count or targ_conditions: for con_inst in vbsp.VMF.by_class['func_instance']: # type: Entity if con_inst['targetname'] not in targets: # Not our instance continue # Is it an indicator panel, and should we be modding it? if force_sign_type is not None and con_inst['file'].casefold( ) in pan_files: # Remove the panel if force_sign_type == '': con_inst.remove() continue # Overwrite the signage instance, and then add the # appropriate outputs to control it. sign_id, sign_file_id = force_sign_type con_inst['file'] = instanceLocs.resolve_one(sign_file_id, error=True) # First delete the original outputs: for out in targets[con_inst['targetname']]: inst.outputs.remove(out) inputs = CONNECTIONS[sign_id] act_name, act_inp = inputs.in_act deact_name, deact_inp = inputs.in_deact LOGGER.info('outputs: a="{}" d="{}"\n' 'inputs: a="{}" d="{}"'.format( (sign_act_name, sign_act_out), (sign_deact_name, sign_deact_out), inputs.in_act, inputs.in_deact)) if act_inp and sign_act_out: inst.add_out( Output( inst_out=sign_act_name, out=sign_act_out, inst_in=act_name, inp=act_inp, targ=con_inst['targetname'], )) if deact_inp and sign_deact_out: inst.add_out( Output( inst_out=sign_deact_name, out=sign_deact_out, inst_in=deact_name, inp=deact_inp, targ=con_inst['targetname'], )) if dec_con_count and 'connectioncount' in con_inst.fixup: # decrease ConnectionCount on the ents, # so they can still process normal inputs try: val = int(con_inst.fixup['connectioncount']) con_inst.fixup['connectioncount'] = str(val - 1) except ValueError: # skip if it's invalid LOGGER.warning(con_inst['targetname'] + ' has invalid ConnectionCount!') if targ_conditions: for cond in targ_conditions: # type: Condition cond.test(con_inst) if outputs: for targ in targets: for out in outputs: conditions.add_output(inst, out, targ)