mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
chargeStored for Electric FixtureBase
This commit is contained in:
@@ -12,6 +12,7 @@ import net.torvald.terrarum.ui.UICanvas
|
|||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.HashMap
|
||||||
|
|
||||||
typealias BlockBoxIndex = Int
|
typealias BlockBoxIndex = Int
|
||||||
typealias WireEmissionType = String
|
typealias WireEmissionType = String
|
||||||
@@ -66,11 +67,17 @@ open class Electric : FixtureBase {
|
|||||||
fun setWireEmissionAt(x: Int, y: Int, emission: Vector2) { wireEmission[pointToBlockBoxIndex(x, y)] = emission }
|
fun setWireEmissionAt(x: Int, y: Int, emission: Vector2) { wireEmission[pointToBlockBoxIndex(x, y)] = emission }
|
||||||
fun setWireConsumptionAt(x: Int, y: Int, consumption: Vector2) { wireConsumption[pointToBlockBoxIndex(x, y)] = consumption }
|
fun setWireConsumptionAt(x: Int, y: Int, consumption: Vector2) { wireConsumption[pointToBlockBoxIndex(x, y)] = consumption }
|
||||||
|
|
||||||
|
// these are characteristic properties of the fixture (they have constant value) so must not be serialised
|
||||||
@Transient val wireEmitterTypes: HashMap<BlockBoxIndex, WireEmissionType> = HashMap()
|
@Transient val wireEmitterTypes: HashMap<BlockBoxIndex, WireEmissionType> = HashMap()
|
||||||
@Transient val wireSinkTypes: HashMap<BlockBoxIndex, WireEmissionType> = HashMap()
|
@Transient val wireSinkTypes: HashMap<BlockBoxIndex, WireEmissionType> = HashMap()
|
||||||
@Transient val wireEmission: HashMap<BlockBoxIndex, Vector2> = HashMap()
|
@Transient val wireEmission: HashMap<BlockBoxIndex, Vector2> = HashMap()
|
||||||
@Transient val wireConsumption: HashMap<BlockBoxIndex, Vector2> = HashMap()
|
@Transient val wireConsumption: HashMap<BlockBoxIndex, Vector2> = HashMap()
|
||||||
|
|
||||||
|
// these are NOT constant so they ARE serialised. Type: Map<SinkType (String) -> Charge (Double>
|
||||||
|
// Use case: signal buffer (sinkType=digital_bit), battery (sinkType=electricity), etc.
|
||||||
|
val chargeStored: HashMap<String, Double> = HashMap()
|
||||||
|
|
||||||
|
|
||||||
/** Triggered when 'digital_bit' rises from low to high. Edge detection only considers the real component (labeled as 'x') of the vector */
|
/** Triggered when 'digital_bit' rises from low to high. Edge detection only considers the real component (labeled as 'x') of the vector */
|
||||||
open fun onRisingEdge(readFrom: BlockBoxIndex) {}
|
open fun onRisingEdge(readFrom: BlockBoxIndex) {}
|
||||||
/** Triggered when 'digital_bit' rises from high to low. Edge detection only considers the real component (labeled as 'x') of the vector */
|
/** Triggered when 'digital_bit' rises from high to low. Edge detection only considers the real component (labeled as 'x') of the vector */
|
||||||
|
|||||||
Reference in New Issue
Block a user