Compare commits

...

2 Commits

Author SHA1 Message Date
e15cc0e410 Add ctrl object & range 2022-02-18 16:17:39 +08:00
b10b614113 Add individuals metadata 2022-02-18 14:38:30 +08:00
4 changed files with 53 additions and 8 deletions

View File

@ -0,0 +1,24 @@
import { LabelObject } from "./Label"
import type { Model } from "./Model";
/**
*
*/
class CtrlObject extends LabelObject {
/**
*
*/
protected model: Model;
/**
*
*/
public constructor(model: Model) {
super();
this.model = model;
}
}
export default CtrlObject;
export { CtrlObject };

View File

@ -1,11 +1,12 @@
import { Individual } from "./Individual"; import { Individual } from "./Individual";
import { CtrlObject } from "./CtrlObject";
import type { Behavior } from "./Behavior"; import type { Behavior } from "./Behavior";
import type { Model } from "./Model"; import type { Model } from "./Model";
/** /**
* *
*/ */
class Group { class Group extends CtrlObject {
/** /**
* *
@ -111,10 +112,10 @@ class Group {
* *
* @param * @param
*/ */
public runner(model: Model, t: number): void { public runner(t: number): void {
this.individuals.forEach((individual) => { this.individuals.forEach((individual) => {
for(let j = 0; j < this.behaviors.length; j++) { for(let j = 0; j < this.behaviors.length; j++) {
this.behaviors[j].effect(individual, this, model, t); this.behaviors[j].effect(individual, this, this.model, t);
} }
}); });
} }

View File

@ -44,20 +44,20 @@ class LabelObject {
/** /**
* *
*/ */
private labels: Set<Label> = new Set(); private labels: Label[] = [];
/** /**
* Label * Label
*/ */
public allLabels(): Label[] { public allLabels(): Label[] {
return Array.from(this.labels); return this.labels.concat([]);
} }
/** /**
* *
*/ */
public addLabel(label: Label): this { public addLabel(label: Label): this {
this.labels.add(label); this.labels.push(label);
return this; return this;
} }
@ -65,7 +65,9 @@ class LabelObject {
* *
*/ */
public removeLabel(label: Label): this { public removeLabel(label: Label): this {
this.labels.delete(label); this.labels = this.labels.filter((localLabel) => {
return !localLabel.equal(label);
});
return this; return this;
} }
@ -79,4 +81,6 @@ class LabelObject {
}); });
return has; return has;
} }
} }
export { Label, LabelObject };

16
source/Model/Range.ts Normal file
View File

@ -0,0 +1,16 @@
import { CtrlObject } from "./CtrlObject";
/**
*
*/
class Range extends CtrlObject {
/**
*
*/
public position: number[] = [];
}
export default Range;
export { Range };