主题
GameCore.Shape
AIShapeComposer 仅客户端
命名空间 GameCore.Shape
csharp
public static class AIShapeComposerAI助手专用的形状组合工具,提供预定义的复杂对象组合模板
备注
这个组合器为AI助手提供了快速创建复杂对象的能力,通过组合多个基本形状 来构建角色、建筑、载具等复杂物体。每个组合都有清晰的语义含义, 便于AI理解和使用。
方法
CreateSimpleCharacter 仅客户端
csharp
public static List<ActorModel> CreateSimpleCharacter(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单的人形角色(头+身体)
position— 角色位置scope— 作用域scale— 整体缩放
返回: 角色部件列表([0]=身体, [1]=头部)
CreateRobotCharacter 仅客户端
csharp
public static List<ActorModel> CreateRobotCharacter(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建机器人角色(更加几何化)
position— 机器人位置scope— 作用域scale— 整体缩放
返回: 机器人部件列表([0]=身体, [1]=头部, [2]=左臂, [3]=右臂)
CreateSimpleHouse 仅客户端
csharp
public static List<ActorModel> CreateSimpleHouse(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单房屋(墙+屋顶)
position— 房屋位置scope— 作用域scale— 整体缩放
返回: 建筑部件列表([0]=墙壁, [1]=屋顶)
CreateCastleTower 仅客户端
csharp
public static List<ActorModel> CreateCastleTower(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建城堡塔楼
position— 塔楼位置scope— 作用域scale— 整体缩放
返回: 塔楼部件列表([0]=基座, [1]=塔身, [2]=塔顶)
CreateSimpleCar 仅客户端
csharp
public static List<ActorModel> CreateSimpleCar(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单汽车
position— 汽车位置scope— 作用域scale— 整体缩放
返回: 汽车部件列表([0]=车身, [1-4]=轮子)
CreateSimpleSpaceship 仅客户端
csharp
public static List<ActorModel> CreateSimpleSpaceship(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单飞船
position— 飞船位置scope— 作用域scale— 整体缩放
返回: 飞船部件列表([0]=船身, [1]=尾翼, [2]=引擎)
CreateSimpleTree 仅客户端
csharp
public static List<ActorModel> CreateSimpleTree(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单树木
position— 树木位置scope— 作用域scale— 整体缩放
返回: 树木部件列表([0]=树干, [1]=树冠)
CreateStreetLight 仅客户端
csharp
public static List<ActorModel> CreateStreetLight(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建路灯
position— 路灯位置scope— 作用域scale— 整体缩放
返回: 路灯部件列表([0]=灯柱, [1]=灯泡)
CreateSimpleTurret 仅客户端
csharp
public static List<ActorModel> CreateSimpleTurret(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建简单炮塔
position— 炮塔位置scope— 作用域scale— 整体缩放
返回: 炮塔部件列表([0]=基座, [1]=炮管)
CreateCollectibleAltar 仅客户端
csharp
public static List<ActorModel> CreateCollectibleAltar(ScenePoint position, IActorScope? scope = null, float scale = 1f)创建收集品祭坛
position— 祭坛位置scope— 作用域scale— 整体缩放
返回: 祭坛部件列表([0]=基座, [1]=收集品)
CreateForest 仅客户端
csharp
public static List<List<ActorModel>> CreateForest(ScenePoint centerPosition, float radius, int treeCount, IActorScope? scope = null)创建对象森林(随机分布的树木)
centerPosition— 森林中心位置radius— 森林半径treeCount— 树木数量scope— 作用域
返回: 所有树木的部件列表
CreateCityBlock 仅客户端
csharp
public static List<List<ActorModel>> CreateCityBlock(ScenePoint centerPosition, (int width, int height) gridSize, float spacing = 300f, IActorScope? scope = null)AIShapeFactory 仅客户端
命名空间 GameCore.Shape
csharp
public static class AIShapeFactoryAI助手专用的3D形状创建工厂,提供简单易用的API来快速创建基本形状
备注
这个工厂类是为AI助手设计的,提供了语义化、直观的API来创建3D形状。 AI可以通过简单的方法调用快速搭建游戏原型,而无需深入了解复杂的底层系统。 支持智能默认颜色、自动尺寸调整和灵活的自定义选项。
属性
DefaultColorMode 仅客户端
csharp
public static ShapeColorMode DefaultColorMode { get; set; }默认的形状颜色模式
DefaultColorTheme 仅客户端
csharp
public static ShapeColorTheme DefaultColorTheme { get; set; }默认的颜色主题
EnableAutoTint 仅客户端
csharp
public static bool EnableAutoTint { get; set; }是否启用自动染色设置(推荐用于AI快速原型)
方法
CreateShape 仅客户端
csharp
public static ActorModel CreateShape(PrimitiveShape shape, ScenePoint position, IActorScope? scope = null)创建基本形状Actor(最简单的API)
shape— 要创建的形状类型position— 世界位置,使用Vector3(x, y, z)格式,其中XY为地面坐标,Z为高度scope— Actor作用域,null表示无作用域
返回: 创建的形状Actor
备注
⚠️ 坐标系统重要提醒:
- X轴:水平方向(左右)
- Y轴:水平方向(前后)
- Z轴:高度方向(上下,跳跃轴)
- XY平面:地面
CreateShape 仅客户端
csharp
public static ActorModel CreateShape(PrimitiveShape shape, ScenePoint position, ShapeColorMode colorMode, IActorScope? scope = null)创建指定颜色模式的形状
shape— 要创建的形状类型position— 世界位置colorMode— 颜色模式scope— Actor作用域
返回: 创建的形状Actor
CreateShape 仅客户端
csharp
public static ActorModel CreateShape(PrimitiveShape shape, ScenePoint position, Vector3 scale, IActorScope? scope = null)创建带缩放的形状
shape— 要创建的形状类型position— 世界位置scale— 缩放系数scope— Actor作用域
返回: 创建的形状Actor
CreateColoredShape 仅客户端
csharp
public static ActorModel CreateColoredShape(PrimitiveShape shape, ScenePoint position, HdrColor color, IActorScope? scope = null)创建自定义颜色的形状
shape— 要创建的形状类型position— 世界位置color— 自定义颜色scope— Actor作用域
返回: 创建的形状Actor
CreateThemedShape 仅客户端
csharp
public static ActorModel CreateThemedShape(PrimitiveShape shape, ScenePoint position, ShapeColorTheme theme, IActorScope? scope = null)创建指定主题的形状
shape— 要创建的形状类型position— 世界位置theme— 颜色主题scope— Actor作用域
返回: 创建的形状Actor
CreatePlayer 仅客户端
csharp
public static ActorModel CreatePlayer(ScenePoint position, IActorScope? scope = null)快速创建玩家角色(蓝色胶囊)
position— 出生位置。注意:使用Vector3(x, y, z),其中XY为地面位置,Z为高度scope— 角色作用域
返回: 角色Actor
备注
坐标系统提醒:WasiCore使用Z轴作为高度轴,XY平面为地面。 示例:new ScenePoint(new Vector3(100, 200, 0), scene) 表示在地面位置(100,200)创建角色。
CreateEnemy 仅客户端
csharp
public static ActorModel CreateEnemy(ScenePoint position, IActorScope? scope = null)快速创建敌人(红色球体)
position— 敌人位置scope— 敌人作用域
返回: 敌人Actor
CreateObstacle 仅客户端
csharp
public static ActorModel CreateObstacle(ScenePoint position, Vector3? scale = null, IActorScope? scope = null)快速创建障碍物(灰色立方体)
position— 障碍物位置scale— 障碍物大小scope— 作用域
返回: 障碍物Actor
CreateCollectible 仅客户端
csharp
public static ActorModel CreateCollectible(ScenePoint position, IActorScope? scope = null)快速创建收集品(黄色圆锥)
position— 收集品位置scope— 作用域
返回: 收集品Actor
CreatePlatform 仅客户端
csharp
public static ActorModel CreatePlatform(ScenePoint position, Vector3? scale = null, IActorScope? scope = null)快速创建平台(棕色平面)
position— 平台位置。Z坐标决定平台高度scale— 平台大小。格式:Vector3(宽度, 深度, 厚度),注意Z为厚度scope— 作用域
返回: 平台Actor
备注
坐标提醒:平台位置的Z值决定其在空间中的高度。 缩放提醒:scale.X和scale.Y控制平台在地面的大小,scale.Z控制厚度。
CreateShapes 仅客户端
csharp
public static List<ActorModel> CreateShapes(PrimitiveShape shape, IEnumerable<ScenePoint> positions, IActorScope? scope = null)批量创建相同形状的Actor
shape— 形状类型positions— 位置列表scope— 作用域
返回: 创建的Actor列表
CreateShapeGrid 仅客户端
csharp
public static List<ActorModel> CreateShapeGrid(PrimitiveShape shape, ScenePoint centerPosition, (int width, int height) gridSize, float spacing = 150f, IActorScope? scope = null)GetShapeUsageHint 仅客户端
csharp
public static string GetShapeUsageHint(PrimitiveShape shape)获取形状的推荐用途描述
shape— 形状类型
返回: 用途描述字符串
GetAllShapeHints 仅客户端
csharp
public static ValueKeyDictionary<PrimitiveShape, string> GetAllShapeHints()列出所有可用的形状和其用途
返回: 形状用途映射
AIUnitShapeFactory 仅客户端
命名空间 GameCore.Shape
csharp
public static class AIUnitShapeFactoryAI友好的单位形状工厂,用于为游戏单位附着基本几何形状
备注
这个工厂专门处理单位(Unit)与基本形状的结合,提供简单的API让AI助手 能够快速为单位添加临时的视觉表现。支持形状切换、组合和动态调整。
方法
AttachShapeToUnit 仅客户端
csharp
public static ActorModel AttachShapeToUnit(Unit unit, PrimitiveShape shape, Vector3? offset = null, Vector3? scale = null, ShapeColorMode? colorMode = null, ShapeColorTheme? theme = null, object? tag = null)为单位附着单个基本形状
unit— 目标单位shape— 要附着的形状offset— 相对于单位原点的偏移scale— 形状缩放(null使用默认值)colorMode— 颜色模式(null使用默认值)theme— 颜色主题(null使用默认值)tag— 标识符,用于后续管理(null使用默认值)
返回: 创建的形状Actor
AttachCompositeShapeToUnit 仅客户端
csharp
public static List<ActorModel> AttachCompositeShapeToUnit(Unit unit, params ShapeConfig[] shapeConfig)为单位附着复合形状(多个形状组合)
unit— 目标单位shapeConfig— 形状配置列表
返回: 创建的所有形状Actor列表
AttachUnitTemplate 仅客户端
csharp
public static List<ActorModel> AttachUnitTemplate(Unit unit, UnitShapeTemplate template, float scale = 1f)使用预定义的单位形状模板
unit— 目标单位template— 形状模板scale— 整体缩放
返回: 创建的形状Actor列表
DestroyShapes 仅客户端
csharp
public static void DestroyShapes(List<ActorModel> shapeActors)销毁指定的形状Actor列表(用于清理 AttachShapeToUnit / AttachCompositeShapeToUnit 返回的 Actor)
shapeActors— 要销毁的形状Actor列表
ApplyShapeColor 仅客户端
csharp
public static void ApplyShapeColor(ActorModel actor, PrimitiveShape shape, ShapeColorMode colorMode, ShapeColorTheme theme)为形状Actor应用颜色(使用TintColor机制)
actor— 目标形状Actorshape— 形状类型colorMode— 颜色模式theme— 颜色主题
SetShapeColor 仅客户端
csharp
public static void SetShapeColor(ActorModel actor, HdrColor color, string tag = "custom_color")为形状Actor设置自定义颜色(使用TintColor机制)
actor— 目标形状Actorcolor— 自定义颜色tag— 标识符
ClearShapeColor 仅客户端
csharp
public static void ClearShapeColor(ActorModel actor, string? tag = null)清除形状Actor的颜色染色
actor— 目标形状Actortag— 要清除的标识符,null表示清除所有
Region 双端
命名空间 GameCore.Shape
csharp
public abstract class Region : DisposableObject, IEventSenderAbstract base class representing a geometric region within a scene. Provides a common interface for region types (such as circles and rectangles) to define spatial properties, containment logic, and entity queries within the region.
构造函数
Region 双端
csharp
protected Region()属性
Position 双端
csharp
public abstract ScenePoint Position { get; }Gets the position of the region, typically representing its origin or anchor point.
Scene 双端
csharp
public Scene Scene { get; }Gets the scene that contains this region. This is a convenience property equivalent to Position.Scene.
Center 双端
csharp
public abstract ScenePoint Center { get; }Gets the center point of the region.
方法
Contains 双端
csharp
public abstract bool Contains(ScenePoint point)Determines whether the specified point is contained within the region.
point— The point to check for containment.
返回: true if the point is within the region; otherwise, false.
Contains 双端
csharp
public abstract bool Contains(Entity entity)Determines whether the specified entity is contained within the region.
entity— The entity to check for containment.
返回: true if the entity is within the region; otherwise, false.
FilterEntities 双端
csharp
public abstract IEnumerable<Entity>? FilterEntities(Func<Entity, bool>? condition)Returns all entities within the region that satisfy the specified condition.
condition— A predicate to filter entities; ifnull, all entities within the region are returned.
返回: An enumerable of entities within the region that match the condition, or null if none found.
FilterEntities 双端
csharp
public abstract IEnumerable<TMorph>? FilterEntities<TMorph>(Func<Entity, TMorph?> condition) where TMorph : notnullReturns all entities within the region that can be transformed to the specified type and satisfy the given condition.
condition— A transformation function that takes anEntityand returns a instance ornull. Ifnullis returned, the entity is excluded from the result.
返回: An enumerable of instances representing entities within the region that match the transformation condition, or null if none are found.
RandomPoint 双端
csharp
public abstract ScenePoint RandomPoint()Returns a random point within the region.
返回: A ScenePoint randomly located within the region's bounds.
DisposeManaged 仅服务端
csharp
protected override void DisposeManaged()CreateViewDetector 仅服务端
csharp
protected internal abstract IDetector? CreateViewDetector()字段
SharedRandom 双端
csharp
protected static readonly Random SharedRandomRegionCircle 双端
命名空间 GameCore.Shape
csharp
public class RegionCircle : Region, IEventSenderRepresents a circular region in a scene, defined by a center point and a radius. Provides geometric properties and methods for containment checks and entity queries within the region.
构造函数
RegionCircle 双端
csharp
public RegionCircle(ScenePoint position, float radius)Represents a circular region in a scene, defined by a center point and a radius. Provides geometric properties and methods for containment checks and entity queries within the region.
属性
Center 双端
csharp
public override ScenePoint Center { get; }Gets the center point of the circle.
Position 双端
csharp
public override ScenePoint Position { get; }Gets the position of the circle (same as the center).
Radius 双端
csharp
public float Radius { get; }Gets the radius of the circle.
Diameter 双端
csharp
public float Diameter { get; }Gets the diameter of the circle.
Circumference 双端
csharp
public float Circumference { get; }Gets the circumference of the circle.
Area 双端
csharp
public float Area { get; }Gets the area of the circle.
方法
Contains 双端
csharp
public override bool Contains(ScenePoint point)Determines whether the specified point is contained within the circle.
point— The point to check for containment.
返回: true if the point is within the circle and in the same scene; otherwise, false.
ToString 双端
csharp
public override string ToString()Returns a string representation of the circle region.
返回: A string describing the circle's position and radius.
FilterEntities 双端
csharp
public override IEnumerable<Entity>? FilterEntities(Func<Entity, bool>? condition)Returns all entities within the circle that satisfy the specified condition.
condition— A predicate to filter entities; ifnull, all entities within the circle are returned.
返回: An enumerable of entities within the circle that match the condition, or null if none found.
FilterEntities 双端
csharp
public override IEnumerable<TMorph>? FilterEntities<TMorph>(Func<Entity, TMorph?> condition)Returns all entities within the circle that can be transformed to the specified type and satisfy the given condition.
condition— A transformation function that takes anEntityand returns a instance ornull. Ifnullis returned, the entity is excluded from the result.
返回: An enumerable of instances representing entities within the circle that match the transformation condition, or null if none are found.
Contains 双端
csharp
public override bool Contains(Entity entity)RandomPoint 双端
csharp
public override ScenePoint RandomPoint()Returns a uniformly distributed random point within the circle.
CreateViewDetector 仅服务端
csharp
protected internal override IDetector? CreateViewDetector()RegionRectangle 双端
命名空间 GameCore.Shape
csharp
public class RegionRectangle : Region, IEventSenderRepresents a rectangular region in a scene, defined by a position and size. Provides geometric properties and methods for containment checks and entity queries within the region.
构造函数
RegionRectangle 双端
csharp
public RegionRectangle(ScenePoint position, Vector2 size)Represents a rectangular region in a scene, defined by a position and size. Provides geometric properties and methods for containment checks and entity queries within the region.
RegionRectangle 双端
csharp
public RegionRectangle(ScenePoint position, float width, float height)Initializes a new instance of the RegionRectangle class with the specified position, width, and height.
position— The position of the rectangle (top-left corner).width— The width of the rectangle.height— The height of the rectangle.
属性
Position 双端
csharp
public override ScenePoint Position { get; }Gets the position of the rectangle (top-left corner).
Size 双端
csharp
public Vector2 Size { get; }Gets the size of the rectangle as a Vector2 (X: width, Y: height).
Height 双端
csharp
public float Height { get; }Gets the height of the rectangle.
Width 双端
csharp
public float Width { get; }Gets the width of the rectangle.
Center 双端
csharp
public override ScenePoint Center { get; }Gets the center point of the rectangle.
TopLeft 双端
csharp
public ScenePoint TopLeft { get; }Gets the top-left corner of the rectangle.
TopRight 双端
csharp
public ScenePoint TopRight { get; }Gets the top-right corner of the rectangle.
BottomLeft 双端
csharp
public ScenePoint BottomLeft { get; }Gets the bottom-left corner of the rectangle.
BottomRight 双端
csharp
public ScenePoint BottomRight { get; }Gets the bottom-right corner of the rectangle.
方法
Contains 双端
csharp
public override bool Contains(ScenePoint point)Determines whether the specified point is contained within the rectangle.
point— The point to check for containment.
返回: true if the point is within the rectangle and in the same scene; otherwise, false.
ToString 双端
csharp
public override string ToString()Returns a string representation of the rectangle region.
返回: A string describing the rectangle's position and size.
Contains 双端
csharp
public override bool Contains(Entity entity)Determines whether the specified entity is contained within the rectangle.
entity— The entity to check for containment.
返回: true if the entity is within the rectangle; otherwise, false.
FilterEntities 双端
csharp
public override IEnumerable<Entity>? FilterEntities(Func<Entity, bool>? condition)Returns all entities within the rectangle that satisfy the specified condition.
condition— A predicate to filter entities; ifnull, all entities within the rectangle are returned.
返回: An enumerable of entities within the rectangle that match the condition, or null if none found.
FilterEntities 双端
csharp
public override IEnumerable<TMorph>? FilterEntities<TMorph>(Func<Entity, TMorph?> condition)Returns all entities within the rectangle that can be transformed to the specified type and satisfy the given condition.
condition— A transformation function that takes anEntityand returns a instance ornull. Ifnullis returned, the entity is excluded from the result.
返回: An enumerable of instances representing entities within the rectangle that match the transformation condition, or null if none are found.
RandomPoint 双端
csharp
public override ScenePoint RandomPoint()Returns a uniformly distributed random point within the rectangle.
CreateViewDetector 仅服务端
csharp
protected internal override IDetector? CreateViewDetector()SceneLine 双端
命名空间 GameCore.Shape
csharp
public class SceneLineRepresents a polyline (连续线段) in a scene, defined by a series of connected points. Provides geometric properties and methods for line calculations such as length, distance to point, etc.
构造函数
SceneLine 双端
csharp
public SceneLine(IEnumerable<ScenePoint> points)Initializes a new instance of the SceneLine class with the specified points.
points— The points that define the line. Must contain at least 2 points.
属性
Points 双端
csharp
public IReadOnlyList<ScenePoint> Points { get; }Gets the points that define this line. The line connects these points in order.
Scene 双端
csharp
public Scene Scene { get; }Gets the scene that contains this line.
Start 双端
csharp
public ScenePoint Start { get; }Gets the first point of the line.
End 双端
csharp
public ScenePoint End { get; }Gets the last point of the line.
SegmentCount 双端
csharp
public int SegmentCount { get; }Gets the number of segments in this line. Equal to the number of points minus one.
方法
GetLength 双端
csharp
public float GetLength()Calculates the total length of the line by summing the distances between consecutive points.
返回: The total length of the line.
GetSegment 双端
csharp
public (ScenePoint Start, ScenePoint End) GetSegment(int index)Gets a specific line segment by index.
index— The index of the segment (0 to SegmentCount-1).
返回: A tuple containing the start and end points of the segment.
DistanceToPoint 双端
csharp
public float DistanceToPoint(ScenePoint point)Calculates the minimum distance from a point to this line. The distance is measured to the closest point on any segment of the line.
point— The point to measure distance from.
返回: The minimum distance from the point to the line.
ClosestPointOnLine 双端
csharp
public ScenePoint ClosestPointOnLine(ScenePoint point)Finds the closest point on this line to the specified point.
point— The point to find the closest point to.
返回: The closest point on the line to the specified point.
IsPointNearLine 双端
csharp
public bool IsPointNearLine(ScenePoint point, float distance)Determines whether a point is within a specified distance from the line.
point— The point to check.distance— The maximum distance.
返回: true if the point is within the specified distance; otherwise, false.
ToString 双端
csharp
public override string ToString()Returns a string representation of this line.
返回: A string describing the line's points.
ShapeConfig 仅客户端
命名空间 GameCore.Shape
csharp
public struct ShapeConfig形状配置结构,用于复合形状创建
属性
Shape 仅客户端
csharp
public PrimitiveShape Shape { get; set; }Scale 仅客户端
csharp
public Vector3? Scale { get; set; }Offset 仅客户端
csharp
public Vector3? Offset { get; set; }Rotation 仅客户端
csharp
public Vector3? Rotation { get; set; }ColorMode 仅客户端
csharp
public ShapeColorMode? ColorMode { get; set; }Theme 仅客户端
csharp
public ShapeColorTheme? Theme { get; set; }AttachToRoot 仅客户端
csharp
public bool AttachToRoot { get; set; }UnitShapeTemplate 仅客户端
命名空间 GameCore.Shape
csharp
public enum UnitShapeTemplate预定义的单位形状模板
枚举值
SimpleCharacter— 简单角色(胶囊身体+球体头部)FlyingOrb— 飞行球体(单个球体)Vehicle— 载具(立方体)Tower— 塔楼(圆柱体)
PrimitiveColorScheme 双端
命名空间 GameCore.Shape.Data
csharp
public static class PrimitiveColorScheme基本形状的智能颜色方案管理器,为AI助手提供语义化的默认颜色
备注
该类基于认知心理学和游戏设计惯例,为不同形状分配直观的默认颜色。 支持多种主题,可以根据项目需求切换不同的配色方案。
属性
CurrentTheme 双端
csharp
public static ShapeColorTheme CurrentTheme { get; set; }当前使用的颜色主题
方法
GetDefaultColor 双端
csharp
public static HdrColor GetDefaultColor(PrimitiveShape shape)获取指定形状在当前主题下的默认颜色
shape— 要获取颜色的形状
返回: 该形状的默认HDR颜色
GetColor 双端
csharp
public static HdrColor GetColor(PrimitiveShape shape, ShapeColorTheme theme)获取指定主题下的形状颜色
shape— 要获取颜色的形状theme— 指定的颜色主题
返回: 该形状在指定主题下的HDR颜色
GenerateRandomColor 双端
csharp
public static HdrColor GenerateRandomColor()生成随机颜色(用于调试模式)
返回: 随机的HDR颜色
GetAllShapeColors 双端
csharp
public static ValueKeyDictionary<PrimitiveShape, HdrColor> GetAllShapeColors()获取所有可用的形状及其当前主题下的颜色
返回: 形状到颜色的映射字典
GetShapeDescription 双端
csharp
public static string GetShapeDescription(PrimitiveShape shape)获取形状的语义化描述(包含颜色信息)
shape— 要描述的形状
返回: 包含颜色和用途的描述字符串
PrimitiveShape 双端
命名空间 GameCore.Shape.Data
csharp
public enum PrimitiveShape定义可用的基本3D形状类型,适用于AI助手快速游戏原型开发
备注
所有形状都基于标准尺寸:圆形底面直径100(半径50),方形底面边长100。 这个枚举为AI助手提供语义化的形状选择,便于快速识别和使用。
枚举值
Sphere— 球体 - 直径100(半径50),原点在球心Cube— 立方体 - 边长100,原点在底面中心Cylinder— 圆柱体 - 底面直径100(半径50),高度100,原点在底面圆心Plane— 平面 - 边长100的正方形,原点在几何中心Cone— 圆锥 - 底面直径100(半径50),高度100,原点在底面圆心Capsule— 胶囊 - 直径100(半径50),总高度200,原点在底端圆心Pyramid— 方形金字塔 - 底面边长100,高度100,原点在底面中心Torus— 环形(甜甜圈) - 外径100,高度40,原点在几何中心Wedge— 楔形 - 底面边长100,高度100,原点在底面后端中心
PrimitiveShapeConfig 双端
命名空间 GameCore.Shape.Data
csharp
public class PrimitiveShapeConfig基本几何形状配置数据(用于GameData序列化)
备注
这个配置类用于在GameDataUnit中定义单位的基本几何形状。 当单位在客户端创建时,会根据这些配置自动生成相应的形状表现。
构造函数
PrimitiveShapeConfig 双端
csharp
public PrimitiveShapeConfig()属性
Shape 双端
csharp
public PrimitiveShape Shape { get; set; }形状类型
Offset 双端
csharp
public Vector3 Offset { get; set; }相对于单位原点的偏移位置
Scale 双端
csharp
public Vector3 Scale { get; set; }形状的缩放比例
Rotation 双端
csharp
public Vector3 Rotation { get; set; }形状的旋转角度(欧拉角,度数)
ColorMode 双端
csharp
public ShapeColorMode ColorMode { get; set; }颜色模式
ColorTheme 双端
csharp
public ShapeColorTheme ColorTheme { get; set; }颜色主题
CustomColor 双端
csharp
public HdrColor? CustomColor { get; set; }自定义颜色(如果设置,将覆盖颜色模式)
备注
当此字段不为null时,将忽略ColorMode和ColorTheme设置, 直接使用指定的自定义颜色。
AttachToRoot 双端
csharp
public bool AttachToRoot { get; set; }是否附着到根单位
备注
true:附着到单位本身的原点 false:附着到前一个创建的形状(用于复合形状)
Tag 双端
csharp
public string? Tag { get; set; }形状标识符,用于后续管理和引用
备注
可以用于后续通过代码动态修改或移除特定的形状。 如果为空,将自动生成一个基于形状类型的标识符。
Priority 双端
csharp
public int Priority { get; set; }形状优先级(数值越大越后创建,影响附着顺序)
EnableCollision 双端
csharp
public bool EnableCollision { get; set; }是否启用碰撞检测
备注
注意:基本形状通常只用于视觉表现,不建议启用碰撞。 单位的碰撞应该由其他系统管理。
方法
ToRuntimeConfig 仅客户端
csharp
public ShapeConfig ToRuntimeConfig()创建运行时ShapeConfig(仅客户端可用)
返回: 用于AIUnitShapeFactory的运行时配置
IsValid 双端
csharp
public bool IsValid()验证配置的有效性
返回: 配置是否有效
GetEffectiveTag 双端
csharp
public string GetEffectiveTag(int index = 0)获取有效的标识符
index— 形状索引,用于生成默认标识符
返回: 形状标识符
PrimitiveShapeRegistry 双端
命名空间 GameCore.Shape.Data
csharp
public class PrimitiveShapeRegistry : IGameClass基本形状的数据注册系统,负责在游戏初始化时创建所有基本形状的GameData
备注
该系统使用框架的IGameClass自动注册机制,在游戏启动时自动创建所有基本形状的 GameDataModel和GameDataActorModel数据。支持多种颜色主题和尺寸配置。
构造函数
PrimitiveShapeRegistry 双端
csharp
public PrimitiveShapeRegistry()属性
ModelLinks 双端
csharp
public static ValueKeyDictionary<PrimitiveShape, IGameLink<GameDataModel>> ModelLinks { get; }形状模型数据的链接映射
ActorLinks 双端
csharp
public static ValueKeyDictionary<ShapeColorTheme, ValueKeyDictionary<PrimitiveShape, IGameLink<GameDataActorModel>>> ActorLinks { get; }形状Actor数据的链接映射(按颜色主题分组)
字段
STANDARD_RADIUS 双端
csharp
public const float STANDARD_RADIUS基本形状的标准半径(对应直径100的圆形)
STANDARD_SIZE 双端
csharp
public const float STANDARD_SIZE基本形状的标准边长(方形底面)
STANDARD_HEIGHT 双端
csharp
public const float STANDARD_HEIGHT基本形状的标准高度
ShapeColorMode 双端
命名空间 GameCore.Shape.Data
csharp
public enum ShapeColorMode形状颜色模式,决定基本形状的默认着色方案
枚举值
SmartDefaults— 智能默认颜色 - AI友好,每种形状有不同的语义化默认色PureWhite— 纯白色 - 适合需要自定义材质的场景RandomColors— 随机颜色 - 便于调试时区分不同实例
ShapeColorTheme 双端
命名空间 GameCore.Shape.Data
csharp
public enum ShapeColorTheme预定义的形状颜色主题
枚举值
Standard— 标准主题 - 基于通用认知的颜色Gaming— 游戏主题 - 基于游戏惯例的颜色Educational— 教育主题 - 明亮且易于区分的颜色Natural— 自然主题 - 基于自然元素的颜色