update from origin

This commit is contained in:
Ayush Saini 2023-09-30 17:21:33 +05:30
parent 8beb334d64
commit bf2f252ee5
91 changed files with 1839 additions and 1281 deletions

View file

@ -45,6 +45,9 @@ class CoopJoinActivity(bs.JoinActivity):
def _show_remaining_achievements(self) -> None:
from bascenev1lib.actor.text import Text
app = bs.app
env = app.env
# We only show achievements and challenges for CoopGameActivities.
session = self.session
assert isinstance(session, bs.CoopSession)
@ -64,19 +67,15 @@ class CoopJoinActivity(bs.JoinActivity):
ts_h_offs = 60
# Show remaining achievements in some cases.
if bs.app.classic is not None and not (
bs.app.demo_mode or bs.app.arcade_mode
):
if app.classic is not None and not (env.demo or env.arcade):
achievements = [
a
for a in bs.app.classic.ach.achievements_for_coop_level(
levelname
)
for a in app.classic.ach.achievements_for_coop_level(levelname)
if not a.complete
]
have_achievements = bool(achievements)
achievements = [a for a in achievements if not a.complete]
vrmode = bs.app.vr_mode
vrmode = env.vr
if have_achievements:
Text(
bs.Lstr(resource='achievementsRemainingText'),

View file

@ -351,6 +351,8 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
assert bui.app.classic is not None
env = bui.app.env
delay = 0.7 if (self._score is not None) else 0.0
# If there's no players left in the game, lets not show the UI
@ -406,9 +408,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
else:
pass
show_next_button = self._is_more_levels and not (
bui.app.demo_mode or bui.app.arcade_mode
)
show_next_button = self._is_more_levels and not (env.demo or env.arcade)
if not show_next_button:
h_offs += 70
@ -486,7 +486,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
v_offs + 560.0,
)
if bui.app.demo_mode or bui.app.arcade_mode:
if env.demo or env.arcade:
self._league_rank_button = None
self._store_button_instance = None
else:
@ -595,7 +595,9 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
# pylint: disable=too-many-locals
super().on_begin()
plus = bs.app.plus
app = bs.app
env = app.env
plus = app.plus
assert plus is not None
self._begin_time = bs.time()
@ -624,7 +626,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
# If this is the first time we completed it, set the next one
# as current.
if self._newly_complete:
cfg = bs.app.config
cfg = app.config
cfg['Selected Coop Game'] = (
self._campaign.name + ':' + self._next_level_name
)
@ -637,7 +639,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
self._is_complete
and self._victory
and self._is_more_levels
and not (bs.app.demo_mode or bs.app.arcade_mode)
and not (env.demo or env.arcade)
):
Text(
bs.Lstr(
@ -715,7 +717,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
position=(0, 230),
).autoretain()
if bs.app.classic is not None and bs.app.classic.server is None:
if app.classic is not None and app.classic.server is None:
# If we're running in normal non-headless build, show this text
# because only host can continue the game.
adisp = plus.get_v1_account_display_string()
@ -828,7 +830,7 @@ class CoopScoreScreen(bs.Activity[bs.Player, bs.Team]):
)
if plus.get_v1_account_state() != 'signed_in':
# We expect this only in kiosk mode; complain otherwise.
if not (bs.app.demo_mode or bs.app.arcade_mode):
if not (env.demo or env.arcade):
logging.error('got not-signed-in at score-submit; unexpected')
bs.pushcall(bs.WeakCall(self._got_score_results, None))
else:

View file

@ -74,7 +74,7 @@ class Background(bs.Actor):
self.node.connectattr('opacity', self.logo, 'opacity')
# add jitter/pulse for a stop-motion-y look unless we're in VR
# in which case stillness is better
if not bs.app.vr_mode:
if not bs.app.env.vr:
self.cmb = bs.newnode(
'combine', owner=self.node, attrs={'size': 2}
)

View file

