Skip to content

Commit

Permalink
Merge pull request #1154 from solaris-games/dev
Browse files Browse the repository at this point in the history
Update 245
  • Loading branch information
SpacialCircumstances authored Sep 8, 2024
2 parents 4f29b18 + 6dedfa1 commit b820737
Show file tree
Hide file tree
Showing 88 changed files with 1,177 additions and 529 deletions.
66 changes: 33 additions & 33 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@pixi/graphics-extras": "^7.4.0",
"@popperjs/core": "^2.11.5",
"axios": "^1.6.7",
"axios": "^1.7.4",
"bootstrap": "^5.1.3",
"chart.js": "^2.9.4",
"core-js": "^3.8.3",
Expand Down
5 changes: 3 additions & 2 deletions client/src/game/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class Background {
this.time = 0
}

setup (game, userSettings) {
setup (game, userSettings, context) {
this.game = game
this.context = context
this.userSettings = userSettings
this.rng = rng.create(game._id)
// TODO: This should use the constant?
Expand Down Expand Up @@ -124,7 +125,7 @@ class Background {
let sprite
let nebulaTextureCount
let textures

nebulaTextureCount = TextureService.STARLESS_NEBULA_TEXTURES.length
textures = TextureService.STARLESS_NEBULA_TEXTURES

Expand Down
5 changes: 3 additions & 2 deletions client/src/game/carrier.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ class Carrier extends EventEmitter {
this.zoomPercent = 100
}

setup (data, userSettings, stars, player, lightYearDistance) {
setup (data, userSettings, context, stars, player, lightYearDistance) {
this.data = data
this.stars = stars
this.player = player
this.colour = player.colour.value
this.context = context
this.colour = context.getPlayerColour(player._id)
this.lightYearDistance = lightYearDistance

this.container.position.x = data.location.x
Expand Down
18 changes: 15 additions & 3 deletions client/src/game/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import Map from './map'
import gameHelper from '../services/gameHelper'
import textureService from './texture'

class DrawingContext {
constructor (store) {
this.store = store;
}

getPlayerColour (playerId) {
return this.store.getters.getColourForPlayer(playerId).value
}
}

class GameContainer {


Expand Down Expand Up @@ -69,6 +79,8 @@ class GameContainer {
setupApp (store, userSettings) {
this.store = store

this.context = new DrawingContext(store)

// Cleanup if the app already exists.
this.destroy()

Expand Down Expand Up @@ -112,7 +124,7 @@ class GameContainer {
this.app.stage.addChild(this.viewport)

// Add a new map to the viewport
this.map = new Map(this.app, this.store, this)
this.map = new Map(this.app, this.store, this, this.context)
this.viewport.addChild(this.map.container)
}

Expand Down Expand Up @@ -173,11 +185,11 @@ class GameContainer {
this.viewport.on('pointerdown', this.map.onViewportPointerDown.bind(this.map))
}

setup (game, userSettings) {
setup (game, userSettings, context) {
this.userSettings = userSettings
textureService.initialize()

this.map.setup(this.game, userSettings)
this.map.setup(this.game, userSettings, context)
}

draw () {
Expand Down
31 changes: 16 additions & 15 deletions client/src/game/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ class Map extends EventEmitter {
// waypoints - Displays waypoints overlay for a given carrier
mode = 'galaxy'

constructor (app, store, gameContainer) {
constructor (app, store, gameContainer, context) {
super()

this.app = app
this.store = store
this.context = context
this.gameContainer = gameContainer;
this.container = new PIXI.Container()
this.container.sortableChildren = true
Expand Down Expand Up @@ -107,7 +108,7 @@ class Map extends EventEmitter {
}

this.waypoints = new Waypoints()
this.waypoints.setup(game)
this.waypoints.setup(game, this.context)
this.waypoints.onWaypointCreatedHandler = this.waypoints.on('onWaypointCreated', this.onWaypointCreated.bind(this))
this.waypoints.onWaypointOutOfRangeHandler = this.waypoints.on('onWaypointOutOfRange', this.onWaypointOutOfRange.bind(this))

Expand All @@ -130,23 +131,23 @@ class Map extends EventEmitter {
// -----------
// Setup Territories
this.territories = new Territories()
this.territories.setup(game, userSettings)
this.territories.setup(game, userSettings, this.context)

this.territoryContainer.addChild(this.territories.container)
this.territories.draw(userSettings)

// -----------
// Setup Player Names
this.playerNames = new PlayerNames()
this.playerNames.setup(game, userSettings)
this.playerNames.setup(game, userSettings, this.context)

this.playerNamesContainer.addChild(this.playerNames.container)
this.playerNames.draw()

// -----------
// Setup Background
this.background = new Background()
this.background.setup(game, userSettings)
this.background.setup(game, userSettings, this.context)

this.backgroundContainer.addChild(this.background.container)
this.backgroundContainer.addChild(this.background.starContainer)
Expand All @@ -173,7 +174,7 @@ class Map extends EventEmitter {
this._setupChunks()

this.tooltipLayer = new TooltipLayer()
this.tooltipLayer.setup(this.game)
this.tooltipLayer.setup(this.game, this.context)
this.tooltipContainer.addChild(this.tooltipLayer.container)
}

Expand All @@ -195,7 +196,7 @@ class Map extends EventEmitter {
star.on('onUnselected', this.onStarUnselected.bind(this))
}

star.setup(this.game, starData, userSettings, game.galaxy.players, game.galaxy.carriers, game.constants.distances.lightYear)
star.setup(this.game, starData, userSettings, this.context, game.galaxy.players, game.galaxy.carriers, game.constants.distances.lightYear)

return star
}
Expand All @@ -219,7 +220,7 @@ class Map extends EventEmitter {

let player = gameHelper.getPlayerById(game, carrierData.ownedByPlayerId)

carrier.setup(carrierData, userSettings, this.stars, player, game.constants.distances.lightYear)
carrier.setup(carrierData, userSettings, this.context, this.stars, player, game.constants.distances.lightYear)

return carrier
}
Expand Down Expand Up @@ -394,7 +395,7 @@ class Map extends EventEmitter {
let existing = this.stars.find(x => x.data._id === starData._id)

if (existing) {
existing.setup(this.game, starData, userSettings, game.galaxy.players, game.galaxy.carriers, game.constants.distances.lightYear)
existing.setup(this.game, starData, userSettings, this.context, game.galaxy.players, game.galaxy.carriers, game.constants.distances.lightYear)
} else {
existing = this.setupStar(game, userSettings, starData)
}
Expand All @@ -411,7 +412,7 @@ class Map extends EventEmitter {
if (existing) {
let player = gameHelper.getPlayerById(game, carrierData.ownedByPlayerId)

existing.setup(carrierData, userSettings, this.stars, player, game.constants.distances.lightYear)
existing.setup(carrierData, userSettings, this.context, this.stars, player, game.constants.distances.lightYear)
} else {
existing = this.setupCarrier(game, userSettings, carrierData)
}
Expand All @@ -423,11 +424,11 @@ class Map extends EventEmitter {
this.drawWormHoles()
this.drawPlayerNames()

this.background.setup(game, userSettings)
this.background.setup(game, userSettings, this.context)
this.background.draw(game, userSettings)

this.waypoints.setup(game)
this.tooltipLayer.setup(game)
this.waypoints.setup(game, this.context)
this.tooltipLayer.setup(game, this.context)

this._setupChunks()
}
Expand Down Expand Up @@ -567,7 +568,7 @@ class Map extends EventEmitter {
}

drawTerritories (userSettings) {
this.territories.setup(this.game, userSettings)
this.territories.setup(this.game, userSettings, this.context)
this.territories.draw(userSettings)
}

Expand All @@ -579,7 +580,7 @@ class Map extends EventEmitter {
}

drawPlayerNames () {
this.playerNames.setup(this.game, this.userSettings)
this.playerNames.setup(this.game, this.userSettings, this.context)
this.playerNames.draw(this.userSettings)
}

Expand Down
Loading

0 comments on commit b820737

Please sign in to comment.