Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Code/client/Services/Generic/OverlayService.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <TiltedOnlinePCH.h>

#include <cmath>

#include <Services/OverlayService.h>

#include <OverlayApp.hpp>
Expand Down Expand Up @@ -491,7 +493,10 @@ void OverlayService::RunPlayerHealthUpdates() noexcept

static float s_previousPercentage = -1.f;

const float newPercentage = CalculateHealthPercentage(PlayerCharacter::Get());
// The party UI shows a bar, so whole percents are enough. Round up so that 0 still means dead.
// Without rounding, regeneration in combat changes the value on every tick and each update
// makes the overlay redraw.
const float newPercentage = std::ceil(CalculateHealthPercentage(PlayerCharacter::Get()));
if (newPercentage == s_previousPercentage)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[ngStyle]="positionStyle | async"
>
<div
*ngFor="let player of groupMembers$ | async"
*ngFor="let player of groupMembers$ | async; trackBy: trackByMemberId"
[title]="player.cellName"
class="group-member"
[class.not-loaded]="!player.isLoaded"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
margin-top: 1%;

.group-member-health-value {
transition: width 0.8s ease-in-out;
height: 0.79vw;
position: relative;
overflow: hidden;
Expand Down
6 changes: 5 additions & 1 deletion Code/skyrim_ui/src/app/components/group/group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class GroupComponent implements OnInit, OnDestroy {
}

private subscribeChangeHealth() {
this.clientService.healthChange
this.groupService.memberHealthChange
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.flashGroup();
Expand Down Expand Up @@ -210,6 +210,10 @@ export class GroupComponent implements OnInit, OnDestroy {
}
}

public trackByMemberId(_index: number, member: Player) {
return member.id;
}

public invite(playerId: number) {
this.groupService.invite(playerId);
}
Expand Down
4 changes: 3 additions & 1 deletion Code/skyrim_ui/src/app/services/client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ export class ClientService implements OnDestroy {

private onSetHealth(playerId: number, health: number) {
this.zone.run(() => {
this.healthChange.next(new Player({ id: playerId, health: health }));
this.healthChange.next(
new Player({ id: playerId, health: Math.ceil(health) }),
);
});
}

Expand Down
7 changes: 6 additions & 1 deletion Code/skyrim_ui/src/app/services/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Observable,
of,
pluck,
Subject,
Subscription,
} from 'rxjs';
import { filter, map } from 'rxjs/operators';
Expand All @@ -25,6 +26,9 @@ import { Sound, SoundService } from './sound.service';
export class GroupService implements OnDestroy {
public group = new BehaviorSubject<Group | undefined>(undefined);

/** Emits the id of a party member whose health value actually changed. */
public memberHealthChange = new Subject<number>();

private debugSubscription: Subscription;
private connectionSubscription: Subscription;
private userHealthSubscription: Subscription;
Expand Down Expand Up @@ -102,9 +106,10 @@ export class GroupService implements OnDestroy {
if (group) {
const foundPlayer = this.playerListService.getPlayerById(player.id);

if (foundPlayer) {
if (foundPlayer && foundPlayer.health !== player.health) {
foundPlayer.health = player.health;
this.updateGroup();
this.memberHealthChange.next(foundPlayer.id);
}
}
},
Expand Down