-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimizations to spawn locations and unit counts.
GitOrigin-RevId: cc665f4e0eac662dff639561609d05209c069942
- Loading branch information
Showing
18 changed files
with
212 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BuildingInfo } from '../info/Building.tsx'; | ||
import { ConstructionSite, Plain } from '../info/Tile.tsx'; | ||
import { PlayerID } from '../map/Player.tsx'; | ||
import Vector from '../map/Vector.tsx'; | ||
import MapData from '../MapData.tsx'; | ||
import writeTile from '../mutation/writeTile.tsx'; | ||
import canBuild from './canBuild.tsx'; | ||
|
||
export default function couldSpawnBuilding( | ||
map: MapData, | ||
vector: Vector, | ||
building: BuildingInfo, | ||
player: PlayerID, | ||
) { | ||
if (map.getTileInfo(vector) === Plain) { | ||
const tiles = map.map.slice(); | ||
const modifiers = map.modifiers.slice(); | ||
writeTile(tiles, modifiers, map.getTileIndex(vector), ConstructionSite); | ||
map = map.copy({ | ||
map: tiles, | ||
}); | ||
} | ||
|
||
return ( | ||
!map.buildings.has(vector) && canBuild(map, building, player, vector, true) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import getFirstOrThrow from '@deities/hephaestus/getFirstOrThrow.tsx'; | ||
import ImmutableMap from '@nkzw/immutable-map'; | ||
import Building from '../map/Building.tsx'; | ||
import Vector from '../map/Vector.tsx'; | ||
import MapData from '../MapData.tsx'; | ||
import writeTile from '../mutation/writeTile.tsx'; | ||
import withModifiers from './withModifiers.tsx'; | ||
|
||
export default function spawnBuildings( | ||
map: MapData, | ||
buildings: ImmutableMap<Vector, Building> | undefined, | ||
) { | ||
if (buildings?.size) { | ||
const tileMap = map.map.slice(); | ||
const modifiers = map.modifiers.slice(); | ||
for (const [vector, building] of buildings) { | ||
const { editorPlaceOn, placeOn } = building.info.configuration; | ||
const tiles = new Set([...(placeOn || []), ...editorPlaceOn]); | ||
if (!tiles.has(map.getTileInfo(vector))) { | ||
writeTile( | ||
tileMap, | ||
modifiers, | ||
map.getTileIndex(vector), | ||
getFirstOrThrow(tiles), | ||
); | ||
} | ||
} | ||
return withModifiers( | ||
map.copy({ buildings: map.buildings.merge(buildings), map: tileMap }), | ||
); | ||
} | ||
|
||
return map; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,6 @@ export default function Notice( | |
}, | ||
opacity: { | ||
duration: 0.15, | ||
ease: 'ease', | ||
}, | ||
}} | ||
> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.