mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
This commit is contained in:
parent
7af264a85b
commit
2580a3604a
4 changed files with 14 additions and 6 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -6,7 +6,7 @@
|
||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@demostf/edit": "0.2.0",
|
"@demostf/edit": "0.2.0",
|
||||||
"@demostf/tf-demos-viewer": "^0.3.1",
|
"@demostf/tf-demos-viewer": "^0.3.2",
|
||||||
"@lutaok/solid-modal": "^0.1.1",
|
"@lutaok/solid-modal": "^0.1.1",
|
||||||
"@solid-primitives/autofocus": "^0.0.111",
|
"@solid-primitives/autofocus": "^0.0.111",
|
||||||
"@solid-primitives/keyboard": "^1.2.8",
|
"@solid-primitives/keyboard": "^1.2.8",
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
"integrity": "sha512-s9wk3QVm+aTpMhIyfdGIHRm5qHp7FQ1dq/Jn0fms+lXsB1xY3wgjfWH+5gwRjjo/Dd3UMNM0o3atjO2uh+CxOQ=="
|
"integrity": "sha512-s9wk3QVm+aTpMhIyfdGIHRm5qHp7FQ1dq/Jn0fms+lXsB1xY3wgjfWH+5gwRjjo/Dd3UMNM0o3atjO2uh+CxOQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@demostf/tf-demos-viewer": {
|
"node_modules/@demostf/tf-demos-viewer": {
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@demostf/tf-demos-viewer/-/tf-demos-viewer-0.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/@demostf/tf-demos-viewer/-/tf-demos-viewer-0.3.2.tgz",
|
||||||
"integrity": "sha512-AhU72a7IcYCMUnjHfRL0kKfOZee1uN0ik8do/TUGX+0zcCuBfwf1HC3OqP0G3b5g2XmGhbXHIQgaGJIDwttWWA=="
|
"integrity": "sha512-gNMGWOV/xQG5Y2JnJFi6ZBuWY3+RE8HoFWDWSEhuwvlFzqYUEaVhPA4wkD/1KmEjtgHbSF1ezsQFB6TTSgKd/A=="
|
||||||
},
|
},
|
||||||
"node_modules/@lutaok/solid-modal": {
|
"node_modules/@lutaok/solid-modal": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@demostf/edit": "0.2.0",
|
"@demostf/edit": "0.2.0",
|
||||||
"@demostf/tf-demos-viewer": "^0.3.1",
|
"@demostf/tf-demos-viewer": "^0.3.2",
|
||||||
"@lutaok/solid-modal": "^0.1.1",
|
"@lutaok/solid-modal": "^0.1.1",
|
||||||
"@solid-primitives/autofocus": "^0.0.111",
|
"@solid-primitives/autofocus": "^0.0.111",
|
||||||
"@solid-primitives/keyboard": "^1.2.8",
|
"@solid-primitives/keyboard": "^1.2.8",
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ export interface BuildingState {
|
||||||
team: Team,
|
team: Team,
|
||||||
buildingType: BuildingType,
|
buildingType: BuildingType,
|
||||||
buildProgress: number,
|
buildProgress: number,
|
||||||
|
shield: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProjectileState {
|
export interface ProjectileState {
|
||||||
|
|
@ -383,7 +384,8 @@ function unpackBuilding(bytes: Uint8Array, base: number, world: WorldBoundaries)
|
||||||
const y = unpack_f32(bytes[base + 2] + (bytes[base + 3] << 8), world.boundary_min.y, world.boundary_max.y);
|
const y = unpack_f32(bytes[base + 2] + (bytes[base + 3] << 8), world.boundary_min.y, world.boundary_max.y);
|
||||||
const team_type_health = bytes[base + 4] + (bytes[base + 5] << 8);
|
const team_type_health = bytes[base + 4] + (bytes[base + 5] << 8);
|
||||||
const angle = unpack_angle(bytes[base + 6]);
|
const angle = unpack_angle(bytes[base + 6]);
|
||||||
const health = team_type_health & 1013;
|
const health = (team_type_health >> 1) & 511;
|
||||||
|
const shield = (team_type_health & 1) == 1;
|
||||||
const team = (((team_type_health >> 13) & 1) === 0) ? Team.Blue : Team.Red;
|
const team = (((team_type_health >> 13) & 1) === 0) ? Team.Blue : Team.Red;
|
||||||
const level = (team_type_health >> 14);
|
const level = (team_type_health >> 14);
|
||||||
const buildingType = ((team_type_health >> 10) & 7) as BuildingType;
|
const buildingType = ((team_type_health >> 10) & 7) as BuildingType;
|
||||||
|
|
@ -397,6 +399,7 @@ function unpackBuilding(bytes: Uint8Array, base: number, world: WorldBoundaries)
|
||||||
buildingType,
|
buildingType,
|
||||||
level,
|
level,
|
||||||
buildProgress,
|
buildProgress,
|
||||||
|
shield,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ export function Building(props: BuildingProp) {
|
||||||
const teamColor = () => (props.building.team === Team.Red) ? '#a75d50' : '#5b818f';
|
const teamColor = () => (props.building.team === Team.Red) ? '#a75d50' : '#5b818f';
|
||||||
if (!maxHealth) {
|
if (!maxHealth) {
|
||||||
return null;
|
return null;
|
||||||
|
v
|
||||||
}
|
}
|
||||||
|
|
||||||
const transform = () => `translate(${scaledX()} ${scaledY()}) scale(${1 / props.scale})`;
|
const transform = () => `translate(${scaledX()} ${scaledY()}) scale(${1 / props.scale})`;
|
||||||
|
|
@ -52,12 +53,16 @@ export function Building(props: BuildingProp) {
|
||||||
|
|
||||||
const alpha = () => props.building.health / maxHealth();
|
const alpha = () => props.building.health / maxHealth();
|
||||||
const imageOpacity = () => props.building.health === 0 ? 0 : (1 + alpha()) / 2;
|
const imageOpacity = () => props.building.health === 0 ? 0 : (1 + alpha()) / 2;
|
||||||
|
|
||||||
|
const filter = () => props.building.shield ? ((props.building.team === Team.Red) ? 'url(#sofGlowRed)' : 'url(#sofGlowBlue)') : '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const image = () => getBuildingType(props.building.buildingType);
|
const image = () => getBuildingType(props.building.buildingType);
|
||||||
return <g transform={transform()}>
|
return <g transform={transform()}>
|
||||||
<circle r={16} stroke-width={1.5} stroke="white" fill={teamColor()}
|
<circle r={16} stroke-width={1.5} stroke="white" fill={teamColor()}
|
||||||
opacity={alpha()}
|
opacity={alpha()}
|
||||||
stroke-dasharray={`${props.building.buildProgress} 100`}
|
stroke-dasharray={`${props.building.buildProgress} 100`}
|
||||||
|
filter={filter()}
|
||||||
/>
|
/>
|
||||||
<image href={image()} class="player-icon" height={32} width={32} transform={`translate(-16 -16)`}
|
<image href={image()} class="player-icon" height={32} width={32} transform={`translate(-16 -16)`}
|
||||||
opacity={imageOpacity()}/>
|
opacity={imageOpacity()}/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue