本文整理汇总了Python中memory.make_object函数的典型用法代码示例。如果您正苦于以下问题:Python make_object函数的具体用法?Python make_object怎么用?Python make_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _pre_send_user_message
def _pre_send_user_message(args):
message_index = args[2]
user_message_hooks = HookUserMessage.hooks[message_index]
protobuf_user_message_hooks = HookProtobufUserMessage.hooks[message_index]
# No need to do anything behind this if no listener is registered
if not user_message_hooks and not protobuf_user_message_hooks:
return
# Replace original recipients filter
tmp_recipients = make_object(BaseRecipientFilter, args[1])
_recipients.update(*tuple(tmp_recipients), clear=True)
args[1] = _recipients
buffer = make_object(ProtobufMessage, args[3])
protobuf_user_message_hooks.notify(_recipients, buffer)
# No need to do anything behind this if no listener is registered
if not user_message_hooks:
return
try:
impl = get_user_message_impl(message_index)
except NotImplementedError:
return
data = impl.read(buffer)
user_message_hooks.notify(_recipients, data)
# Update buffer if data has been changed
if data.has_been_changed():
buffer.clear()
impl.write(buffer, data)
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:35,代码来源:hooks.py
示例2: pre_bump_weapon
def pre_bump_weapon(self, stack_data):
"""Switch the player's team if they are a CT picking up the bomb."""
if make_object(Entity, stack_data[1]).classname != 'weapon_c4':
return
self.bump_player = make_object(Entity, stack_data[0])
if self.bump_player.team == 3:
self.bump_player.team_index = 2
else:
self.bump_player = None
开发者ID:satoon101,项目名称:BombSecurity,代码行数:9,代码来源:bomb_security.py
示例3: _callback
def _callback(stack_data, *args):
"""Called when the hooked method is called."""
# Get the temp entity instance...
temp_entity = make_object(TempEntity, stack_data[0])
# Are we looking for that temp entity?
if temp_entity.name == self.name:
# Call the registered callback...
return callback(temp_entity, make_object(
RecipientFilter, stack_data[1]))
开发者ID:ThaPwned,项目名称:Source.Python,代码行数:11,代码来源:hooks.py
示例4: on_take_damage
def on_take_damage(args):
info = make_object(TakeDamageInfo, args[1])
if info.type & DamageTypes.HEADSHOT:
info.damage *= HEADSHOT_DMG_MULTIPLIER
else:
victim = make_object(Player, args[0])
if victim.hitgroup in (HitGroup.CHEST, HitGroup.STOMACH):
info.damage *= CHEST_DMG_MULTIPLIER
else:
info.damage *= BASE_DMG_MULTIPLIER
开发者ID:KirillMysnik,项目名称:CSGO-RS,代码行数:11,代码来源:damage.py
示例5: on_take_damage
def on_take_damage(args):
protected_player = protected_player_manager[index_from_pointer(args[0])]
if protected_player.dead:
return
info = make_object(TakeDamageInfo, args[1])
return protected_player._hurt(info)
开发者ID:KirillMysnik,项目名称:ArcJail,代码行数:7,代码来源:damage_hook.py
示例6: _pre_on_take_damage
def _pre_on_take_damage(args):
"""
Hooked to a function that is fired any time an
entity takes damage.
"""
player_index = index_from_pointer(args[0])
info = make_object(TakeDamageInfo, args[1])
defender = Player(player_index)
attacker = None if not info.attacker else Player(info.attacker)
eargs = {
'attacker': attacker,
'defender': defender,
'info': info,
'weapon': Weapon(
index_from_inthandle(attacker.active_weapon)
).class_name if attacker and attacker.active_weapon != -1 else ''
}
if not player_index == info.attacker:
defender.hero.execute_skills('player_pre_defend', **eargs)
'''
Added exception to check whether world caused damage.
'''
if attacker:
attacker.hero.execute_skills('player_pre_attack', **eargs)
开发者ID:EtoxRisingWoW,项目名称:Warcraft-GO-old,代码行数:25,代码来源:player.py
示例7: _pre_damage_call_events
def _pre_damage_call_events(stack_data):
take_damage_info = make_object(TakeDamageInfo, stack_data[1])
if not take_damage_info.attacker:
return
entity = Entity(take_damage_info.attacker)
attacker = players[entity.index] if entity.is_player() else None
victim = players[index_from_pointer(stack_data[0])]
event_args = {
'attacker': attacker,
'victim': victim,
'take_damage_info': take_damage_info,
}
if attacker:
if victim.team == attacker.team:
attacker.hero.call_events('player_pre_teammate_attack', player=attacker,
**event_args)
victim.hero.call_events('player_pre_teammate_victim', player=victim, **event_args)
return
attacker.hero.call_events('player_pre_attack', player=attacker, **event_args)
victim.hero.call_events('player_pre_victim', player=victim, **event_args)
if victim.health <= take_damage_info.damage:
attacker.hero.call_events('player_pre_death', player=victim, **event_args)
开发者ID:Predz,项目名称:SP-Warcraft-Mod,代码行数:26,代码来源:calls.py
示例8: base_client
def base_client(self):
"""Return the player's base client instance.
:rtype: BaseClient
"""
from players import BaseClient
return make_object(BaseClient, get_object_pointer(self.client) - 4)
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:7,代码来源:_base.py
示例9: __iter__
def __iter__(self):
"""Iterate over all WeaponInfo instances."""
# Loop through all indexes...
for index in range(_weapon_scripts._length):
# Yield the WeaponInfo instance at the current slot...
yield make_object(WeaponInfo, _weapon_scripts._find(index))
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:7,代码来源:scripts.py
示例10: convert
def convert(self, name, ptr):
"""Convert the pointer.
Tries to convert a pointer in the following order:
Attempts to convert the pointer...
1. to a custom type
2. to a exposed type
3. to a function typedef
4. by using a converter
"""
cls = self.get_class(name)
if cls is not None:
# Use the class to convert the pointer
return make_object(cls, ptr)
# No class was found. Maybe we have luck with a function typedef
converter = self.function_typedefs.get(name, None)
# Is there no function typedef?
if converter is None:
converter = self.converters.get(name, None)
# Is there no converter?
if converter is None:
raise NameError(
'No class, function typedef or ' +
'converter found for "{0}".'.format(name))
# Yay, we found a converter or function typedef!
return converter(ptr)
开发者ID:Doldol,项目名称:Source.Python,代码行数:31,代码来源:manager.py
示例11: _pre_detonate
def _pre_detonate(args):
entity = make_object(Entity, args[0])
if entity.index not in _filtered_indexes:
return None
dissolve(entity)
return True
开发者ID:KirillMysnik,项目名称:ArcJail,代码行数:7,代码来源:antiflash.py
示例12: _pre_on_take_damage
def _pre_on_take_damage(args):
info = make_object(TakeDamageInfo, args[1])
entity = Entity(info.attacker) if info.attacker else None
if entity is not None and entity.is_player():
attacker = wcgo.player.Player(entity.index)
else:
attacker = None
victim = wcgo.player.Player(index_from_pointer(args[0]))
eargs = {
'attacker': attacker,
'victim': victim,
'info': info,
}
# Adds the weapon argument dependent on scenario
if attacker is not None and attacker.active_weapon != -1:
eargs['weapon'] = Weapon(index_from_inthandle(attacker.active_weapon))
else:
eargs['weapon'] = None
if attacker is None or attacker.userid == victim.userid:
victim.hero.execute_skills('player_pre_self_injury', player=victim, **eargs)
return
if not (attacker.steamid == 'BOT' and attacker.hero is None):
attacker.hero.execute_skills('player_pre_attack', player=attacker, **eargs)
if not (victim.steamid == 'BOT' and victim.hero is None):
victim.hero.execute_skills('player_pre_victim', player=victim, **eargs)
开发者ID:Ayuto,项目名称:Warcraft-GO,代码行数:28,代码来源:wcgo.py
示例13: give_level_weapon
def give_level_weapon(self):
"""Give the player the weapon of their current level."""
if self.has_level_weapon():
return self.get_weapon(self.level_weapon_classname)
return make_object(
Weapon,
self.give_named_item(self.level_weapon_classname)
)
开发者ID:GunGame-Dev-Team,项目名称:GunGame-SP,代码行数:8,代码来源:instance.py
示例14: _pre_take_damage
def _pre_take_damage(stack_data):
"""Store the information for later use."""
take_damage_info = make_object(TakeDamageInfo, stack_data[1])
attacker = Entity(take_damage_info.attacker)
if attacker.classname != 'player':
return
victim = make_object(Player, stack_data[0])
if victim.health > take_damage_info.damage:
return
KILLER_DICTIONARY[victim.userid] = {
'attacker': userid_from_index(attacker.index),
'end': Vector(*take_damage_info.position),
'projectile': attacker.index != take_damage_info.inflictor,
'color': _team_colors[victim.team],
}
开发者ID:satoon101,项目名称:DeathBeam,代码行数:17,代码来源:death_beam.py
示例15: _get_property
def _get_property(self, prop_name, prop_type):
"""Return the value of the given property name.
:param str prop_name:
The name of the property.
:param SendPropType prop_type:
The type of the property.
"""
# Is the given property not valid?
if prop_name not in self.template.properties:
# Raise an exception...
raise NameError(
'"{}" is not a valid property for temp entity "{}".'.format(
prop_name, self.name))
# Get the property data...
prop, offset, type_name = self.template.properties[prop_name]
# Are the prop types matching?
if prop.type != prop_type:
# Raise an exception...
raise TypeError('"{}" is not of type "{}".'.format(
prop_name, prop_type))
# Is the property an array?
if prop_type == SendPropType.ARRAY:
# Return an array instance...
return Array(manager, False, type_name, get_object_pointer(
self) + offset, prop.length)
# Is the given type not supported?
if prop_type not in _supported_property_types:
# Raise an exception...
raise TypeError('"{}" is not supported.'.format(prop_type))
# Is the type native?
if Type.is_native(type_name):
# Return the value...
return getattr(
get_object_pointer(self), 'get_' + type_name)(offset)
# Otherwise
else:
# Make the object and return it...
return make_object(
manager.get_class(type_name),
get_object_pointer(self) + offset)
# Raise an exception...
raise ValueError('Unable to get the value of "{}".'.format(prop_name))
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:56,代码来源:base.py
示例16: _on_weapon_purchase
def _on_weapon_purchase(args):
"""Return whether the player is allowed to purchase the weapon."""
# TODO:
# In CS:GO it seems like the weapon isn't passed as a string anymore.
# Instead it's rather a pointer that might be NULL. If it's not NULL, the
# function sets it to some value:
#if ( a3 )
# *(_DWORD *)a3 = v16;
return weapon_restriction_manager.on_player_purchasing_weapon(
make_object(Player, args[0]), args[1 if SOURCE_ENGINE != 'csgo' else 2])
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:10,代码来源:restrictions.py
示例17: _pre_bump_weapon
def _pre_bump_weapon(args):
"""Switch the player's team if they are a CT picking up the bomb."""
global _bump_player
if edict_from_pointer(args[1]).classname != 'weapon_c4':
return
_bump_player = make_object(Player, args[0])
if _bump_player.team == 3:
Entity(_bump_player.index).team = 2
else:
_bump_player = None
开发者ID:Kandru,项目名称:conquest-go,代码行数:10,代码来源:conquest.py
示例18: pre_run_command
def pre_run_command(args):
player = player_manager[make_object(Player, args[0]).index]
user_cmd = make_object(UserCmd, args[1])
if not (user_cmd.buttons & PlayerButtons.SCORE and
user_cmd.buttons & PlayerButtons.USE):
return
if get_mine_denial_reason(player) is not None:
return
trace = player.player.get_trace_ray()
distance = (trace.end_position - player.player.origin).length
if distance > config_manager['plant_distance']:
return
use_mine(player, trace.end_position, trace.plane.normal)
开发者ID:KirillMysnik,项目名称:sp-tripmines,代码行数:19,代码来源:tripmines.py
示例19: pre_send_user_message
def pre_send_user_message(args):
if args[2] != say_text2_index:
return
recipient_filter = make_object(RecipientFilter, args[1])
if is_hltv_message(recipient_filter):
return
buffer = make_object(ProtobufMessage, args[3])
msg_name = buffer.get_string('msg_name')
if msg_name in ("Cstrike_Chat_AllDead", "Cstrike_Chat_AllSpec"):
recipient_filter.add_all_players()
elif msg_name == "Cstrike_Chat_T_Dead":
recipient_filter.update(PlayerIter('t'))
elif msg_name == "Cstrike_Chat_CT_Dead":
recipient_filter.update(PlayerIter('ct'))
开发者ID:KirillMysnik,项目名称:sp-deadchat,代码行数:19,代码来源:protobuf.py
示例20: on_pre_drop_weapon
def on_pre_drop_weapon(stack_data):
"""Remove the droppped weapon after about two seconds."""
# Get a Player object for the first stack_data item
player = make_object(Player, stack_data[0])
# Get the player's active weapon
active_weapon = player.get_active_weapon()
# Remove the weapon after two seconds, if it is valid
if active_weapon is not None:
player.delay(2.0, remove_weapon, (player.get_active_weapon().index,), cancel_on_level_end=True)
开发者ID:backraw,项目名称:flashfun,代码行数:11,代码来源:flashfun.py
注:本文中的memory.make_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论