Feature/physics and tilemap enhancement (#247)
* feat(behavior-tree,tilemap): 修复编辑器连线缩放问题并增强插件系统 * feat(node-editor,blueprint): 新增通用节点编辑器和蓝图可视化脚本系统 * feat(editor,tilemap): 优化编辑器UI样式和Tilemap编辑器功能 * fix: 修复CodeQL安全警告和CI类型检查错误 * fix: 修复CodeQL安全警告和CI类型检查错误 * fix: 修复CodeQL安全警告和CI类型检查错误
This commit is contained in:
@@ -23,19 +23,40 @@ import type { Vector2 } from '../types/Physics2DTypes';
|
||||
@ECSComponent('BoxCollider2D')
|
||||
@Serializable({ version: 1, typeId: 'BoxCollider2D' })
|
||||
export class BoxCollider2DComponent extends Collider2DBase {
|
||||
private _width: number = 10;
|
||||
private _height: number = 10;
|
||||
|
||||
/**
|
||||
* 矩形宽度(半宽度的2倍)
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'number', label: 'Width', min: 0.01, step: 0.1 })
|
||||
public width: number = 10;
|
||||
public get width(): number {
|
||||
return this._width;
|
||||
}
|
||||
|
||||
public set width(value: number) {
|
||||
if (this._width !== value) {
|
||||
this._width = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 矩形高度(半高度的2倍)
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'number', label: 'Height', min: 0.01, step: 0.1 })
|
||||
public height: number = 10;
|
||||
public get height(): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
if (this._height !== value) {
|
||||
this._height = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取半宽度
|
||||
@@ -78,6 +99,5 @@ export class BoxCollider2DComponent extends Collider2DBase {
|
||||
public setSize(width: number, height: number): void {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,41 @@ export enum CapsuleDirection2D {
|
||||
@ECSComponent('CapsuleCollider2D')
|
||||
@Serializable({ version: 1, typeId: 'CapsuleCollider2D' })
|
||||
export class CapsuleCollider2DComponent extends Collider2DBase {
|
||||
private _radius: number = 3;
|
||||
private _height: number = 10;
|
||||
private _direction: CapsuleDirection2D = CapsuleDirection2D.Vertical;
|
||||
|
||||
/**
|
||||
* 胶囊半径
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'number', label: 'Radius', min: 0.01, step: 0.1 })
|
||||
public radius: number = 3;
|
||||
public get radius(): number {
|
||||
return this._radius;
|
||||
}
|
||||
|
||||
public set radius(value: number) {
|
||||
if (this._radius !== value) {
|
||||
this._radius = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 胶囊总高度(包括两端的半圆)
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'number', label: 'Height', min: 0.01, step: 0.1 })
|
||||
public height: number = 10;
|
||||
public get height(): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
if (this._height !== value) {
|
||||
this._height = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 胶囊方向
|
||||
@@ -61,7 +83,16 @@ export class CapsuleCollider2DComponent extends Collider2DBase {
|
||||
{ label: 'Horizontal', value: 1 }
|
||||
]
|
||||
})
|
||||
public direction: CapsuleDirection2D = CapsuleDirection2D.Vertical;
|
||||
public get direction(): CapsuleDirection2D {
|
||||
return this._direction;
|
||||
}
|
||||
|
||||
public set direction(value: CapsuleDirection2D) {
|
||||
if (this._direction !== value) {
|
||||
this._direction = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取半高度(中间矩形部分的一半)
|
||||
@@ -103,7 +134,6 @@ export class CapsuleCollider2DComponent extends Collider2DBase {
|
||||
public setSize(radius: number, height: number): void {
|
||||
this.radius = radius;
|
||||
this.height = height;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +142,5 @@ export class CapsuleCollider2DComponent extends Collider2DBase {
|
||||
*/
|
||||
public setDirection(direction: CapsuleDirection2D): void {
|
||||
this.direction = direction;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,23 @@ import type { Vector2 } from '../types/Physics2DTypes';
|
||||
@ECSComponent('CircleCollider2D')
|
||||
@Serializable({ version: 1, typeId: 'CircleCollider2D' })
|
||||
export class CircleCollider2DComponent extends Collider2DBase {
|
||||
private _radius: number = 5;
|
||||
|
||||
/**
|
||||
* 圆的半径
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'number', label: 'Radius', min: 0.01, step: 0.1 })
|
||||
public radius: number = 5;
|
||||
public get radius(): number {
|
||||
return this._radius;
|
||||
}
|
||||
|
||||
public set radius(value: number) {
|
||||
if (this._radius !== value) {
|
||||
this._radius = value;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override getShapeType(): string {
|
||||
return 'circle';
|
||||
@@ -50,6 +61,5 @@ export class CircleCollider2DComponent extends Collider2DBase {
|
||||
*/
|
||||
public setRadius(radius: number): void {
|
||||
this.radius = radius;
|
||||
this._needsRebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export abstract class Collider2DBase extends Component {
|
||||
* 使用位掩码,可以属于多个层
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'integer', label: 'Collision Layer', min: 0 })
|
||||
@Property({ type: 'collisionLayer', label: 'Collision Layer' })
|
||||
public collisionLayer: number = CollisionLayer2D.Default;
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ export abstract class Collider2DBase extends Component {
|
||||
* 使用位掩码
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'integer', label: 'Collision Mask', min: 0 })
|
||||
@Property({ type: 'collisionMask', label: 'Collision Mask' })
|
||||
public collisionMask: number = CollisionLayer2D.All;
|
||||
|
||||
// ==================== 偏移 ====================
|
||||
|
||||
Reference in New Issue
Block a user