@ -58,45 +58,11 @@ class ControlsGuide(bs.Actor):
self._update_timer: bs.Timer | None = None
self._title_text: bs.Node | None
clr: Sequence[float]
extra_pos_1: tuple[float, float] | None
extra_pos_2: tuple[float, float] | None
if bs.app.iircade_mode:
xtweak = 0.2
ytweak = 0.2
jump_pos = (
position[0] + offs * (-1.2 + xtweak),
position[1] + offs * (0.1 + ytweak),
)
bomb_pos = (
position[0] + offs * (0.0 + xtweak),
position[1] + offs * (0.5 + ytweak),
)
punch_pos = (
position[0] + offs * (1.2 + xtweak),
position[1] + offs * (0.5 + ytweak),
)
pickup_pos = (
position[0] + offs * (-1.4 + xtweak),
position[1] + offs * (-1.2 + ytweak),
)
extra_pos_1 = (
position[0] + offs * (-0.2 + xtweak),
position[1] + offs * (-0.8 + ytweak),
)
extra_pos_2 = (
position[0] + offs * (1.0 + xtweak),
position[1] + offs * (-0.8 + ytweak),
)
self._force_hide_button_names = True
else:
punch_pos = (position[0] - offs * 1.1, position[1])
jump_pos = (position[0], position[1] - offs)
bomb_pos = (position[0] + offs * 1.1, position[1])
pickup_pos = (position[0], position[1] + offs)
extra_pos_1 = None
extra_pos_2 = None
self._force_hide_button_names = False
punch_pos = (position[0] - offs * 1.1, position[1])
jump_pos = (position[0], position[1] - offs)
bomb_pos = (position[0] + offs * 1.1, position[1])
pickup_pos = (position[0], position[1] + offs)
self._force_hide_button_names = False
if show_title:
self._title_text_pos_top = (
@ -242,13 +208,13 @@ class ControlsGuide(bs.Actor):
clr = (0.9, 0.9, 2.0, 1.0) if bright else (0.8, 0.8, 2.0, 1.0)
self._run_text_pos_top = (position[0], position[1] - 135.0 * scale)
self._run_text_pos_bottom = (position[0], position[1] - 172.0 * scale)
sval = 1.0 * scale if bs.app.vr_mode else 0.8 * scale
sval = 1.0 * scale if bs.app.env.vr else 0.8 * scale
self._run_text = bs.newnode(
'text',
attrs={
'scale': sval,
'host_only': True,
'shadow': 1.0 if bs.app.vr_mode else 0.5,
'shadow': 1.0 if bs.app.env.vr else 0.5,
'flatness': 1.0,
'maxwidth': 380,
'v_align': 'top',
@ -271,36 +237,8 @@ class ControlsGuide(bs.Actor):
},
)
if extra_pos_1 is not None:
self._extra_image_1: bs.Node | None = bs.newnode(
'image',
attrs={
'texture': bs.gettexture('nub'),
'absolute_scale': True,
'host_only': True,
'vr_depth': 10,
'position': extra_pos_1,
'scale': (image_size, image_size),
'color': (0.5, 0.5, 0.5),
},
)
else:
self._extra_image_1 = None
if extra_pos_2 is not None:
self._extra_image_2: bs.Node | None = bs.newnode(
'image',
attrs={
'texture': bs.gettexture('nub'),
'absolute_scale': True,
'host_only': True,
'vr_depth': 10,
'position': extra_pos_2,
'scale': (image_size, image_size),
'color': (0.5, 0.5, 0.5),
},
)
else:
self._extra_image_2 = None
self._extra_image_1 = None
self._extra_image_2 = None
self._nodes = [
self._bomb_image,
@ -317,10 +255,6 @@ class ControlsGuide(bs.Actor):
if show_title:
assert self._title_text
self._nodes.append(self._title_text)
if self._extra_image_1 is not None:
self._nodes.append(self._extra_image_1)
if self._extra_image_2 is not None:
self._nodes.append(self._extra_image_2)
# Start everything invisible.
for node in self._nodes:

View file

@ -209,7 +209,7 @@ class PlayerSpaz(Spaz):
picked_up_by = msg.node.source_player
if picked_up_by:
self.last_player_attacked_by = picked_up_by
self.last_attacked_time = bs.apptime()
self.last_attacked_time = bs.time()
self.last_attacked_type = ('picked_up', 'default')
elif isinstance(msg, bs.StandMessage):
super().handlemessage(msg) # Augment standard behavior.
@ -247,7 +247,7 @@ class PlayerSpaz(Spaz):
# something like last_actor_attacked_by to fix that.
if (
self.last_player_attacked_by
and bs.apptime() - self.last_attacked_time < 4.0
and bs.time() - self.last_attacked_time < 4.0
):
killerplayer = self.last_player_attacked_by
else:
@ -278,7 +278,7 @@ class PlayerSpaz(Spaz):
source_player = msg.get_source_player(type(self._player))
if source_player:
self.last_player_attacked_by = source_player
self.last_attacked_time = bs.apptime()
self.last_attacked_time = bs.time()
self.last_attacked_type = (msg.hit_type, msg.hit_subtype)
super().handlemessage(msg) # Augment standard behavior.
activity = self._activity()

View file

@ -45,7 +45,7 @@ class _Entry:
# FIXME: Should not do things conditionally for vr-mode, as there may
# be non-vr clients connected which will also get these value.
vrmode = bs.app.vr_mode
vrmode = bs.app.env.vr
if self._do_cover:
if vrmode:

View file

@ -19,6 +19,9 @@ if TYPE_CHECKING:
from typing import Any, Sequence, Callable
POWERUP_WEAR_OFF_TIME = 20000
# Obsolete - just used for demo guy now.
BASE_PUNCH_POWER_SCALE = 1.2
BASE_PUNCH_COOLDOWN = 400
@ -95,7 +98,7 @@ class Spaz(bs.Actor):
self.source_player = source_player
self._dead = False
if self._demo_mode: # Preserve old behavior.
self._punch_power_scale = 1.2
self._punch_power_scale = BASE_PUNCH_POWER_SCALE
else:
self._punch_power_scale = factory.punch_power_scale
self.fly = bs.getactivity().globalsnode.happy_thoughts_mode
@ -189,7 +192,7 @@ class Spaz(bs.Actor):
self.land_mine_count = 0
self.blast_radius = 2.0
self.powerups_expire = powerups_expire
if self._demo_mode: # preserve old behavior
if self._demo_mode: # Preserve old behavior.
self._punch_cooldown = BASE_PUNCH_COOLDOWN
else:
self._punch_cooldown = factory.punch_cooldown
@ -482,12 +485,12 @@ class Spaz(bs.Actor):
Called to 'press bomb' on this spaz;
used for player or AI connections.
"""
if not self.node:
return
if self._dead or self.frozen:
return
if self.node.knockout > 0.0:
if (
not self.node
or self._dead
or self.frozen
or self.node.knockout > 0.0
):
return
t_ms = int(bs.time() * 1000.0)
assert isinstance(t_ms, int)
@ -514,15 +517,14 @@ class Spaz(bs.Actor):
"""
if not self.node:
return
t_ms = int(bs.time() * 1000.0)
assert isinstance(t_ms, int)
self.last_run_time_ms = t_ms
self.node.run = value
# filtering these events would be tough since its an analog
# Filtering these events would be tough since its an analog
# value, but lets still pass full 0-to-1 presses along to
# the turbo filter to punish players if it looks like they're turbo-ing
# the turbo filter to punish players if it looks like they're turbo-ing.
if self._last_run_value < 0.01 and value > 0.99:
self._turbo_filter_add_press('run')
@ -535,7 +537,7 @@ class Spaz(bs.Actor):
"""
if not self.node:
return
# not adding a cooldown time here for now; slightly worried
# Not adding a cooldown time here for now; slightly worried
# input events get clustered up during net-games and we'd wind up
# killing a lot and making it hard to fly.. should look into this.
self.node.fly_pressed = True
@ -610,7 +612,7 @@ class Spaz(bs.Actor):
self.node, attr, materials + (factory.curse_material,)
)
# None specifies no time limit
# None specifies no time limit.
assert self.node
if self.curse_time is None:
self.node.curse_death_time = -1
@ -878,7 +880,7 @@ class Spaz(bs.Actor):
self.node.frozen = True
bs.timer(5.0, bs.WeakCall(self.handlemessage, bs.ThawMessage()))
# Instantly shatter if we're already dead.
# (otherwise its hard to tell we're dead)
# (otherwise its hard to tell we're dead).
if self.hitpoints <= 0:
self.shatter()
@ -898,7 +900,7 @@ class Spaz(bs.Actor):
return True
# If we were recently hit, don't count this as another.
# (so punch flurries and bomb pileups essentially count as 1 hit)
# (so punch flurries and bomb pileups essentially count as 1 hit).
local_time = int(bs.time() * 1000.0)
assert isinstance(local_time, int)
if (
@ -1133,11 +1135,11 @@ class Spaz(bs.Actor):
)
if self.hitpoints > 0:
# It's kinda crappy to die from impacts, so lets reduce
# impact damage by a reasonable amount *if* it'll keep us alive
# impact damage by a reasonable amount *if* it'll keep us alive.
if msg.hit_type == 'impact' and damage > self.hitpoints:
# Drop damage to whatever puts us at 10 hit points,
# or 200 less than it used to be whichever is greater
# (so it *can* still kill us if its high enough)
# (so it *can* still kill us if its high enough).
newdamage = max(damage - 200, self.hitpoints - 10)
damage = newdamage
self.node.handlemessage('flash')

View file

@ -69,7 +69,7 @@ class ZoomText(bs.Actor):
)
# we never jitter in vr mode..
if bs.app.vr_mode:
if bs.app.env.vr:
jitter = 0.0
# if they want jitter, animate its position slightly...

View file

@ -483,9 +483,6 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]):
except bs.NotFoundError:
return
if not spaz.is_alive():
return
player = spaz.getplayer(Player, True)
if player:

View file

@ -487,8 +487,8 @@ class FootballCoopGame(bs.CoopGameActivity[Player, Team]):
super().on_begin()
# Show controls help in kiosk mode.
if bs.app.demo_mode or bs.app.arcade_mode:
# Show controls help in demo or arcade mode.
if bs.app.env.demo or bs.app.env.arcade:
controlsguide.ControlsGuide(
delay=3.0, lifespan=10.0, bright=True
).autoretain()

View file

@ -60,11 +60,11 @@ class Puck(bs.Actor):
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, bs.DieMessage):
assert self.node
self.node.delete()
activity = self._activity()
if activity and not msg.immediate:
activity.handlemessage(PuckDiedMessage(self))
if self.node:
self.node.delete()
activity = self._activity()
if activity and not msg.immediate:
activity.handlemessage(PuckDiedMessage(self))
# If we go out of bounds, move back to where we started.
elif isinstance(msg, bs.OutOfBoundsMessage):

View file

@ -186,6 +186,7 @@ class KingOfTheHillGame(bs.TeamGameActivity[Player, Team]):
'materials': flagmats,
},
)
self._update_scoreboard()
self._update_flag_state()
def _tick(self) -> None:

View file

@ -550,8 +550,9 @@ class OnslaughtGame(bs.CoopGameActivity[Player, Team]):
]
elif self._preset in {Preset.UBER, Preset.UBER_EASY}:
# Show controls help in demo/arcade modes.
if bs.app.demo_mode or bs.app.arcade_mode:
# Show controls help in demo or arcade modes.
env = bs.app.env
if env.demo or env.arcade:
ControlsGuide(
delay=3.0, lifespan=10.0, bright=True
).autoretain()

View file

@ -478,7 +478,7 @@ class RunaroundGame(bs.CoopGameActivity[Player, Team]):
)
# FIXME; should not set things based on vr mode.
# (won't look right to non-vr connected clients, etc)
vrmode = bs.app.vr_mode
vrmode = bs.app.env.vr
self._lives_text = bs.NodeActor(
bs.newnode(
'text',

View file

@ -50,6 +50,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
super().on_transition_in()
random.seed(123)
app = bs.app
env = app.env
assert app.classic is not None
plus = bui.app.plus
@ -59,9 +60,9 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# the host is VR mode or not (clients may differ in that regard).
# Any differences need to happen at the engine level so everyone
# sees things in their own optimal way.
vr_mode = bs.app.vr_mode
vr_mode = bs.app.env.vr
if not bs.app.toolbar_test:
if not bs.app.ui_v1.use_toolbars:
color = (1.0, 1.0, 1.0, 1.0) if vr_mode else (0.5, 0.6, 0.5, 0.6)
# FIXME: Need a node attr for vr-specific-scale.
@ -117,21 +118,21 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# the host is vr mode or not (clients may not be or vice versa).
# Any differences need to happen at the engine level so everyone sees
# things in their own optimal way.
vr_mode = app.vr_mode
vr_mode = app.env.vr
uiscale = app.ui_v1.uiscale
# In cases where we're doing lots of dev work lets always show the
# build number.
force_show_build_number = False
if not bs.app.toolbar_test:
if app.debug_build or app.test_build or force_show_build_number:
if app.debug_build:
if not bs.app.ui_v1.use_toolbars:
if env.debug or env.test or force_show_build_number:
if env.debug:
text = bs.Lstr(
value='${V} (${B}) (${D})',
subs=[
('${V}', app.version),
('${B}', str(app.build_number)),
('${V}', app.env.version),
('${B}', str(app.env.build_number)),
('${D}', bs.Lstr(resource='debugText')),
],
)
@ -139,12 +140,12 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
text = bs.Lstr(
value='${V} (${B})',
subs=[
('${V}', app.version),
('${B}', str(app.build_number)),
('${V}', app.env.version),
('${B}', str(app.env.build_number)),
],
)
else:
text = bs.Lstr(value='${V}', subs=[('${V}', app.version)])
text = bs.Lstr(value='${V}', subs=[('${V}', app.env.version)])
scale = 0.9 if (uiscale is bs.UIScale.SMALL or vr_mode) else 0.7
color = (1, 1, 1, 1) if vr_mode else (0.5, 0.6, 0.5, 0.7)
self.version = bs.NodeActor(
@ -168,31 +169,9 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
assert self.version.node
bs.animate(self.version.node, 'opacity', {2.3: 0, 3.0: 1.0})
# Show the iircade logo on our iircade build.
if app.iircade_mode:
img = bs.NodeActor(
bs.newnode(
'image',
attrs={
'texture': bs.gettexture('iircadeLogo'),
'attach': 'center',
'scale': (250, 250),
'position': (0, 0),
'tilt_translate': 0.21,
'absolute_scale': True,
},
)
).autoretain()
imgdelay = (
0.0 if app.classic.main_menu_did_initial_transition else 1.0
)
bs.animate(
img.node, 'opacity', {imgdelay + 1.5: 0.0, imgdelay + 2.5: 1.0}
)
# Throw in test build info.
self.beta_info = self.beta_info_2 = None
if app.test_build and not (app.demo_mode or app.arcade_mode):
if env.test and not (env.demo or env.arcade):
pos = (230, 35)
self.beta_info = bs.NodeActor(
bs.newnode(
@ -313,7 +292,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
random.seed()
if not (app.demo_mode or app.arcade_mode) and not app.toolbar_test:
if not (env.demo or env.arcade) and not app.ui_v1.use_toolbars:
self._news = NewsDisplay(self)
# Bring up the last place we were, or start at the main menu otherwise.
@ -330,7 +309,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# When coming back from a kiosk-mode game, jump to
# the kiosk start screen.
if bs.app.demo_mode or bs.app.arcade_mode:
if env.demo or env.arcade:
# pylint: disable=cyclic-import
from bauiv1lib.kiosk import KioskWindow
@ -417,6 +396,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# pylint: disable=too-many-locals
# pylint: disable=too-many-statements
app = bs.app
env = app.env
assert app.classic is not None
# Update logo in case it changes.
@ -460,7 +440,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
base_x = -270.0
x = base_x - 20.0
spacing = 85.0 * base_scale
y_extra = 0.0 if (app.demo_mode or app.arcade_mode) else 0.0
y_extra = 0.0 if (env.demo or env.arcade) else 0.0
self._make_logo(
x - 110 + 50,
113 + y + 1.2 * y_extra,
@ -525,7 +505,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
base_x = -170
x = base_x - 20
spacing = 55 * base_scale
y_extra = 0 if (app.demo_mode or app.arcade_mode) else 0
y_extra = 0 if (env.demo or env.arcade) else 0
xv1 = x
delay1 = delay
for shadow in (True, False):
@ -677,7 +657,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# Add a bit of stop-motion-y jitter to the logo
# (unless we're in VR mode in which case its best to
# leave things still).
if not bs.app.vr_mode:
if not bs.app.env.vr:
cmb: bs.Node | None
cmb2: bs.Node | None
if not shadow:
@ -796,7 +776,7 @@ class MainMenuActivity(bs.Activity[bs.Player, bs.Team]):
# (unless we're in VR mode in which case its best to
# leave things still).
assert logo.node
if not bs.app.vr_mode:
if not bs.app.env.vr:
cmb = bs.newnode('combine', owner=logo.node, attrs={'size': 2})
cmb.connectattr('output', logo.node, 'position')
keys = {}
@ -904,7 +884,7 @@ class NewsDisplay:
self._phrases.insert(0, phr)
val = self._phrases.pop()
if val == '__ACH__':
vrmode = app.vr_mode
vrmode = app.env.vr
Text(
bs.Lstr(resource='nextAchievementsText'),
color=((1, 1, 1, 1) if vrmode else (0.95, 0.9, 1, 0.4)),
@ -970,7 +950,7 @@ class NewsDisplay:
# Show upcoming achievements in non-vr versions
# (currently too hard to read in vr).
self._used_phrases = (['__ACH__'] if not bs.app.vr_mode else []) + [
self._used_phrases = (['__ACH__'] if not bs.app.env.vr else []) + [
s for s in news.split('<br>\n') if s != ''
]
self._phrase_change_timer = bs.Timer(
@ -982,12 +962,12 @@ class NewsDisplay:
assert bs.app.classic is not None
scl = (
1.2
if (bs.app.ui_v1.uiscale is bs.UIScale.SMALL or bs.app.vr_mode)
if (bs.app.ui_v1.uiscale is bs.UIScale.SMALL or bs.app.env.vr)
else 0.8
)
color2 = (1, 1, 1, 1) if bs.app.vr_mode else (0.7, 0.65, 0.75, 1.0)
shadow = 1.0 if bs.app.vr_mode else 0.4
color2 = (1, 1, 1, 1) if bs.app.env.vr else (0.7, 0.65, 0.75, 1.0)
shadow = 1.0 if bs.app.env.vr else 0.4
self._text = bs.NodeActor(
bs.newnode(
'text',