refactor: time-based ticks
This commit is contained in:
parent
0ff8b73ffd
commit
43851a275a
|
@ -10,8 +10,6 @@ const decorate = compose(
|
||||||
|
|
||||||
export default (latus) => class Plant extends decorate(Trait) {
|
export default (latus) => class Plant extends decorate(Trait) {
|
||||||
|
|
||||||
static STIM_P = 10 / (latus.get('%humus.tps', 60) * 60);
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.growthElapsed = 0;
|
this.growthElapsed = 0;
|
||||||
|
@ -114,15 +112,15 @@ export default (latus) => class Plant extends decorate(Trait) {
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick(elapsed) {
|
||||||
if ('client' === process.env.SIDE) {
|
if ('client' === process.env.SIDE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.growthCondition(this.growthConditionContext)) {
|
if (this.growthCondition(this.growthConditionContext)) {
|
||||||
const {growthStage} = this.entity;
|
const {growthStage} = this.entity;
|
||||||
const stageSpec = this.params.stageSpecs[growthStage];
|
const stageSpec = this.params.stageSpecs[growthStage];
|
||||||
if (Math.random() < this.constructor.STIM_P) {
|
if (Math.random() < (4 / (60 / elapsed))) {
|
||||||
this.growthElapsed += 0.1;
|
this.growthElapsed += 0.25;
|
||||||
}
|
}
|
||||||
if ('growAt' in stageSpec) {
|
if ('growAt' in stageSpec) {
|
||||||
if (this.growthElapsed >= stageSpec.growAt) {
|
if (this.growthElapsed >= stageSpec.growAt) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user