Hullaballoonatic
05/27/2019, 6:21 PMsetA to also setB when called, and setB to also setA when called, but not infinite loop them? One calls the other but doesn't allow itself to be called again.Hullaballoonatic
05/27/2019, 6:21 PMHullaballoonatic
05/27/2019, 6:22 PMHullaballoonatic
05/27/2019, 6:23 PMHullaballoonatic
05/27/2019, 6:25 PMHullaballoonatic
05/27/2019, 6:29 PMSynchronized annotation to both setterslouis993546
05/27/2019, 6:50 PMfun setAB(thing: String) {
a = thing
b = thing
}Hullaballoonatic
05/27/2019, 6:51 PMHullaballoonatic
05/27/2019, 6:52 PMlouis993546
05/27/2019, 6:56 PMHullaballoonatic
05/27/2019, 6:58 PMinterface Temporary : Effect {
val duration: ComparableQuantity<Time>
var elapsed: ComparableQuantity<Time>
val remaining: ComparableQuantity<Time> get() = duration - elapsed
@Synchronized
fun age(duration: ComparableQuantity<Time>) {
elapsed += duration
if (this is IsPeriodic)
tick(duration)
if (elapsed >= duration)
end()
}
}
interface IsPeriodic {
val tickPeriod: ComparableQuantity<Time>
var numTicks: Int
fun tick(period: ComparableQuantity<Time>) = tick((period / tickPeriod).valueToInt())
@Synchronized
fun tick(times: Int = 1) {
numTicks += times
if (this is Temporary) age(tickPeriod * times)
repeat(numTicks) { onTick() }
}
fun onTick()
}louis993546
05/27/2019, 8:08 PMif (this is SomeOtherRandomInterface) {} feels like a potential code smell, and I'd rather KISS for now.Hullaballoonatic
05/27/2019, 8:09 PMHullaballoonatic
05/27/2019, 8:10 PMHullaballoonatic
05/27/2019, 8:10 PMDico
05/28/2019, 1:39 PMDico
05/28/2019, 1:43 PMage and tickDico
05/28/2019, 1:46 PMHullaballoonatic
05/28/2019, 3:18 PMHullaballoonatic
05/28/2019, 5:15 PMHullaballoonatic
05/28/2019, 5:27 PMTemporary and Periodic, or mix and match, or all at once, and to keep things streamlined I want to pull that all out into separate interfaces. Now I'm just not sure the best way to do that.Dico
05/28/2019, 5:44 PMDico
05/28/2019, 5:45 PMeffect is Periodic you check something like effect has attribute PeriodicDico
05/28/2019, 5:46 PMDico
05/28/2019, 5:46 PMHullaballoonatic
05/28/2019, 6:03 PM