mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 03:55:40 +00:00
thread_split: have structure layer draw updated structures
This commit is contained in:
@@ -308,6 +308,9 @@ export class GameView implements GameMap {
|
||||
units(...types: UnitType[]): UnitView[] {
|
||||
return Array.from(this._units.values())
|
||||
}
|
||||
unit(id: number): UnitView {
|
||||
return this._units.get(id)
|
||||
}
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
return this._config.unitInfo(type)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class DevConfig extends DefaultConfig {
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
const info = super.unitInfo(type)
|
||||
const oldCost = info.cost
|
||||
// info.cost = (p: Player) => oldCost(p) / 10000
|
||||
info.cost = (p: Player) => oldCost(p) / 10
|
||||
return info
|
||||
}
|
||||
|
||||
|
||||
@@ -389,10 +389,6 @@ export class GameImpl implements MutableGame {
|
||||
return false
|
||||
}
|
||||
|
||||
public fireUnitUpdateEvent(unit: Unit) {
|
||||
this.addUpdate((unit as UnitImpl).toUpdate())
|
||||
}
|
||||
|
||||
target(targeter: Player, target: Player) {
|
||||
this.addUpdate({
|
||||
type: GameUpdateType.TargetPlayer,
|
||||
|
||||
@@ -433,7 +433,7 @@ export class PlayerImpl implements MutablePlayer {
|
||||
(prev as PlayerImpl)._units = (prev as PlayerImpl)._units.filter(u => u != unit);
|
||||
(unit as UnitImpl)._owner = this
|
||||
this._units.push(unit as UnitImpl)
|
||||
this.mg.fireUnitUpdateEvent(unit)
|
||||
this.mg.addUpdate(unit.toUpdate())
|
||||
this.mg.displayMessage(`${unit.type()} captured by ${this.displayName()}`, MessageType.ERROR, prev.id())
|
||||
this.mg.displayMessage(`Captured ${unit.type()} from ${prev.displayName()}`, MessageType.SUCCESS, this.id())
|
||||
}
|
||||
@@ -444,7 +444,7 @@ export class PlayerImpl implements MutablePlayer {
|
||||
this._units.push(b);
|
||||
this.removeGold(cost)
|
||||
this.removeTroops(troops)
|
||||
this.mg.fireUnitUpdateEvent(b);
|
||||
this.mg.addUpdate(b.toUpdate());
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export class UnitImpl implements MutableUnit {
|
||||
}
|
||||
this._lastTile = this._tile
|
||||
this._tile = tile;
|
||||
this.mg.fireUnitUpdateEvent(this);
|
||||
this.mg.addUpdate(this.toUpdate());
|
||||
}
|
||||
setTroops(troops: number): void {
|
||||
this._troops = troops;
|
||||
@@ -82,7 +82,7 @@ export class UnitImpl implements MutableUnit {
|
||||
const oldOwner = this._owner
|
||||
oldOwner._units = oldOwner._units.filter(u => u != this)
|
||||
this._owner = newOwner as PlayerImpl
|
||||
this.mg.fireUnitUpdateEvent(this)
|
||||
this.mg.addUpdate(this.toUpdate())
|
||||
this.mg.displayMessage(
|
||||
`Your ${this.type()} was captured by ${newOwner.displayName()}`,
|
||||
MessageType.ERROR,
|
||||
@@ -105,7 +105,7 @@ export class UnitImpl implements MutableUnit {
|
||||
}
|
||||
this._owner._units = this._owner._units.filter(b => b != this);
|
||||
this._active = false;
|
||||
this.mg.fireUnitUpdateEvent(this);
|
||||
this.mg.addUpdate(this.toUpdate());
|
||||
if (displayMessage) {
|
||||
this.mg.displayMessage(`Your ${this.type()} was destroyed`, MessageType.ERROR, this.owner().id())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user