mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-05 15:03:33 +08:00
Tidying
This commit is contained in:
parent
c98e645f74
commit
83e7388d49
@ -118,7 +118,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
# Set this to true to inherit VR camera offsets from the previous
|
# Set this to true to inherit VR camera offsets from the previous
|
||||||
# activity (useful for preventing sporadic camera movement
|
# activity (useful for preventing sporadic camera movement
|
||||||
# during transitions).
|
# during transitions).
|
||||||
inherits_camera_vr_offset = False
|
inherits_vr_camera_offset = False
|
||||||
|
|
||||||
# Set this to true to inherit (non-fixed) VR overlay positioning from
|
# Set this to true to inherit (non-fixed) VR overlay positioning from
|
||||||
# the previous activity (useful for prevent sporadic overlay jostling
|
# the previous activity (useful for prevent sporadic overlay jostling
|
||||||
@ -168,7 +168,6 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
self._setup_player_and_team_types()
|
self._setup_player_and_team_types()
|
||||||
|
|
||||||
# FIXME: Relocate or remove the need for this stuff.
|
# FIXME: Relocate or remove the need for this stuff.
|
||||||
self.sharedobjs: Dict[str, Any] = {}
|
|
||||||
self.paused_text: Optional[ba.Actor] = None
|
self.paused_text: Optional[ba.Actor] = None
|
||||||
self.spaz_respawn_icons_right: Dict[int, RespawnIcon]
|
self.spaz_respawn_icons_right: Dict[int, RespawnIcon]
|
||||||
|
|
||||||
@ -188,10 +187,6 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
self._has_transitioned_in = False
|
self._has_transitioned_in = False
|
||||||
self._has_begun = False
|
self._has_begun = False
|
||||||
self._has_ended = False
|
self._has_ended = False
|
||||||
self._should_end_immediately = False
|
|
||||||
self._should_end_immediately_results: (
|
|
||||||
Optional[ba.TeamGameResults]) = None
|
|
||||||
self._should_end_immediately_delay = 0.0
|
|
||||||
self._activity_death_check_timer: Optional[ba.Timer] = None
|
self._activity_death_check_timer: Optional[ba.Timer] = None
|
||||||
self._expired = False
|
self._expired = False
|
||||||
|
|
||||||
@ -463,7 +458,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
|
|||||||
glb.music_continuous = True # Prevent restarting same music.
|
glb.music_continuous = True # Prevent restarting same music.
|
||||||
glb.music = prev_globals.music
|
glb.music = prev_globals.music
|
||||||
glb.music_count += 1
|
glb.music_count += 1
|
||||||
if self.inherits_camera_vr_offset and prev_globals is not None:
|
if self.inherits_vr_camera_offset and prev_globals is not None:
|
||||||
glb.vr_camera_offset = prev_globals.vr_camera_offset
|
glb.vr_camera_offset = prev_globals.vr_camera_offset
|
||||||
if self.inherits_vr_overlay_center and prev_globals is not None:
|
if self.inherits_vr_overlay_center and prev_globals is not None:
|
||||||
glb.vr_overlay_center = prev_globals.vr_overlay_center
|
glb.vr_overlay_center = prev_globals.vr_overlay_center
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class EndSessionActivity(Activity[Player, Team]):
|
|||||||
self.transition_time = 0.25
|
self.transition_time = 0.25
|
||||||
self.inherits_tint = True
|
self.inherits_tint = True
|
||||||
self.inherits_slow_motion = True
|
self.inherits_slow_motion = True
|
||||||
self.inherits_camera_vr_offset = True
|
self.inherits_vr_camera_offset = True
|
||||||
self.inherits_vr_overlay_center = True
|
self.inherits_vr_overlay_center = True
|
||||||
|
|
||||||
def on_transition_in(self) -> None:
|
def on_transition_in(self) -> None:
|
||||||
@ -114,7 +114,7 @@ class TransitionActivity(Activity[Player, Team]):
|
|||||||
self.transition_time = 0.5
|
self.transition_time = 0.5
|
||||||
self.inherits_slow_motion = True # Don't change.
|
self.inherits_slow_motion = True # Don't change.
|
||||||
self.inherits_tint = True # Don't change.
|
self.inherits_tint = True # Don't change.
|
||||||
self.inherits_camera_vr_offset = True # Don't change.
|
self.inherits_vr_camera_offset = True # Don't change.
|
||||||
self.inherits_vr_overlay_center = True
|
self.inherits_vr_overlay_center = True
|
||||||
self.use_fixed_vr_overlay = True
|
self.use_fixed_vr_overlay = True
|
||||||
self._background: Optional[ba.Actor] = None
|
self._background: Optional[ba.Actor] = None
|
||||||
@ -144,7 +144,7 @@ class ScoreScreenActivity(Activity[Player, Team]):
|
|||||||
super().__init__(settings)
|
super().__init__(settings)
|
||||||
self.transition_time = 0.5
|
self.transition_time = 0.5
|
||||||
self.inherits_tint = True
|
self.inherits_tint = True
|
||||||
self.inherits_camera_vr_offset = True
|
self.inherits_vr_camera_offset = True
|
||||||
self.use_fixed_vr_overlay = True
|
self.use_fixed_vr_overlay = True
|
||||||
self.default_music: Optional[MusicType] = MusicType.SCORES
|
self.default_music: Optional[MusicType] = MusicType.SCORES
|
||||||
self._birth_time = _ba.time()
|
self._birth_time = _ba.time()
|
||||||
|
|||||||
@ -171,7 +171,6 @@ class Actor:
|
|||||||
so a simple "if myactor" test will conveniently do the right thing
|
so a simple "if myactor" test will conveniently do the right thing
|
||||||
even if myactor is set to None.
|
even if myactor is set to None.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
def __bool__(self) -> bool:
|
||||||
|
|||||||
@ -78,7 +78,7 @@ def run_stress_test(playlist_type: str = 'Random',
|
|||||||
from ba._enums import TimeType
|
from ba._enums import TimeType
|
||||||
_ba.screenmessage(
|
_ba.screenmessage(
|
||||||
'Beginning stress test.. use '
|
'Beginning stress test.. use '
|
||||||
'\'End Game\' to stop testing.',
|
"'End Game' to stop testing.",
|
||||||
color=(1, 1, 0))
|
color=(1, 1, 0))
|
||||||
with _ba.Context('ui'):
|
with _ba.Context('ui'):
|
||||||
start_stress_test({
|
start_stress_test({
|
||||||
@ -112,7 +112,7 @@ def start_stress_test(args: Dict[str, Any]) -> None:
|
|||||||
from ba._dualteamsession import DualTeamSession
|
from ba._dualteamsession import DualTeamSession
|
||||||
from ba._freeforallsession import FreeForAllSession
|
from ba._freeforallsession import FreeForAllSession
|
||||||
from ba._enums import TimeType, TimeFormat
|
from ba._enums import TimeType, TimeFormat
|
||||||
bs_config = _ba.app.config
|
appconfig = _ba.app.config
|
||||||
playlist_type = args['playlist_type']
|
playlist_type = args['playlist_type']
|
||||||
if playlist_type == 'Random':
|
if playlist_type == 'Random':
|
||||||
if random.random() < 0.5:
|
if random.random() < 0.5:
|
||||||
@ -122,15 +122,15 @@ def start_stress_test(args: Dict[str, Any]) -> None:
|
|||||||
_ba.screenmessage('Running Stress Test (listType="' + playlist_type +
|
_ba.screenmessage('Running Stress Test (listType="' + playlist_type +
|
||||||
'", listName="' + args['playlist_name'] + '")...')
|
'", listName="' + args['playlist_name'] + '")...')
|
||||||
if playlist_type == 'Teams':
|
if playlist_type == 'Teams':
|
||||||
bs_config['Team Tournament Playlist Selection'] = args['playlist_name']
|
appconfig['Team Tournament Playlist Selection'] = args['playlist_name']
|
||||||
bs_config['Team Tournament Playlist Randomize'] = 1
|
appconfig['Team Tournament Playlist Randomize'] = 1
|
||||||
_ba.timer(1.0,
|
_ba.timer(1.0,
|
||||||
Call(_ba.pushcall, Call(_ba.new_host_session,
|
Call(_ba.pushcall, Call(_ba.new_host_session,
|
||||||
DualTeamSession)),
|
DualTeamSession)),
|
||||||
timetype=TimeType.REAL)
|
timetype=TimeType.REAL)
|
||||||
else:
|
else:
|
||||||
bs_config['Free-for-All Playlist Selection'] = args['playlist_name']
|
appconfig['Free-for-All Playlist Selection'] = args['playlist_name']
|
||||||
bs_config['Free-for-All Playlist Randomize'] = 1
|
appconfig['Free-for-All Playlist Randomize'] = 1
|
||||||
_ba.timer(1.0,
|
_ba.timer(1.0,
|
||||||
Call(_ba.pushcall,
|
Call(_ba.pushcall,
|
||||||
Call(_ba.new_host_session, FreeForAllSession)),
|
Call(_ba.new_host_session, FreeForAllSession)),
|
||||||
|
|||||||
@ -549,20 +549,6 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
# By default, just spawn a dude.
|
# By default, just spawn a dude.
|
||||||
self.spawn_player(player)
|
self.spawn_player(player)
|
||||||
|
|
||||||
# def on_player_leave(self, player: PlayerType) -> None:
|
|
||||||
# super().on_player_leave(player)
|
|
||||||
|
|
||||||
# # If the player has an actor, send it a deferred die message.
|
|
||||||
# # This way the player will be completely gone from the game
|
|
||||||
# # when the message goes through, making it less likely games
|
|
||||||
# # will incorrectly try to respawn them, etc.
|
|
||||||
# actor = player.actor
|
|
||||||
# if actor is not None:
|
|
||||||
# _ba.pushcall(
|
|
||||||
# Call(actor.handlemessage,
|
|
||||||
# DieMessage(how=DeathType.LEFT_GAME)))
|
|
||||||
# player.actor = None
|
|
||||||
|
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
if isinstance(msg, PlayerDiedMessage):
|
if isinstance(msg, PlayerDiedMessage):
|
||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
@ -759,7 +745,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
tip = tip['tip']
|
tip = tip['tip']
|
||||||
assert isinstance(tip, str)
|
assert isinstance(tip, str)
|
||||||
|
|
||||||
# A few substitutions...
|
# Do a few substitutions.
|
||||||
tip_lstr = Lstr(translate=('tips', tip),
|
tip_lstr = Lstr(translate=('tips', tip),
|
||||||
subs=[('${PICKUP}',
|
subs=[('${PICKUP}',
|
||||||
_ba.charstr(SpecialChar.TOP_BUTTON))])
|
_ba.charstr(SpecialChar.TOP_BUTTON))])
|
||||||
@ -1104,10 +1090,11 @@ class GameActivity(Activity[PlayerType, TeamType]):
|
|||||||
if duration <= 0.0:
|
if duration <= 0.0:
|
||||||
return
|
return
|
||||||
self._tournament_time_limit = int(duration)
|
self._tournament_time_limit = int(duration)
|
||||||
# we want this timer to match the server's time as close as possible,
|
|
||||||
# so lets go with base-time.. theoretically we should do real-time but
|
# We want this timer to match the server's time as close as possible,
|
||||||
|
# so lets go with base-time. Theoretically we should do real-time but
|
||||||
# then we have to mess with contexts and whatnot since its currently
|
# then we have to mess with contexts and whatnot since its currently
|
||||||
# not available in activity contexts... :-/
|
# not available in activity contexts. :-/
|
||||||
self._tournament_time_limit_timer = _ba.Timer(
|
self._tournament_time_limit_timer = _ba.Timer(
|
||||||
1.0,
|
1.0,
|
||||||
WeakCall(self._tournament_time_limit_tick),
|
WeakCall(self._tournament_time_limit_tick),
|
||||||
|
|||||||
@ -254,14 +254,14 @@ class MultiTeamSession(Session):
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
from ba import _math
|
from ba._math import normalized_color
|
||||||
from ba import _general
|
from ba._general import Call
|
||||||
from ba._gameutils import cameraflash
|
from ba._gameutils import cameraflash
|
||||||
from ba import _lang
|
from ba._lang import Lstr
|
||||||
from ba._freeforallsession import FreeForAllSession
|
from ba._freeforallsession import FreeForAllSession
|
||||||
from ba._messages import CelebrateMessage
|
from ba._messages import CelebrateMessage
|
||||||
_ba.timer(delay,
|
_ba.timer(delay, Call(_ba.playsound, _ba.getsound('boxingBell')))
|
||||||
_general.Call(_ba.playsound, _ba.getsound('boxingBell')))
|
|
||||||
if announce_winning_team:
|
if announce_winning_team:
|
||||||
winning_team = results.get_winning_team()
|
winning_team = results.get_winning_team()
|
||||||
if winning_team is not None:
|
if winning_team is not None:
|
||||||
@ -278,12 +278,13 @@ class MultiTeamSession(Session):
|
|||||||
wins_resource = 'winsPlayerText'
|
wins_resource = 'winsPlayerText'
|
||||||
else:
|
else:
|
||||||
wins_resource = 'winsTeamText'
|
wins_resource = 'winsTeamText'
|
||||||
wins_text = _lang.Lstr(resource=wins_resource,
|
wins_text = Lstr(resource=wins_resource,
|
||||||
subs=[('${NAME}', winning_team.name)])
|
subs=[('${NAME}', winning_team.name)])
|
||||||
activity.show_zoom_message(wins_text,
|
activity.show_zoom_message(
|
||||||
scale=0.85,
|
wins_text,
|
||||||
color=_math.normalized_color(
|
scale=0.85,
|
||||||
winning_team.color))
|
color=normalized_color(winning_team.color),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShuffleList:
|
class ShuffleList:
|
||||||
|
|||||||
@ -158,10 +158,8 @@ class Session:
|
|||||||
# Init our C++ layer data.
|
# Init our C++ layer data.
|
||||||
self._sessiondata = _ba.register_session(self)
|
self._sessiondata = _ba.register_session(self)
|
||||||
|
|
||||||
# Stuff in this section should be removed from this class if possible.
|
# Should remove this if possible.
|
||||||
self.tournament_id: Optional[str] = None
|
self.tournament_id: Optional[str] = None
|
||||||
self.sharedobjs: Dict[str, Any] = {}
|
|
||||||
self.have_shown_controls_help_overlay = False
|
|
||||||
|
|
||||||
self.teams = []
|
self.teams = []
|
||||||
self.players = []
|
self.players = []
|
||||||
@ -193,7 +191,6 @@ class Session:
|
|||||||
color=color)
|
color=color)
|
||||||
self.teams.append(team)
|
self.teams.append(team)
|
||||||
self._next_team_id += 1
|
self._next_team_id += 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with _ba.Context(self):
|
with _ba.Context(self):
|
||||||
self.on_team_join(team)
|
self.on_team_join(team)
|
||||||
|
|||||||
@ -77,7 +77,8 @@ class TeamGameActivity(GameActivity[PlayerType, TeamType]):
|
|||||||
# (unless we're being run in co-op mode, in which case we leave
|
# (unless we're being run in co-op mode, in which case we leave
|
||||||
# it up to them)
|
# it up to them)
|
||||||
if not isinstance(self.session, CoopSession):
|
if not isinstance(self.session, CoopSession):
|
||||||
if not self.session.have_shown_controls_help_overlay:
|
attrname = '_have_shown_ctrl_help_overlay'
|
||||||
|
if not getattr(self.session, attrname, False):
|
||||||
delay = 4.0
|
delay = 4.0
|
||||||
lifespan = 10.0
|
lifespan = 10.0
|
||||||
if self.slow_motion:
|
if self.slow_motion:
|
||||||
@ -87,7 +88,7 @@ class TeamGameActivity(GameActivity[PlayerType, TeamType]):
|
|||||||
scale=0.8,
|
scale=0.8,
|
||||||
position=(380, 200),
|
position=(380, 200),
|
||||||
bright=True).autoretain()
|
bright=True).autoretain()
|
||||||
self.session.have_shown_controls_help_overlay = True
|
setattr(self.session, attrname, True)
|
||||||
|
|
||||||
def on_begin(self) -> None:
|
def on_begin(self) -> None:
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
# Keep prev activity alive while we fade in
|
# Keep prev activity alive while we fade in
|
||||||
self.transition_time = 0.5
|
self.transition_time = 0.5
|
||||||
self.inherits_tint = True
|
self.inherits_tint = True
|
||||||
self.inherits_camera_vr_offset = True
|
self.inherits_vr_camera_offset = True
|
||||||
self.inherits_music = True
|
self.inherits_music = True
|
||||||
self.use_fixed_vr_overlay = True
|
self.use_fixed_vr_overlay = True
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
import ba
|
import ba
|
||||||
from bastd.activity.multiteamscore import MultiTeamScoreScreenActivity
|
from bastd.activity.multiteamscore import MultiTeamScoreScreenActivity
|
||||||
|
from bastd.actor.zoomtext import ZoomText
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
@ -34,15 +35,9 @@ if TYPE_CHECKING:
|
|||||||
class DrawScoreScreenActivity(MultiTeamScoreScreenActivity):
|
class DrawScoreScreenActivity(MultiTeamScoreScreenActivity):
|
||||||
"""Score screen shown after a draw."""
|
"""Score screen shown after a draw."""
|
||||||
|
|
||||||
def __init__(self, settings: Dict[str, Any]):
|
default_music = None # Awkward silence...
|
||||||
super().__init__(settings=settings)
|
|
||||||
|
|
||||||
def on_transition_in(self) -> None:
|
|
||||||
self.default_music = None # Awkward silence...
|
|
||||||
super().on_transition_in()
|
|
||||||
|
|
||||||
def on_begin(self) -> None:
|
def on_begin(self) -> None:
|
||||||
from bastd.actor.zoomtext import ZoomText
|
|
||||||
ba.set_analytics_screen('Draw Score Screen')
|
ba.set_analytics_screen('Draw Score Screen')
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
ZoomText(ba.Lstr(resource='drawText'),
|
ZoomText(ba.Lstr(resource='drawText'),
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
settings['map'] = 'Tower D'
|
settings['map'] = 'Tower D'
|
||||||
super().__init__(settings)
|
super().__init__(settings)
|
||||||
shared = SharedObjects.get()
|
shared = SharedObjects.get()
|
||||||
self._preset = self.settings_raw.get('preset', 'pro')
|
self._preset = str(settings.get('preset', 'pro'))
|
||||||
|
|
||||||
self._player_death_sound = ba.getsound('playerDeath')
|
self._player_death_sound = ba.getsound('playerDeath')
|
||||||
self._new_wave_sound = ba.getsound('scoreHit01')
|
self._new_wave_sound = ba.getsound('scoreHit01')
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||||
<h4><em>last updated on 2020-05-29 for Ballistica version 1.5.0 build 20035</em></h4>
|
<h4><em>last updated on 2020-05-30 for Ballistica version 1.5.0 build 20035</em></h4>
|
||||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
<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>
|
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>
|
<hr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user