update packet, add 'eventCounts'
This commit is contained in:
parent
b42eaaa67e
commit
1ba4371b14
5 changed files with 167 additions and 22 deletions
|
|
@ -7,7 +7,7 @@ interface FactorioEventUpdateKey {
|
|||
}
|
||||
|
||||
interface FactorioEventUpdate extends FactorioEventUpdateKey {
|
||||
events: string[] | null;
|
||||
eventCounts: { [key: string]: int } | null;
|
||||
updateType: FactorioEventUpdateType;
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ interface PlayerUpdate extends FactorioEventUpdate, PlayerUpdateKey {
|
|||
colour: Colour | null;
|
||||
diedCause: EntityIdentifiers | null;
|
||||
disconnectReason: string | null;
|
||||
events: string[] | null;
|
||||
eventCounts: { [key: string]: int } | null;
|
||||
forceIndex: uint | null;
|
||||
index: uint;
|
||||
isAdmin: boolean | null;
|
||||
|
|
@ -57,7 +57,7 @@ interface EntityUpdateKey extends EntityIdentifiers, FactorioEventUpdateKey {
|
|||
|
||||
interface EntityUpdate extends FactorioEventUpdate, EntityIdentifiers, EntityUpdateKey {
|
||||
chunkPosition: MapChunkPosition | null;
|
||||
events: string[] | null;
|
||||
eventCounts: { [key: string]: int } | null;
|
||||
graphicsVariation: number | null;
|
||||
health: float | null;
|
||||
isActive: boolean | null;
|
||||
|
|
@ -79,7 +79,7 @@ interface MapChunkUpdateKey extends FactorioEventUpdateKey {
|
|||
|
||||
interface MapChunkUpdate extends FactorioEventUpdate, MapChunkUpdateKey {
|
||||
chunkPosition: MapChunkPosition;
|
||||
events: string[] | null;
|
||||
eventCounts: { [key: string]: int } | null;
|
||||
force: uint | null;
|
||||
isDeleted: boolean | null;
|
||||
player: uint | null;
|
||||
|
|
|
|||
|
|
@ -41,12 +41,10 @@ function mapTilesUpdateDebounce(
|
|||
)
|
||||
}
|
||||
|
||||
if (data.events == null) {
|
||||
data.events = []
|
||||
}
|
||||
if (eventName ! in data.events) {
|
||||
data.events.push(eventName)
|
||||
if (data.eventCounts == undefined) {
|
||||
data.eventCounts = {}
|
||||
}
|
||||
data.eventCounts[eventName] = ((data.eventCounts ?? {}) [eventName] ?? 0) + 1
|
||||
|
||||
if (updater != undefined) {
|
||||
updater(data)
|
||||
|
|
@ -111,7 +109,7 @@ script.on_event(
|
|||
const groupedTiles = groupTiles(e.tiles)
|
||||
|
||||
for (const [chunkPos, tiles] of groupedTiles) {
|
||||
mapTilesUpdateDebounce(surface, chunkPos, tiles, Converters.eventNameString(e.name))
|
||||
mapTilesUpdateDebounce(surface, chunkPos, tiles, Converters.eventNameString(e.name))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ function playerUpdateThrottle(
|
|||
mutate(player, data)
|
||||
}
|
||||
|
||||
if (data.events == null) {
|
||||
data.events = []
|
||||
if (data.eventCounts == undefined) {
|
||||
data.eventCounts = {}
|
||||
}
|
||||
data.events.push(eventName)
|
||||
data.eventCounts[eventName] = ((data.eventCounts ?? {}) [eventName] ?? 0) + 1
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
@ -57,6 +57,7 @@ script.on_event(
|
|||
data.name = player.name
|
||||
data.isShowOnMap = player.show_on_map
|
||||
data.isSpectator = player.spectator
|
||||
data.surfaceIndex = player.surface.index
|
||||
data.tag = player.tag
|
||||
playerOnlineInfo(player, data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue