Merge pull request #65 from Dliwk/fixes-1

Add position_center attribute to ba.Node and optional bomb_scale parameter to Bomb class
This commit is contained in:
Eric Froemling 2020-06-22 15:50:57 -07:00 committed by GitHub
commit b7cdc9eeae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -572,6 +572,7 @@ class Node:
color: Sequence[float] = (0.0, 0.0, 0.0) color: Sequence[float] = (0.0, 0.0, 0.0)
size: Sequence[float] = (0.0, 0.0, 0.0) size: Sequence[float] = (0.0, 0.0, 0.0)
position: Sequence[float] = (0.0, 0.0, 0.0) position: Sequence[float] = (0.0, 0.0, 0.0)
position_center: Sequence[float] = (0.0, 0.0, 0.0)
position_forward: Sequence[float] = (0.0, 0.0, 0.0) position_forward: Sequence[float] = (0.0, 0.0, 0.0)
punch_position: Sequence[float] = (0.0, 0.0, 0.0) punch_position: Sequence[float] = (0.0, 0.0, 0.0)
punch_velocity: Sequence[float] = (0.0, 0.0, 0.0) punch_velocity: Sequence[float] = (0.0, 0.0, 0.0)

View File

@ -674,6 +674,7 @@ class Bomb(ba.Actor):
velocity: Sequence[float] = (0.0, 0.0, 0.0), velocity: Sequence[float] = (0.0, 0.0, 0.0),
bomb_type: str = 'normal', bomb_type: str = 'normal',
blast_radius: float = 2.0, blast_radius: float = 2.0,
bomb_scale: float = 1.0,
source_player: ba.Player = None, source_player: ba.Player = None,
owner: ba.Node = None): owner: ba.Node = None):
"""Create a new Bomb. """Create a new Bomb.
@ -693,6 +694,7 @@ class Bomb(ba.Actor):
self.bomb_type = bomb_type self.bomb_type = bomb_type
self._exploded = False self._exploded = False
self.scale = bomb_scale
self.texture_sequence: Optional[ba.Node] = None self.texture_sequence: Optional[ba.Node] = None
@ -753,6 +755,7 @@ class Bomb(ba.Actor):
'model': factory.land_mine_model, 'model': factory.land_mine_model,
'light_model': factory.land_mine_model, 'light_model': factory.land_mine_model,
'body': 'landMine', 'body': 'landMine',
'body_scale': self.scale,
'shadow_size': 0.44, 'shadow_size': 0.44,
'color_texture': factory.land_mine_tex, 'color_texture': factory.land_mine_tex,
'reflection': 'powerup', 'reflection': 'powerup',
@ -770,6 +773,7 @@ class Bomb(ba.Actor):
'model': factory.tnt_model, 'model': factory.tnt_model,
'light_model': factory.tnt_model, 'light_model': factory.tnt_model,
'body': 'crate', 'body': 'crate',
'body_scale': self.scale,
'shadow_size': 0.5, 'shadow_size': 0.5,
'color_texture': factory.tnt_tex, 'color_texture': factory.tnt_tex,
'reflection': 'soft', 'reflection': 'soft',
@ -785,6 +789,7 @@ class Bomb(ba.Actor):
'position': position, 'position': position,
'velocity': velocity, 'velocity': velocity,
'body': 'sphere', 'body': 'sphere',
'body_scale': self.scale,
'model': factory.impact_bomb_model, 'model': factory.impact_bomb_model,
'shadow_size': 0.3, 'shadow_size': 0.3,
'color_texture': factory.impact_tex, 'color_texture': factory.impact_tex,
@ -822,6 +827,7 @@ class Bomb(ba.Actor):
'position': position, 'position': position,
'velocity': velocity, 'velocity': velocity,
'model': model, 'model': model,
'body_scale': self.scale,
'shadow_size': 0.3, 'shadow_size': 0.3,
'color_texture': tex, 'color_texture': tex,
'sticky': sticky, 'sticky': sticky,
@ -846,7 +852,11 @@ class Bomb(ba.Actor):
ba.timer(fuse_time, ba.timer(fuse_time,
ba.WeakCall(self.handlemessage, ExplodeMessage())) ba.WeakCall(self.handlemessage, ExplodeMessage()))
ba.animate(self.node, 'model_scale', {0: 0, 0.2: 1.3, 0.26: 1}) ba.animate(self.node, 'model_scale', {
0: 0,
0.2: 1.3 * self.scale,
0.26: self.scale
})
def get_source_player( def get_source_player(
self, playertype: Type[PlayerType]) -> Optional[PlayerType]: self, playertype: Type[PlayerType]) -> Optional[PlayerType]: