mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-28 01:43:22 +08:00
cleaned up on_transition_in() calls
This commit is contained in:
parent
049bb97b1f
commit
6f3f1644b4
@ -151,6 +151,8 @@ class ScoreScreenActivity(_activity.Activity):
|
||||
self._tips_text: Optional[ba.Actor] = None
|
||||
self._kicked_off_server_shutdown = False
|
||||
self._kicked_off_server_restart = False
|
||||
self._default_music: Optional[str] = 'Scores'
|
||||
self._default_show_tips = True
|
||||
|
||||
def on_player_join(self, player: ba.Player) -> None:
|
||||
from ba import _general
|
||||
@ -163,22 +165,17 @@ class ScoreScreenActivity(_activity.Activity):
|
||||
_ba.timer(time_till_assign, _general.WeakCall(self._safe_assign,
|
||||
player))
|
||||
|
||||
def on_transition_in(self,
|
||||
music: Optional[str] = 'Scores',
|
||||
show_tips: bool = True) -> None:
|
||||
# FIXME: Unify args.
|
||||
# pylint: disable=arguments-differ
|
||||
# pylint: disable=cyclic-import
|
||||
from bastd.actor import tipstext
|
||||
from bastd.actor import background
|
||||
from ba import _music as bs_music
|
||||
def on_transition_in(self) -> None:
|
||||
from bastd.actor.tipstext import TipsText
|
||||
from bastd.actor.background import Background
|
||||
from ba import _music
|
||||
super().on_transition_in()
|
||||
self._background = background.Background(fade_time=0.5,
|
||||
start_faded=False,
|
||||
show_logo=True)
|
||||
if show_tips:
|
||||
self._tips_text = tipstext.TipsText()
|
||||
bs_music.setmusic(music)
|
||||
self._background = Background(fade_time=0.5,
|
||||
start_faded=False,
|
||||
show_logo=True)
|
||||
if self._default_show_tips:
|
||||
self._tips_text = TipsText()
|
||||
_music.setmusic(self._default_music)
|
||||
|
||||
def on_begin(self, custom_continue_message: ba.Lstr = None) -> None:
|
||||
# FIXME: Unify args.
|
||||
|
||||
@ -240,7 +240,7 @@ class GameActivity(Activity):
|
||||
'default': False
|
||||
})]
|
||||
"""
|
||||
del sessiontype # unused arg
|
||||
del sessiontype # Unused arg.
|
||||
return []
|
||||
|
||||
@classmethod
|
||||
@ -264,8 +264,8 @@ class GameActivity(Activity):
|
||||
from ba import _map
|
||||
name = cls.get_display_string(config['settings'])
|
||||
|
||||
# in newer configs, map is in settings; it used to be in the
|
||||
# config root
|
||||
# In newer configs, map is in settings; it used to be in the
|
||||
# config root.
|
||||
if 'map' in config['settings']:
|
||||
sval = Lstr(value="${NAME} @ ${MAP}",
|
||||
subs=[('${NAME}', name),
|
||||
@ -306,6 +306,10 @@ class GameActivity(Activity):
|
||||
# Whether to show points for kills.
|
||||
self._show_kill_points = True
|
||||
|
||||
# Music that should play in on_transition_in()
|
||||
# (unless overridden by the map).
|
||||
self._default_music: Optional[str] = None
|
||||
|
||||
# Go ahead and get our map loading.
|
||||
map_name: str
|
||||
if 'map' in settings:
|
||||
@ -438,23 +442,15 @@ class GameActivity(Activity):
|
||||
"""
|
||||
return ''
|
||||
|
||||
def on_transition_in(self, music: str = None) -> None:
|
||||
"""
|
||||
Method override; optionally can
|
||||
be passed a 'music' string which is the suggested type of
|
||||
music to play during the game.
|
||||
Note that in some cases music may be overridden by
|
||||
the map or other factors, which is why you should pass
|
||||
it in here instead of simply playing it yourself.
|
||||
"""
|
||||
# FIXME: Unify args.
|
||||
# pylint: disable=arguments-differ
|
||||
def on_transition_in(self) -> None:
|
||||
|
||||
super().on_transition_in()
|
||||
|
||||
# make our map
|
||||
# Make our map.
|
||||
self._map = self._map_type()
|
||||
|
||||
music = self._default_music
|
||||
|
||||
# give our map a chance to override the music
|
||||
# (for happy-thoughts and other such themed maps)
|
||||
override_music = self._map_type.get_music_type()
|
||||
@ -462,8 +458,8 @@ class GameActivity(Activity):
|
||||
music = override_music
|
||||
|
||||
if music is not None:
|
||||
from ba import _music as bsmusic
|
||||
bsmusic.setmusic(music)
|
||||
from ba import _music
|
||||
_music.setmusic(music)
|
||||
|
||||
def on_continue(self) -> None:
|
||||
"""
|
||||
|
||||
@ -64,11 +64,11 @@ class TeamGameActivity(GameActivity):
|
||||
if isinstance(_ba.getsession(), FreeForAllSession):
|
||||
self._show_kill_points = False
|
||||
|
||||
def on_transition_in(self, music: str = None) -> None:
|
||||
def on_transition_in(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from ba._coopsession import CoopSession
|
||||
from bastd.actor.controlsguide import ControlsGuide
|
||||
super().on_transition_in(music)
|
||||
super().on_transition_in()
|
||||
|
||||
# On the first game, show the controls UI momentarily.
|
||||
# (unless we're being run in co-op mode, in which case we leave
|
||||
|
||||
@ -37,11 +37,9 @@ class DrawScoreScreenActivity(TeamsScoreScreenActivity):
|
||||
def __init__(self, settings: Dict[str, Any]):
|
||||
super().__init__(settings=settings)
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME FIXME: unify args
|
||||
# pylint: disable=arguments-differ
|
||||
super().on_transition_in(music=None)
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = None # Awkward silence...
|
||||
super().on_transition_in()
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_begin(self) -> None: # type: ignore
|
||||
|
||||
@ -42,11 +42,11 @@ class TeamSeriesVictoryScoreScreenActivity(TeamsScoreScreenActivity):
|
||||
self._tips_text = None
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify args.
|
||||
# pylint: disable=arguments-differ
|
||||
# we don't yet want music and stuff..
|
||||
super().on_transition_in(music=None, show_tips=False)
|
||||
def on_transition_in(self) -> None:
|
||||
# We don't yet want music and whatnot...
|
||||
self._default_music = None
|
||||
self._default_show_tips = False
|
||||
super().on_transition_in()
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_begin(self) -> None: # type: ignore
|
||||
|
||||
@ -67,7 +67,7 @@ class OnScreenTimer(ba.Actor):
|
||||
self.inputnode.time1 = self._starttime
|
||||
ba.sharedobj('globals').connectattr('time', self.inputnode, 'time2')
|
||||
|
||||
def hasstarted(self) -> bool:
|
||||
def has_started(self) -> bool:
|
||||
"""Return whether this timer has started yet."""
|
||||
return self._starttime is not None
|
||||
|
||||
|
||||
@ -93,13 +93,10 @@ class AssaultGame(ba.TeamGameActivity):
|
||||
return 'touch 1 flag'
|
||||
return 'touch ${ARG1} flags', self.settings['Score to Win']
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Need to unify these parameters.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self,
|
||||
music='Epic' if self.settings['Epic Mode'] else 'ForwardMarch')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic' if self.settings['Epic Mode'] else
|
||||
'ForwardMarch')
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['score'] = 0
|
||||
|
||||
@ -134,13 +134,10 @@ class CaptureTheFlagGame(ba.TeamGameActivity):
|
||||
return 'return 1 flag'
|
||||
return 'return ${ARG1} flags', self.settings['Score to Win']
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME unify these args
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self,
|
||||
music='Epic' if self.settings['Epic Mode'] else 'FlagCatcher')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic' if self.settings['Epic Mode'] else
|
||||
'FlagCatcher')
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['score'] = 0
|
||||
|
||||
@ -117,12 +117,10 @@ class ChosenOneGame(ba.TeamGameActivity):
|
||||
def get_instance_description(self) -> Union[str, Sequence]:
|
||||
return 'There can be only one.'
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic' if self.settings['Epic Mode'] else 'Chosen One')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic'
|
||||
if self.settings['Epic Mode'] else 'Chosen One')
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['time_remaining'] = self.settings["Chosen One Time"]
|
||||
|
||||
@ -122,12 +122,10 @@ class ConquestGame(ba.TeamGameActivity):
|
||||
def get_instance_scoreboard_description(self) -> Union[str, Sequence]:
|
||||
return 'secure all ${ARG1} flags', len(self.map.flag_points)
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME unify these args
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic' if self.settings['Epic Mode'] else 'GrandRomp')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic'
|
||||
if self.settings['Epic Mode'] else 'GrandRomp')
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
if self.has_begun():
|
||||
|
||||
@ -114,12 +114,10 @@ class DeathMatchGame(ba.TeamGameActivity):
|
||||
def get_instance_scoreboard_description(self) -> Union[str, Sequence]:
|
||||
return 'kill ${ARG1} enemies', self._score_to_win
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME need to unify these function signatures
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic' if self.settings['Epic Mode'] else 'ToTheDeath')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic'
|
||||
if self.settings['Epic Mode'] else 'ToTheDeath')
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['score'] = 0
|
||||
|
||||
@ -96,11 +96,9 @@ class EasterEggHuntGame(ba.TeamGameActivity):
|
||||
# Called when our game is transitioning in but not ready to start.
|
||||
# ..we can go ahead and set our music and whatnot.
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these arguments.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='ForwardMarch')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'ForwardMarch'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['score'] = 0
|
||||
|
||||
@ -243,12 +243,10 @@ class EliminationGame(ba.TeamGameActivity):
|
||||
return 'last team standing wins' if isinstance(
|
||||
self.session, ba.TeamsSession) else 'last one standing wins'
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: need to give on_transition_in() consistent args everywhere.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic' if self.settings['Epic Mode'] else 'Survival')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic'
|
||||
if self.settings['Epic Mode'] else 'Survival')
|
||||
super().on_transition_in()
|
||||
self._start_time = ba.time()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
|
||||
@ -145,11 +145,9 @@ class FootballTeamGame(ba.TeamGameActivity):
|
||||
return 'score ${ARG1} touchdowns', touchdowns
|
||||
return 'score a touchdown'
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='Football')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Football'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_begin(self) -> None:
|
||||
ba.TeamGameActivity.on_begin(self)
|
||||
@ -398,11 +396,9 @@ class FootballCoopGame(ba.CoopGameActivity):
|
||||
self._flag_respawn_light: Optional[ba.Actor] = None
|
||||
self._flag: Optional[FootballFlag] = None
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.CoopGameActivity.on_transition_in(self, music='Football')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Football'
|
||||
super().on_transition_in()
|
||||
self._scoreboard = Scoreboard()
|
||||
self._flag_spawn_pos = self.map.get_flag_position(None)
|
||||
self._spawn_flag()
|
||||
|
||||
@ -206,11 +206,9 @@ class HockeyGame(ba.TeamGameActivity):
|
||||
return 'score a goal'
|
||||
return 'score ${ARG1} goals', self.settings['Score to Win']
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='Hockey')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Hockey'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_begin(self) -> None:
|
||||
ba.TeamGameActivity.on_begin(self)
|
||||
|
||||
@ -123,11 +123,9 @@ class KeepAwayGame(ba.TeamGameActivity):
|
||||
return ('carry the flag for ${ARG1} seconds',
|
||||
self.settings['Hold Time'])
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='Keep Away')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Keep Away'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['time_remaining'] = self.settings["Hold Time"]
|
||||
|
||||
@ -132,11 +132,9 @@ class KingOfTheHillGame(ba.TeamGameActivity):
|
||||
return ('secure the flag for ${ARG1} seconds',
|
||||
self.settings['Hold Time'])
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='Scary')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Scary'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['time_remaining'] = self.settings["Hold Time"]
|
||||
|
||||
@ -90,12 +90,10 @@ class MeteorShowerGame(ba.TeamGameActivity):
|
||||
|
||||
# Called when our game is transitioning in but not ready to start;
|
||||
# ..we can go ahead and set our music and whatnot.
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME unify these
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic' if self.settings['Epic Mode'] else 'Survival')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic'
|
||||
if self.settings['Epic Mode'] else 'Survival')
|
||||
super().on_transition_in()
|
||||
|
||||
# Called when our game actually starts.
|
||||
def on_begin(self) -> None:
|
||||
|
||||
@ -83,11 +83,9 @@ class NinjaFightGame(ba.TeamGameActivity):
|
||||
|
||||
# Called when our game is transitioning in but not ready to begin;
|
||||
# we can go ahead and start creating stuff, playing music, etc.
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='ToTheDeath')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'ToTheDeath'
|
||||
super().on_transition_in()
|
||||
|
||||
# Called when our game actually begins.
|
||||
def on_begin(self) -> None:
|
||||
|
||||
@ -123,12 +123,9 @@ class OnslaughtGame(ba.CoopGameActivity):
|
||||
self._land_mine_kills = 0
|
||||
self._tnt_kills = 0
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
def on_transition_in(self) -> None:
|
||||
from bastd.actor.scoreboard import Scoreboard
|
||||
ba.CoopGameActivity.on_transition_in(self)
|
||||
super().on_transition_in()
|
||||
|
||||
# Show special landmine tip on rookie preset.
|
||||
if self._preset in ['rookie', 'rookie_easy']:
|
||||
|
||||
@ -27,6 +27,7 @@ from __future__ import annotations
|
||||
|
||||
import random
|
||||
from typing import TYPE_CHECKING
|
||||
from dataclasses import dataclass
|
||||
|
||||
import ba
|
||||
from bastd.actor.bomb import Bomb
|
||||
@ -38,6 +39,13 @@ if TYPE_CHECKING:
|
||||
from bastd.actor.onscreentimer import OnScreenTimer
|
||||
|
||||
|
||||
@dataclass
|
||||
class RaceMine:
|
||||
"""Holds info about a mine on the track."""
|
||||
point: Sequence[float]
|
||||
mine: Optional[Bomb]
|
||||
|
||||
|
||||
class RaceRegion(ba.Actor):
|
||||
"""Region used to track progress during a race."""
|
||||
|
||||
@ -48,7 +56,7 @@ class RaceRegion(ba.Actor):
|
||||
self.pos = pt
|
||||
self.index = index
|
||||
self.node = ba.newnode(
|
||||
"region",
|
||||
'region',
|
||||
delegate=self,
|
||||
attrs={
|
||||
'position': pt[:3],
|
||||
@ -84,41 +92,41 @@ class RaceGame(ba.TeamGameActivity):
|
||||
|
||||
@classmethod
|
||||
def get_supported_maps(cls, sessiontype: Type[ba.Session]) -> List[str]:
|
||||
return ba.getmaps("race")
|
||||
return ba.getmaps('race')
|
||||
|
||||
@classmethod
|
||||
def get_settings(
|
||||
cls,
|
||||
sessiontype: Type[ba.Session]) -> List[Tuple[str, Dict[str, Any]]]:
|
||||
settings: List[Tuple[str, Dict[str, Any]]] = [
|
||||
("Laps", {
|
||||
('Laps', {
|
||||
'min_value': 1,
|
||||
"default": 3,
|
||||
"increment": 1
|
||||
'default': 3,
|
||||
'increment': 1
|
||||
}),
|
||||
("Time Limit", {
|
||||
('Time Limit', {
|
||||
'choices': [('None', 0), ('1 Minute', 60),
|
||||
('2 Minutes', 120), ('5 Minutes', 300),
|
||||
('10 Minutes', 600), ('20 Minutes', 1200)],
|
||||
'default': 0
|
||||
}),
|
||||
("Mine Spawning", {
|
||||
('Mine Spawning', {
|
||||
'choices': [('No Mines', 0), ('8 Seconds', 8000),
|
||||
('4 Seconds', 4000), ('2 Seconds', 2000)],
|
||||
'default': 4000
|
||||
}),
|
||||
("Bomb Spawning", {
|
||||
('Bomb Spawning', {
|
||||
'choices': [('None', 0), ('8 Seconds', 8000),
|
||||
('4 Seconds', 4000), ('2 Seconds', 2000),
|
||||
('1 Second', 1000)],
|
||||
'default': 2000
|
||||
}),
|
||||
("Epic Mode", {
|
||||
('Epic Mode', {
|
||||
'default': False
|
||||
})] # yapf: disable
|
||||
|
||||
if issubclass(sessiontype, ba.TeamsSession):
|
||||
settings.append(("Entire Team Must Finish", {'default': False}))
|
||||
settings.append(('Entire Team Must Finish', {'default': False}))
|
||||
return settings
|
||||
|
||||
def __init__(self, settings: Dict[str, Any]):
|
||||
@ -128,8 +136,8 @@ class RaceGame(ba.TeamGameActivity):
|
||||
self._scoreboard = Scoreboard()
|
||||
if self.settings['Epic Mode']:
|
||||
self.slow_motion = True
|
||||
self._score_sound = ba.getsound("score")
|
||||
self._swipsound = ba.getsound("swip")
|
||||
self._score_sound = ba.getsound('score')
|
||||
self._swipsound = ba.getsound('swip')
|
||||
self._last_team_time: Optional[float] = None
|
||||
self._front_race_region = None
|
||||
self._nub_tex = ba.gettexture('nub')
|
||||
@ -140,7 +148,7 @@ class RaceGame(ba.TeamGameActivity):
|
||||
self._team_finish_pts: Optional[int] = None
|
||||
self._time_text: Optional[ba.Actor] = None
|
||||
self._timer: Optional[OnScreenTimer] = None
|
||||
self._race_mines: Optional[List[Dict[str, Any]]] = None
|
||||
self._race_mines: Optional[List[RaceMine]] = None
|
||||
self._race_mine_timer: Optional[ba.Timer] = None
|
||||
self._scoreboard_timer: Optional[ba.Timer] = None
|
||||
self._player_order_update_timer: Optional[ba.Timer] = None
|
||||
@ -163,20 +171,18 @@ class RaceGame(ba.TeamGameActivity):
|
||||
return 'run ${ARG1} laps', self.settings['Laps']
|
||||
return 'run 1 lap'
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: unify these args
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(
|
||||
self, music='Epic Race' if self.settings['Epic Mode'] else 'Race')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = ('Epic Race'
|
||||
if self.settings['Epic Mode'] else 'Race')
|
||||
super().on_transition_in()
|
||||
|
||||
pts = self.map.get_def_points('race_point')
|
||||
mat = self.race_region_material = ba.Material()
|
||||
mat.add_actions(conditions=("they_have_material",
|
||||
mat.add_actions(conditions=('they_have_material',
|
||||
ba.sharedobj('player_material')),
|
||||
actions=(("modify_part_collision", "collide", True),
|
||||
("modify_part_collision", "physical",
|
||||
False), ("call", "at_connect",
|
||||
actions=(('modify_part_collision', 'collide', True),
|
||||
('modify_part_collision', 'physical',
|
||||
False), ('call', 'at_connect',
|
||||
self._handle_race_point_collide)))
|
||||
for rpt in pts:
|
||||
self._regions.append(RaceRegion(rpt, len(self._regions)))
|
||||
@ -358,7 +364,7 @@ class RaceGame(ba.TeamGameActivity):
|
||||
player.team.gamedata['finished'] = True
|
||||
player.team.gamedata['time'] = None
|
||||
player.team.gamedata['lap'] = 0
|
||||
ba.playsound(ba.getsound("boo"))
|
||||
ba.playsound(ba.getsound('boo'))
|
||||
for otherplayer in player.team.players:
|
||||
otherplayer.gamedata['lap'] = 0
|
||||
otherplayer.gamedata['finished'] = True
|
||||
@ -415,10 +421,10 @@ class RaceGame(ba.TeamGameActivity):
|
||||
self._timer = OnScreenTimer()
|
||||
|
||||
if self.settings['Mine Spawning'] != 0:
|
||||
self._race_mines = [{
|
||||
'point': p,
|
||||
'mine': None
|
||||
} for p in self.map.get_def_points('race_mine')]
|
||||
self._race_mines = [
|
||||
RaceMine(point=p, mine=None)
|
||||
for p in self.map.get_def_points('race_mine')
|
||||
]
|
||||
if self._race_mines:
|
||||
self._race_mine_timer = ba.Timer(
|
||||
0.001 * self.settings['Mine Spawning'],
|
||||
@ -572,21 +578,20 @@ class RaceGame(ba.TeamGameActivity):
|
||||
def _make_mine(self, i: int) -> None:
|
||||
assert self._race_mines is not None
|
||||
rmine = self._race_mines[i]
|
||||
rmine['mine'] = Bomb(position=rmine['point'][:3],
|
||||
bomb_type='land_mine')
|
||||
rmine['mine'].arm()
|
||||
rmine.mine = Bomb(position=rmine.point[:3], bomb_type='land_mine')
|
||||
rmine.mine.arm()
|
||||
|
||||
def _flash_mine(self, i: int) -> None:
|
||||
assert self._race_mines is not None
|
||||
rmine = self._race_mines[i]
|
||||
light = ba.newnode("light",
|
||||
light = ba.newnode('light',
|
||||
attrs={
|
||||
'position': rmine['point'][:3],
|
||||
'position': rmine.point[:3],
|
||||
'color': (1, 0.2, 0.2),
|
||||
'radius': 0.1,
|
||||
'height_attenuated': False
|
||||
})
|
||||
ba.animate(light, "intensity", {0.0: 0, 0.1: 1.0, 0.2: 0}, loop=True)
|
||||
ba.animate(light, 'intensity', {0.0: 0, 0.1: 1.0, 0.2: 0}, loop=True)
|
||||
ba.timer(1.0, light.delete)
|
||||
|
||||
def _update_race_mine(self) -> None:
|
||||
@ -596,10 +601,10 @@ class RaceGame(ba.TeamGameActivity):
|
||||
for _i in range(3):
|
||||
m_index = random.randrange(len(self._race_mines))
|
||||
rmine = self._race_mines[m_index]
|
||||
if not rmine['mine']:
|
||||
if not rmine.mine:
|
||||
break
|
||||
assert rmine is not None
|
||||
if not rmine['mine']:
|
||||
if not rmine.mine:
|
||||
self._flash_mine(m_index)
|
||||
ba.timer(0.95, ba.Call(self._make_mine, m_index))
|
||||
|
||||
@ -690,7 +695,7 @@ class RaceGame(ba.TeamGameActivity):
|
||||
# finish time if we have one. (so users don't get upset if their
|
||||
# final time differs from what they see onscreen by a tiny bit)
|
||||
assert self._timer is not None
|
||||
if self._timer.hasstarted():
|
||||
if self._timer.has_started():
|
||||
self._timer.stop(
|
||||
endtime=None if self._last_team_time is None else (
|
||||
self._timer.getstarttime() + self._last_team_time))
|
||||
|
||||
@ -129,11 +129,9 @@ class RunaroundGame(ba.CoopGameActivity):
|
||||
self._flawless_bonus: Optional[int] = None
|
||||
self._wave_update_timer: Optional[ba.Timer] = None
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify args here.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.CoopGameActivity.on_transition_in(self, music='Marching')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'Marching'
|
||||
super().on_transition_in()
|
||||
self._scoreboard = Scoreboard(label=ba.Lstr(resource='scoreText'),
|
||||
score_split=0.5)
|
||||
self._score_region = ba.Actor(
|
||||
|
||||
@ -80,11 +80,9 @@ class TargetPracticeGame(ba.TeamGameActivity):
|
||||
self._update_timer: Optional[ba.Timer] = None
|
||||
self._countdown: Optional[OnScreenCountdown] = None
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify these args.
|
||||
# pylint: disable=arguments-differ
|
||||
ba.TeamGameActivity.on_transition_in(self, music='ForwardMarch')
|
||||
def on_transition_in(self) -> None:
|
||||
self._default_music = 'ForwardMarch'
|
||||
super().on_transition_in()
|
||||
|
||||
def on_team_join(self, team: ba.Team) -> None:
|
||||
team.gamedata['score'] = 0
|
||||
|
||||
@ -96,12 +96,10 @@ class TheLastStandGame(ba.CoopGameActivity):
|
||||
spazbot.ExplodeyBot: [0.05, 0.02, 0.002]
|
||||
} # yapf: disable
|
||||
|
||||
# noinspection PyMethodOverriding
|
||||
def on_transition_in(self) -> None: # type: ignore
|
||||
# FIXME: Unify args for this call.
|
||||
# pylint: disable=arguments-differ
|
||||
def on_transition_in(self) -> None:
|
||||
from bastd.actor.scoreboard import Scoreboard
|
||||
ba.CoopGameActivity.on_transition_in(self, music='Epic')
|
||||
self._default_music = 'Epic'
|
||||
super().on_transition_in()
|
||||
ba.timer(1.3, ba.Call(ba.playsound, self._new_wave_sound))
|
||||
self._scoreboard = Scoreboard(label=ba.Lstr(resource='scoreText'),
|
||||
score_split=0.5)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<h4><em>last updated on 2020-03-30 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<h4><em>last updated on 2020-03-31 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
||||
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||
<hr>
|
||||
@ -2210,14 +2210,14 @@ whatever is relevant to keep the game going.</p>
|
||||
|
||||
</dd>
|
||||
<dt><h4><a name="method_ba_GameActivity__on_transition_in">on_transition_in()</a></dt></h4><dd>
|
||||
<p><span>on_transition_in(self, music: str = None) -> None</span></p>
|
||||
<p><span>on_transition_in(self) -> None</span></p>
|
||||
|
||||
<p>Method override; optionally can
|
||||
be passed a 'music' string which is the suggested type of
|
||||
music to play during the game.
|
||||
Note that in some cases music may be overridden by
|
||||
the map or other factors, which is why you should pass
|
||||
it in here instead of simply playing it yourself.</p>
|
||||
<p>Called when the Activity is first becoming visible.</p>
|
||||
|
||||
<p>Upon this call, the Activity should fade in backgrounds,
|
||||
start playing music, etc. It does not yet have access to <a href="#class_ba_Player">ba.Players</a>
|
||||
or <a href="#class_ba_Team">ba.Teams</a>, however. They remain owned by the previous Activity
|
||||
up until <a href="#method_ba_Activity__on_begin">ba.Activity.on_begin</a>() is called.</p>
|
||||
|
||||
</dd>
|
||||
<dt><h4><a name="method_ba_GameActivity__project_flag_stand">project_flag_stand()</a></dt></h4><dd>
|
||||
@ -4356,14 +4356,14 @@ and it should begin its actual game logic.</p>
|
||||
|
||||
</dd>
|
||||
<dt><h4><a name="method_ba_TeamGameActivity__on_transition_in">on_transition_in()</a></dt></h4><dd>
|
||||
<p><span>on_transition_in(self, music: str = None) -> None</span></p>
|
||||
<p><span>on_transition_in(self) -> None</span></p>
|
||||
|
||||
<p>Method override; optionally can
|
||||
be passed a 'music' string which is the suggested type of
|
||||
music to play during the game.
|
||||
Note that in some cases music may be overridden by
|
||||
the map or other factors, which is why you should pass
|
||||
it in here instead of simply playing it yourself.</p>
|
||||
<p>Called when the Activity is first becoming visible.</p>
|
||||
|
||||
<p>Upon this call, the Activity should fade in backgrounds,
|
||||
start playing music, etc. It does not yet have access to <a href="#class_ba_Player">ba.Players</a>
|
||||
or <a href="#class_ba_Team">ba.Teams</a>, however. They remain owned by the previous Activity
|
||||
up until <a href="#method_ba_Activity__on_begin">ba.Activity.on_begin</a>() is called.</p>
|
||||
|
||||
</dd>
|
||||
<dt><h4><a name="method_ba_TeamGameActivity__spawn_player_spaz">spawn_player_spaz()</a></dt></h4><dd>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user