@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:191ff110356e8d8046e0ef05108b06809fad657d086d5e1821219966bbf1b8d7
|
||||
size 861938
|
||||
oid sha256:688b663c660bd9f92ec78bd1e4d0d10813bfb09ffe3c95408fab36a908553628
|
||||
size 962903
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a01502c651ee3de0a4350b3c7fc4c7e964a5a17ec6db031fe79524ed957fd516
|
||||
size 77563
|
||||
oid sha256:9adbc719ee8765117f5f1208f6121b6e5d417de1c62cbd6cbb9b127651830382
|
||||
size 109524
|
||||
|
After Width: | Height: | Size: 5.2 MiB |
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:468563187c9f4e2333c353d2822e21cd5859f363fa636a9f7acf88671d777e11
|
||||
size 47276113
|
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2adafebb258471fb88b16c16746f7468081e97f128910878740e6b1278003e94
|
||||
size 92412
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:af7d1113b0cb0bbcf626889fc242cc6eabb5a9b50e0eef9bf013334f7e3eb7fa
|
||||
size 70769
|
||||
oid sha256:c35f217cbc3c687e3ee7c25a410ce953b38637e106b8ea348caeca55bfeac394
|
||||
size 70555
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a1200717523a78bc2e98929a5d276458f9ce2041969fa54c40873ba08340b219
|
||||
size 5196595
|
||||
oid sha256:db1a0f44bc1b2fa66d18022d941e71063623d8036369739dc02e9b1c577a7d21
|
||||
size 5197244
|
||||
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 214 KiB |
Before Width: | Height: | Size: 484 KiB After Width: | Height: | Size: 503 KiB |
Before Width: | Height: | Size: 968 KiB After Width: | Height: | Size: 1014 KiB |
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8c334a9f100fce4647b4803d2a8270b30e26d53622b3717bdb81b3ea07f84aed
|
||||
size 150286082
|
||||
oid sha256:df7487fb5e8cb34cecee2519b9c3162a5107d2d7b1301c4a550904cfb108a015
|
||||
size 223361394
|
||||
|
After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 936 B |
After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.3 KiB |
@ -0,0 +1,34 @@
|
||||
import { Component } from "../component";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { Vector } from "../../core/vector";
|
||||
|
||||
export class EnergyConsumerComponent extends Component {
|
||||
static getId() {
|
||||
return "EnergyConsumer";
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
bufferSize: types.uint,
|
||||
perCharge: types.uint,
|
||||
stored: types.uint,
|
||||
batteryPosition: types.vector,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {number} param0.bufferSize How much energy this consumer can store
|
||||
* @param {number} param0.perCharge How much energy this consumer needs per charge
|
||||
* @param {Vector} param0.batteryPosition world space render offset of the battery icon
|
||||
*/
|
||||
constructor({ bufferSize = 3, perCharge = 1, batteryPosition = new Vector() }) {
|
||||
super();
|
||||
this.bufferSize = bufferSize;
|
||||
this.perCharge = perCharge;
|
||||
this.batteryPosition = batteryPosition;
|
||||
|
||||
this.stored = 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||
import { EnergyConsumerComponent } from "../components/energy_consumer";
|
||||
import { Loader } from "../../core/loader";
|
||||
import { DrawParameters } from "../../core/draw_parameters";
|
||||
import { Entity } from "../entity";
|
||||
import { enableImageSmoothing } from "../../core/buffer_utils";
|
||||
|
||||
export class EnergyConsumerSystem extends GameSystemWithFilter {
|
||||
constructor(root) {
|
||||
super(root, [EnergyConsumerComponent]);
|
||||
|
||||
this.batterySprites = [
|
||||
Loader.getSprite("sprites/wires/battery_empty.png"),
|
||||
Loader.getSprite("sprites/wires/battery_low.png"),
|
||||
Loader.getSprite("sprites/wires/battery_medium.png"),
|
||||
Loader.getSprite("sprites/wires/battery_full.png"),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws everything
|
||||
* @param {DrawParameters} parameters
|
||||
*/
|
||||
draw(parameters) {
|
||||
this.forEachMatchingEntityOnScreen(parameters, this.drawSingleEntity.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a given entity
|
||||
* @param {DrawParameters} parameters
|
||||
* @param {Entity} entity
|
||||
*/
|
||||
drawSingleEntity(parameters, entity) {
|
||||
const staticComp = entity.components.StaticMapEntity;
|
||||
const consumerComp = entity.components.EnergyConsumer;
|
||||
|
||||
const position = staticComp
|
||||
.getTileSpaceBounds()
|
||||
.getCenter()
|
||||
.toWorldSpace()
|
||||
.add(consumerComp.batteryPosition);
|
||||
|
||||
const percentage = consumerComp.stored / consumerComp.bufferSize;
|
||||
|
||||
const index = Math.floor(percentage * this.batterySprites.length);
|
||||
this.batterySprites[index].drawCachedCentered(parameters, position.x, position.y, 12);
|
||||
}
|
||||
}
|