Skip to content

Commit

Permalink
feat: add sky color to serverInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacThoman committed Jan 15, 2025
1 parent d75b541 commit e674132
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/client/core/Networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface ServerInfo {
version: string;
gameMode: string;
playerMaxHealth: number;
skyColor: string;
}

interface LastUploadedLocalPlayer {
Expand Down Expand Up @@ -68,6 +69,7 @@ export class Networking {
version: '',
gameMode: '',
playerMaxHealth: 0,
skyColor: '#000000',
};

this.setupSocketListeners();
Expand Down
2 changes: 2 additions & 0 deletions src/client/core/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ export class Renderer {

this.camera.quaternion.setFromEuler(euler);

this.scene.background = new THREE.Color(this.networking.getServerInfo().skyColor);

this.updateFramerate();
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/GameEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GameEngine {
private lastItemUpdateTimestamp: number = Date.now() / 1000;
public playerUpdateSinceLastEmit: boolean = false;
private itemUpdateSinceLastEmit: boolean = false;
private serverInfo: ServerInfo = new ServerInfo();
public serverInfo: ServerInfo = new ServerInfo();
public gamemode: Gamemode | false = false;

constructor(
Expand Down
4 changes: 4 additions & 0 deletions src/server/gamemodes/SoloCTFGamemode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export class SoloCTFGamemode extends FFAGamemode {
private announceWin(winner: Player): void {
this.isAnnouncingWin = true; // Set the flag to indicate win announcement
this.winner = winner;
this.gameEngine.serverInfo.skyColor = '#FFFFFF';
// Schedule to unset the win announcement flag after the respawn delay and reset the game
setTimeout(() => {
this.resetAfterWin();
Expand Down Expand Up @@ -383,6 +384,9 @@ export class SoloCTFGamemode extends FFAGamemode {
// Spawn a new flag
this.spawnFlag();

//set sky color to black
this.gameEngine.serverInfo.skyColor = '#000000';

// Reset game state
this.gameActive = true;
this.resetTimestamp = null;
Expand Down
2 changes: 2 additions & 0 deletions src/server/models/ServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export class ServerInfo {
public version: string = '';
public gameMode: string;
public playerMaxHealth: number;
public skyColor: string;
constructor() {
this.name = config.server.name;
this.maxPlayers = config.game.maxPlayers;
this.mapName = config.server.defaultMap;
this.tickRate = config.server.tickRate;
this.gameMode = config.game.mode;
this.playerMaxHealth = config.player.maxHealth;
this.skyColor = '#000000';
}
toJSON() {
return {
Expand Down

0 comments on commit e674132

Please sign in to comment.