测试用例更新
This commit is contained in:
@@ -5,14 +5,20 @@ import { Component } from '../../../src/ECS/Component';
|
||||
|
||||
// 测试用组件
|
||||
class TestComponent extends Component {
|
||||
constructor(public value: number = 0) {
|
||||
public value: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
if (args.length >= 1) this.value = args[0] as number;
|
||||
}
|
||||
}
|
||||
|
||||
class AnotherTestComponent extends Component {
|
||||
constructor(public name: string = 'test') {
|
||||
public name: string = 'test';
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
if (args.length >= 1) this.name = args[0] as string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,26 +9,48 @@ import { BigIntFactory } from '../../../src/ECS/Utils/BigIntCompatibility';
|
||||
|
||||
// 测试组件类(默认使用原始存储)
|
||||
class TestComponent extends Component {
|
||||
constructor(public value: number = 0) {
|
||||
public value: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [value = 0] = args as [number?];
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [x = 0, y = 0] = args as [number?, number?];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number;
|
||||
public vy: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [vx = 0, vy = 0] = args as [number?, number?];
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100, public maxHealth: number = 100) {
|
||||
public health: number;
|
||||
public maxHealth: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [health = 100, maxHealth = 100] = args as [number?, number?];
|
||||
this.health = health;
|
||||
this.maxHealth = maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,20 +7,37 @@ import { EventBus } from '../../../src/ECS/Core/EventBus';
|
||||
|
||||
// 测试组件
|
||||
class TransformComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0, public rotation: number = 0) {
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
public rotation: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
if (args.length >= 1) this.x = args[0] as number;
|
||||
if (args.length >= 2) this.y = args[1] as number;
|
||||
if (args.length >= 3) this.rotation = args[2] as number;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number = 0;
|
||||
public vy: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
if (args.length >= 1) this.vx = args[0] as number;
|
||||
if (args.length >= 2) this.vy = args[1] as number;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100, public maxHealth: number = 100) {
|
||||
public health: number = 100;
|
||||
public maxHealth: number = 100;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
if (args.length >= 1) this.health = args[0] as number;
|
||||
if (args.length >= 2) this.maxHealth = args[1] as number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,38 +4,70 @@ import { Component } from '../../../src/ECS/Component';
|
||||
|
||||
// 测试组件
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [x = 0, y = 0] = args as [number?, number?];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number;
|
||||
public vy: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [vx = 0, vy = 0] = args as [number?, number?];
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100, public maxHealth: number = 100) {
|
||||
public health: number;
|
||||
public maxHealth: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [health = 100, maxHealth = 100] = args as [number?, number?];
|
||||
this.health = health;
|
||||
this.maxHealth = maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
class RenderComponent extends Component {
|
||||
constructor(public visible: boolean = true, public color: string = 'white') {
|
||||
public visible: boolean;
|
||||
public color: string;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [visible = true, color = 'white'] = args as [boolean?, string?];
|
||||
this.visible = visible;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
class AIComponent extends Component {
|
||||
constructor(public intelligence: number = 50) {
|
||||
public intelligence: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [intelligence = 50] = args as [number?];
|
||||
this.intelligence = intelligence;
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerComponent extends Component {
|
||||
constructor(public name: string = 'Player') {
|
||||
public name: string;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [name = 'Player'] = args as [string?];
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,20 +18,36 @@ import { Matcher } from '../../../src/ECS/Utils/Matcher';
|
||||
|
||||
// 测试组件
|
||||
class TestComponent extends Component {
|
||||
constructor(public value: number = 0) {
|
||||
public value: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [value = 0] = args as [number?];
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [x = 0, y = 0] = args as [number?, number?];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number;
|
||||
public vy: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [vx = 0, vy = 0] = args as [number?, number?];
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,38 +5,70 @@ import { ComponentRegistry, ComponentType } from '../../../src/ECS/Core/Componen
|
||||
|
||||
// 测试组件
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [x = 0, y = 0] = args as [number?, number?];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number;
|
||||
public vy: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [vx = 0, vy = 0] = args as [number?, number?];
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100, public maxHealth: number = 100) {
|
||||
public health: number;
|
||||
public maxHealth: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [health = 100, maxHealth = 100] = args as [number?, number?];
|
||||
this.health = health;
|
||||
this.maxHealth = maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
class RenderComponent extends Component {
|
||||
constructor(public visible: boolean = true, public layer: number = 0) {
|
||||
public visible: boolean;
|
||||
public layer: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [visible = true, layer = 0] = args as [boolean?, number?];
|
||||
this.visible = visible;
|
||||
this.layer = layer;
|
||||
}
|
||||
}
|
||||
|
||||
class AIComponent extends Component {
|
||||
constructor(public behavior: string = 'idle') {
|
||||
public behavior: string;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [behavior = 'idle'] = args as [string?];
|
||||
this.behavior = behavior;
|
||||
}
|
||||
}
|
||||
|
||||
class PhysicsComponent extends Component {
|
||||
constructor(public mass: number = 1.0) {
|
||||
public mass: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [mass = 1.0] = args as [number?];
|
||||
this.mass = mass;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,26 +6,42 @@ import { Matcher } from '../../../src/ECS/Utils/Matcher';
|
||||
|
||||
// 测试组件
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
this.x = (args[0] as number) ?? 0;
|
||||
this.y = (args[1] as number) ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number;
|
||||
public vy: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
this.vx = (args[0] as number) ?? 0;
|
||||
this.vy = (args[1] as number) ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100) {
|
||||
public health: number;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
this.health = (args[0] as number) ?? 100;
|
||||
}
|
||||
}
|
||||
|
||||
class TagComponent extends Component {
|
||||
constructor(public tag: string = '') {
|
||||
public tag: string;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
this.tag = (args[0] as string) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,12 @@ import { EntitySystem } from '../../../src/ECS/Systems/EntitySystem';
|
||||
import { ComponentTypeManager } from '../../../src/ECS/Utils/ComponentTypeManager';
|
||||
|
||||
class TestComponent extends Component {
|
||||
constructor(public value: number = 0) {
|
||||
public value: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [value = 0] = args as [number?];
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +30,7 @@ class TrackingSystem extends EntitySystem {
|
||||
}
|
||||
}
|
||||
|
||||
public override onChanged(entity: Entity): void {
|
||||
public onChanged(entity: Entity): void {
|
||||
this.onChangedCallCount++;
|
||||
if (this.isInterestedEntity(entity)) {
|
||||
if (!this.trackedEntities.includes(entity)) {
|
||||
|
||||
@@ -6,20 +6,36 @@ import { Matcher } from '../../../src/ECS/Utils/Matcher';
|
||||
|
||||
// 测试组件
|
||||
class PositionComponent extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [x = 0, y = 0] = args as [number?, number?];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
class VelocityComponent extends Component {
|
||||
constructor(public vx: number = 0, public vy: number = 0) {
|
||||
public vx: number = 0;
|
||||
public vy: number = 0;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [vx = 0, vy = 0] = args as [number?, number?];
|
||||
this.vx = vx;
|
||||
this.vy = vy;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthComponent extends Component {
|
||||
constructor(public health: number = 100) {
|
||||
public health: number = 100;
|
||||
|
||||
constructor(...args: unknown[]) {
|
||||
super();
|
||||
const [health = 100] = args as [number?];
|
||||
this.health = health;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user