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) {
|
||||
|
||||
static STIM_P = 10 / (latus.get('%humus.tps', 60) * 60);
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.growthElapsed = 0;
|
||||
|
@ -114,15 +112,15 @@ export default (latus) => class Plant extends decorate(Trait) {
|
|||
: [];
|
||||
}
|
||||
|
||||
tick() {
|
||||
tick(elapsed) {
|
||||
if ('client' === process.env.SIDE) {
|
||||
return;
|
||||
}
|
||||
if (this.growthCondition(this.growthConditionContext)) {
|
||||
const {growthStage} = this.entity;
|
||||
const stageSpec = this.params.stageSpecs[growthStage];
|
||||
if (Math.random() < this.constructor.STIM_P) {
|
||||
this.growthElapsed += 0.1;
|
||||
if (Math.random() < (4 / (60 / elapsed))) {
|
||||
this.growthElapsed += 0.25;
|
||||
}
|
||||
if ('growAt' in stageSpec) {
|
||||
if (this.growthElapsed >= stageSpec.growAt) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user