Compare commits
No commits in common. "e15cc0e410c75191ff0a2d8b1201b6bfe2ca2021" and "c1dde87e300b734793e8434d7d41129681f7ed1f" have entirely different histories.
e15cc0e410
...
c1dde87e30
@ -1,24 +0,0 @@
|
||||
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 };
|
@ -1,12 +1,11 @@
|
||||
import { Individual } from "./Individual";
|
||||
import { CtrlObject } from "./CtrlObject";
|
||||
import type { Behavior } from "./Behavior";
|
||||
import type { Model } from "./Model";
|
||||
|
||||
/**
|
||||
* 群体类型
|
||||
*/
|
||||
class Group extends CtrlObject {
|
||||
class Group {
|
||||
|
||||
/**
|
||||
* 所有个体
|
||||
@ -112,10 +111,10 @@ class Group extends CtrlObject {
|
||||
* 执行行为影响
|
||||
* @param
|
||||
*/
|
||||
public runner(t: number): void {
|
||||
public runner(model: Model, t: number): void {
|
||||
this.individuals.forEach((individual) => {
|
||||
for(let j = 0; j < this.behaviors.length; j++) {
|
||||
this.behaviors[j].effect(individual, this, this.model, t);
|
||||
this.behaviors[j].effect(individual, this, model, t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -44,20 +44,20 @@ class LabelObject {
|
||||
/**
|
||||
* 标签集合
|
||||
*/
|
||||
private labels: Label[] = [];
|
||||
private labels: Set<Label> = new Set();
|
||||
|
||||
/**
|
||||
* 获取全部 Label
|
||||
*/
|
||||
public allLabels(): Label[] {
|
||||
return this.labels.concat([]);
|
||||
return Array.from(this.labels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
*/
|
||||
public addLabel(label: Label): this {
|
||||
this.labels.push(label);
|
||||
this.labels.add(label);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -65,9 +65,7 @@ class LabelObject {
|
||||
* 移除标签
|
||||
*/
|
||||
public removeLabel(label: Label): this {
|
||||
this.labels = this.labels.filter((localLabel) => {
|
||||
return !localLabel.equal(label);
|
||||
});
|
||||
this.labels.delete(label);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -82,5 +80,3 @@ class LabelObject {
|
||||
return has;
|
||||
}
|
||||
}
|
||||
|
||||
export { Label, LabelObject };
|
@ -1,16 +0,0 @@
|
||||
import { CtrlObject } from "./CtrlObject";
|
||||
|
||||
/**
|
||||
* 范围
|
||||
*/
|
||||
class Range extends CtrlObject {
|
||||
|
||||
/**
|
||||
* 坐标
|
||||
*/
|
||||
public position: number[] = [];
|
||||
|
||||
}
|
||||
|
||||
export default Range;
|
||||
export { Range };
|
Loading…
Reference in New Issue
Block a user