Skip to content

Commit

Permalink
show destructions in kill feed
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Dec 8, 2024
1 parent 29d569b commit 6d351a1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
3 changes: 1 addition & 2 deletions script/viewer/Analyse/Analyser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ export const Analyser = (props: AnalyseProps) => {
const players = () => parser.getPlayersAtTick(tick());
const buildings = () => parser.getBuildingsAtTick(tick());
const projectiles = () => parser.getProjectilesAtTick(tick());
const kills = parser.getKills();
const events = parser.getEvents();
const playButtonText = () => (playing()) ? '⏸' : '▶️';
const inShared = session && !session.isOwner();
Expand Down Expand Up @@ -262,7 +261,7 @@ export const Analyser = (props: AnalyseProps) => {
inShared={inShared}
/>
<SpecHUD parser={parser} tick={tick()}
players={players()} kills={kills}/>
players={players()} events={events}/>
</div>
<div class="time-control"
title={timeTitle()}>
Expand Down
49 changes: 41 additions & 8 deletions script/viewer/Analyse/Render/KillFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {Kill, PlayerState} from "../Data/Parser";
import {BuildingDestroyedEvent, Event, Kill, PlayerState} from "../Data/Parser";
import {killAlias} from "./killAlias";
import {For, Show} from "solid-js";

export interface KillFeedProps {
kills: Kill[],
events: Event[],
tick: number;
players: PlayerState[];
}

export function KillFeed(props: KillFeedProps) {
const {kills} = props;
const relevantKills = () => kills.filter(kill => kill.tick <= props.tick && kill.tick >= (props.tick - 30 * 10));
const {events} = props;
const relevantEvents = () => events.filter(event => event.tick <= props.tick && event.tick >= (props.tick - 30 * 10));

return <ul class="killfeed">
<For each={relevantKills()}>{(kill) =>
<KillFeedItem kill={kill} players={props.players}/>
<For each={relevantEvents()}>{(event) =>
<KillFeedItem event={event} players={props.players}/>
}</For>
</ul>
}
Expand All @@ -26,11 +26,27 @@ export const teamMap = {
};

interface KillFeedItemProps {
kill: Kill;
event: Event;
players: PlayerState[];
}

export function KillFeedItem(props: KillFeedItemProps) {
return <>
<Show when={props.event.type === "kill"}>
<KillFeedKillItem players={props.players} kill={props.event.kill}/>
</Show>
<Show when={props.event.type === "building_destroyed"}>
<KillFeedDestroyedItem players={props.players} event={props.event}/>
</Show>
</>
}

interface KillFeedKillItemProps {
kill: Kill;
players: PlayerState[];
}

export function KillFeedKillItem(props: KillFeedKillItemProps) {
const attacker = getPlayer(props.players, props.kill.attacker);
const assister = getPlayer(props.players, props.kill.assister);
let victim = getPlayer(props.players, props.kill.victim);
Expand All @@ -42,8 +58,25 @@ export function KillFeedItem(props: KillFeedItemProps) {
</li>
}

interface KillFeedDestroyedItemProps {
event: BuildingDestroyedEvent;
players: PlayerState[];
}

export function KillFeedDestroyedItem(props: KillFeedDestroyedItemProps) {
const attacker = getPlayer(props.players, props.event.attacker_id);
const assister = getPlayer(props.players, props.event.assister_id);
let victim = getPlayer(props.players, props.event.victim_id);

return <li class="kill">
<PlayerNames players={[attacker, assister]}/>
<KillIcon kill={props.event}/>
<PlayerName player={victim}/><span className={teamMap[victim.team]}>({props.event.building_type})</span>
</li>
}

interface KillIconProps {
kill: Kill;
kill: Kill | BuildingDestroyedEvent;
}

export function KillIcon(props: KillIconProps) {
Expand Down
18 changes: 9 additions & 9 deletions script/viewer/Analyse/Render/SpecHUD.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {PlayersSpec} from './PlayerSpec';
import {KillFeed} from './KillFeed';
import {AsyncParser} from "../Data/AsyncParser";
import {PlayerState, Kill} from "../Data/Parser";
import {PlayerState, Kill, Event} from "../Data/Parser";

export interface SpecHUDProps {
tick: number;
parser: AsyncParser;
players: PlayerState[];
kills: Kill[]
tick: number;
parser: AsyncParser;
players: PlayerState[];
events: Event[]
}

export function SpecHUD(props: SpecHUDProps) {
return (<div class="spechud">
<KillFeed tick={props.tick} kills={props.kills} players={props.players}/>
<PlayersSpec players={props.players}/>
</div>)
return (<div class="spechud">
<KillFeed tick={props.tick} events={props.events} players={props.players}/>
<PlayersSpec players={props.players}/>
</div>)
}

0 comments on commit 6d351a1

Please sign in to comment.