Add modular
This commit is contained in:
parent
e188fc83bd
commit
f999fc1268
@ -1,9 +1,23 @@
|
||||
import { Individual } from "./Individual";
|
||||
|
||||
/**
|
||||
* 群体类型
|
||||
*/
|
||||
class Group {
|
||||
|
||||
/**
|
||||
* 所有成员
|
||||
*/
|
||||
public individuals: Individual[] = [];
|
||||
|
||||
/**
|
||||
* 添加一个成员
|
||||
*/
|
||||
public add(count: number = 1) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
this.individuals.push(new Individual(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Group;
|
||||
|
@ -1,9 +1,26 @@
|
||||
import type { Group } from "./Group";
|
||||
|
||||
/**
|
||||
* 群中的个体类型
|
||||
*/
|
||||
class Individual {
|
||||
|
||||
/**
|
||||
* 坐标
|
||||
*/
|
||||
public position: number[] = [0, 0, 0];
|
||||
|
||||
/**
|
||||
* 所属群组
|
||||
*/
|
||||
public group: Group;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public constructor(group: Group) {
|
||||
this.group = group;
|
||||
}
|
||||
}
|
||||
|
||||
export default Individual;
|
||||
|
Loading…
Reference in New Issue
Block a user