mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-21 12:16:54 +00:00
Fix border color changes edge cases (#754)
## Description: Fixes a couple of bugs with the defended border color: - When a defense post is destroyed it doesnt redraw defended border to normal ones - The distance to draw borders at unit update is not the same as territory update - When a defense post changes owner, only the directly touching borders were redrawn. Had to refactor units a bit so it keeps track of the last owner ## Gifs: Before fix:  After fix:   ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: VivaciousBox
This commit is contained in:
@@ -3,11 +3,7 @@ import { Colord } from "colord";
|
||||
import { Theme } from "../../../core/configuration/Config";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { Cell, PlayerType, UnitType } from "../../../core/game/Game";
|
||||
import {
|
||||
euclDistFN,
|
||||
manhattanDistFN,
|
||||
TileRef,
|
||||
} from "../../../core/game/GameMap";
|
||||
import { euclDistFN, TileRef } from "../../../core/game/GameMap";
|
||||
import { GameUpdateType, UnitUpdate } from "../../../core/game/GameUpdates";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { PseudoRandom } from "../../../core/PseudoRandom";
|
||||
@@ -64,17 +60,15 @@ export class TerritoryLayer implements Layer {
|
||||
this.game.recentlyUpdatedTiles().forEach((t) => this.enqueueTile(t));
|
||||
this.game.updatesSinceLastTick()[GameUpdateType.Unit].forEach((u) => {
|
||||
const update = u as UnitUpdate;
|
||||
if (update.unitType == UnitType.DefensePost && update.isActive) {
|
||||
if (update.unitType == UnitType.DefensePost) {
|
||||
const tile = update.pos;
|
||||
this.game
|
||||
.bfs(
|
||||
tile,
|
||||
manhattanDistFN(tile, this.game.config().defensePostRange()),
|
||||
)
|
||||
.bfs(tile, euclDistFN(tile, this.game.config().defensePostRange()))
|
||||
.forEach((t) => {
|
||||
if (
|
||||
this.game.isBorder(t) &&
|
||||
this.game.ownerID(t) == update.ownerID
|
||||
(this.game.ownerID(t) == update.ownerID ||
|
||||
this.game.ownerID(t) == update.lastOwnerID)
|
||||
) {
|
||||
this.enqueueTile(t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user