This commit is contained in:
Eric Froemling 2020-05-30 12:21:44 -07:00
parent c98e645f74
commit 83e7388d49
12 changed files with 37 additions and 62 deletions

View File

@ -118,7 +118,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
# Set this to true to inherit VR camera offsets from the previous
# activity (useful for preventing sporadic camera movement
# during transitions).
inherits_camera_vr_offset = False
inherits_vr_camera_offset = False
# Set this to true to inherit (non-fixed) VR overlay positioning from
# 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()
# FIXME: Relocate or remove the need for this stuff.
self.sharedobjs: Dict[str, Any] = {}
self.paused_text: Optional[ba.Actor] = None
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_begun = 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._expired = False
@ -463,7 +458,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
glb.music_continuous = True # Prevent restarting same music.
glb.music = prev_globals.music
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
if self.inherits_vr_overlay_center and prev_globals is not None:
glb.vr_overlay_center = prev_globals.vr_overlay_center

View File

@ -46,7 +46,7 @@ class EndSessionActivity(Activity[Player, Team]):
self.transition_time = 0.25
self.inherits_tint = True
self.inherits_slow_motion = True
self.inherits_camera_vr_offset = True
self.inherits_vr_camera_offset = True
self.inherits_vr_overlay_center = True
def on_transition_in(self) -> None:
@ -114,7 +114,7 @@ class TransitionActivity(Activity[Player, Team]):
self.transition_time = 0.5
self.inherits_slow_motion = 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.use_fixed_vr_overlay = True
self._background: Optional[ba.Actor] = None
@ -144,7 +144,7 @@ class ScoreScreenActivity(Activity[Player, Team]):
super().__init__(settings)
self.transition_time = 0.5
self.inherits_tint = True
self.inherits_camera_vr_offset = True
self.inherits_vr_camera_offset = True
self.use_fixed_vr_overlay = True
self.default_music: Optional[MusicType] = MusicType.SCORES
self._birth_time = _ba.time()

View File

@ -171,7 +171,6 @@ class Actor:
so a simple "if myactor" test will conveniently do the right thing
even if myactor is set to None.
"""
return True
def __bool__(self) -> bool:

View File

@ -78,7 +78,7 @@ def run_stress_test(playlist_type: str = 'Random',
from ba._enums import TimeType
_ba.screenmessage(
'Beginning stress test.. use '
'\'End Game\' to stop testing.',
"'End Game' to stop testing.",
color=(1, 1, 0))
with _ba.Context('ui'):
start_stress_test({
@ -112,7 +112,7 @@ def start_stress_test(args: Dict[str, Any]) -> None:
from ba._dualteamsession import DualTeamSession
from ba._freeforallsession import FreeForAllSession
from ba._enums import TimeType, TimeFormat
bs_config = _ba.app.config
appconfig = _ba.app.config
playlist_type = args['playlist_type']
if playlist_type == 'Random':
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 +
'", listName="' + args['playlist_name'] + '")...')
if playlist_type == 'Teams':
bs_config['Team Tournament Playlist Selection'] = args['playlist_name']
bs_config['Team Tournament Playlist Randomize'] = 1
appconfig['Team Tournament Playlist Selection'] = args['playlist_name']
appconfig['Team Tournament Playlist Randomize'] = 1
_ba.timer(1.0,
Call(_ba.pushcall, Call(_ba.new_host_session,
DualTeamSession)),
timetype=TimeType.REAL)
else:
bs_config['Free-for-All Playlist Selection'] = args['playlist_name']
bs_config['Free-for-All Playlist Randomize'] = 1
appconfig['Free-for-All Playlist Selection'] = args['playlist_name']
appconfig['Free-for-All Playlist Randomize'] = 1
_ba.timer(1.0,
Call(_ba.pushcall,
Call(_ba.new_host_session, FreeForAllSession)),

View File

@ -549,20 +549,6 @@ class GameActivity(Activity[PlayerType, TeamType]):
# By default, just spawn a dude.
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:
if isinstance(msg, PlayerDiedMessage):
# pylint: disable=cyclic-import
@ -759,7 +745,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
tip = tip['tip']
assert isinstance(tip, str)
# A few substitutions...
# Do a few substitutions.
tip_lstr = Lstr(translate=('tips', tip),
subs=[('${PICKUP}',
_ba.charstr(SpecialChar.TOP_BUTTON))])
@ -1104,10 +1090,11 @@ class GameActivity(Activity[PlayerType, TeamType]):
if duration <= 0.0:
return
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
# not available in activity contexts... :-/
# not available in activity contexts. :-/
self._tournament_time_limit_timer = _ba.Timer(
1.0,
WeakCall(self._tournament_time_limit_tick),

View File

@ -254,14 +254,14 @@ class MultiTeamSession(Session):
"""
# pylint: disable=cyclic-import
# pylint: disable=too-many-locals
from ba import _math
from ba import _general
from ba._math import normalized_color
from ba._general import Call
from ba._gameutils import cameraflash
from ba import _lang
from ba._lang import Lstr
from ba._freeforallsession import FreeForAllSession
from ba._messages import CelebrateMessage
_ba.timer(delay,
_general.Call(_ba.playsound, _ba.getsound('boxingBell')))
_ba.timer(delay, Call(_ba.playsound, _ba.getsound('boxingBell')))
if announce_winning_team:
winning_team = results.get_winning_team()
if winning_team is not None:
@ -278,12 +278,13 @@ class MultiTeamSession(Session):
wins_resource = 'winsPlayerText'
else:
wins_resource = 'winsTeamText'
wins_text = _lang.Lstr(resource=wins_resource,
subs=[('${NAME}', winning_team.name)])
activity.show_zoom_message(wins_text,
scale=0.85,
color=_math.normalized_color(
winning_team.color))
wins_text = Lstr(resource=wins_resource,
subs=[('${NAME}', winning_team.name)])
activity.show_zoom_message(
wins_text,
scale=0.85,
color=normalized_color(winning_team.color),
)
class ShuffleList:

