Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Thorium-Sim/thorium-nova into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
alexanderson1993 committed Oct 12, 2024
2 parents 8ce24f7 + 17bd54a commit d4b21fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions server/src/spawners/ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export async function spawnShip(
);
size.multiplyScalar(template.length || 1);
entity.addComponent("size", {
length: size.z,
width: size.x,
height: size.y,
length: size.x,
width: size.y,
height: size.z,
});

entity.addComponent("mass", { mass: template.mass });
Expand Down Expand Up @@ -420,5 +420,10 @@ async function getMeshSize(url: string | null): Promise<Vector3> {
if (!gltf) return new Vector3();
const box = new Box3().setFromObject(gltf.scene.children[0]);

return box.getSize(new Vector3());
const vector = box.getSize(new Vector3()).normalize();
const { x } = vector;
// Rearrange the vector to match the orientation of the ship
vector.normalize().multiplyScalar(1 / x);

return vector;
}
5 changes: 3 additions & 2 deletions server/src/systems/ShieldsSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export class ShieldsSystem extends System {
const elapsedTimeHours = elapsed / 1000 / 60 / 60;

if (entity.components.power && entity.components.isShields) {
const { currentPower } = entity.components.power;
const { currentPower, requiredPower } = entity.components.power;
const { state, maxStrength, strength } = entity.components.isShields;
// Some space magic to make the shields more powerful.
let strengthToRecharge = currentPower * elapsedTimeHours * 10;
if (state === "down") {
if (state === "down" || currentPower < requiredPower) {
// Quickly drain shields when they are down
strengthToRecharge = (-maxStrength / SHIELD_DISCHARGE_TIME) * elapsed;
}
Expand Down

0 comments on commit d4b21fd

Please sign in to comment.