View File

@ -158,10 +158,8 @@ class Session:
# Init our C++ layer data.
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.sharedobjs: Dict[str, Any] = {}
self.have_shown_controls_help_overlay = False
self.teams = []
self.players = []
@ -193,7 +191,6 @@ class Session:
color=color)
self.teams.append(team)
self._next_team_id += 1
try:
with _ba.Context(self):
self.on_team_join(team)

View File

@ -77,7 +77,8 @@ class TeamGameActivity(GameActivity[PlayerType, TeamType]):
# (unless we're being run in co-op mode, in which case we leave
# it up to them)
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
lifespan = 10.0
if self.slow_motion:
@ -87,7 +88,7 @@ class TeamGameActivity(GameActivity[PlayerType, TeamType]):
scale=0.8,
position=(380, 200),
bright=True).autoretain()
self.session.have_shown_controls_help_overlay = True
setattr(self.session, attrname, True)
def on_begin(self) -> None:
super().on_begin()

View File

@ -48,7 +48,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
# Keep prev activity alive while we fade in
self.transition_time = 0.5
self.inherits_tint = True
self.inherits_camera_vr_offset = True
self.inherits_vr_camera_offset = True
self.inherits_music = True
self.use_fixed_vr_overlay = True

View File

@ -26,6 +26,7 @@ from typing import TYPE_CHECKING
import ba
from bastd.activity.multiteamscore import MultiTeamScoreScreenActivity
from bastd.actor.zoomtext import ZoomText
if TYPE_CHECKING:
from typing import Any, Dict
@ -34,15 +35,9 @@ if TYPE_CHECKING:
class DrawScoreScreenActivity(MultiTeamScoreScreenActivity):
"""Score screen shown after a draw."""
def __init__(self, settings: Dict[str, Any]):
super().__init__(settings=settings)
def on_transition_in(self) -> None:
self.default_music = None # Awkward silence...
super().on_transition_in()
default_music = None # Awkward silence...
def on_begin(self) -> None:
from bastd.actor.zoomtext import ZoomText
ba.set_analytics_screen('Draw Score Screen')
super().on_begin()
ZoomText(ba.Lstr(resource='drawText'),

View File

@ -90,7 +90,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
settings['map'] = 'Tower D'
super().__init__(settings)
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._new_wave_sound = ba.getsound('scoreHit01')

View File

@ -1,5 +1,5 @@
<!-- 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,
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>