Skip to content

GameCore.Extension ​

EditorLiteralAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class EditorLiteralAttribute<T> : Attribute where T : unmanaged

构造函数 ​

EditorLiteralAttribute 双端 ​

csharp
public EditorLiteralAttribute()

EnumExtensionAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class EnumExtensionAttribute : Attribute

Attribute used to mark enums for extension capabilities within the GameCore framework.

备注

This attribute provides metadata for enums that can be extended at runtime or compile-time, allowing for flexible and modular enum systems. It supports flag-based enums, extendable enums that can be inherited, and enum extension hierarchies.

构造函数 ​

EnumExtensionAttribute 双端 ​

csharp
public EnumExtensionAttribute()

属性 ​

UseAsFlags 双端 ​

csharp
public bool UseAsFlags { get; set; }

Gets or sets a value indicating whether the enum should be treated as a flags enumeration.

备注

When set to true, the enum values can be combined using bitwise operations, similar to the standard FlagsAttribute behavior.

Extendable 双端 ​

csharp
public bool Extendable { get; set; }

Gets or sets a value indicating whether this enum can be extended by other enums.

备注

Extendable enums can have additional values added through the extension system, allowing for modular and plugin-based enum definitions.

Extends 双端 ​

csharp
public Type? Extends { get; set; }

Gets or sets the base enum type that this enum extends.

备注

When specified, this enum will inherit or extend the values from the base enum type, creating a hierarchical enum extension system.

EnumValueExtensionAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class EnumValueExtensionAttribute : Attribute

Marks an enum field with extension configuration options, controlling its behavior in various game systems.

备注

This attribute provides metadata for enum values that can be used by the game engine and editor tools to customize how specific enum values are handled, displayed, or processed. It allows fine-grained control over enum value behavior without modifying the core enum definition.

构造函数 ​

EnumValueExtensionAttribute 双端 ​

csharp
public EnumValueExtensionAttribute()

字段 ​

HiddenInEditor 双端 ​

csharp
public bool HiddenInEditor

Gets or sets a value indicating whether this enum value should be hidden in editor interfaces.

备注

When set to true, this enum value will not appear in editor dropdowns, property inspectors, or other UI elements where enum values are displayed for selection. This is useful for internal or deprecated enum values that should not be exposed to content creators. TODO: Hide in Editor

ExtensionMethods 双端 ​

命名空间 GameCore.Extension

csharp
public static class ExtensionMethods

方法 ​

GetAllExtended 双端 ​

csharp
public static IEnumerable<TEnumExtendable> GetAllExtended<TEnumExtendable>() where TEnumExtendable : struct, IExtendableEnum<TEnumExtendable>

GetNormalized 双端 ​

csharp
public static Vector2 GetNormalized(this Vector2 vector)

CompareToEx 双端 ​

csharp
public static int CompareToEx(this double? x, double? y)

Extends 双端 ​

csharp
public static bool Extends(this Enum en, Type type)

Extends 双端 ​

csharp
public static bool Extends<TExtendableEnum>(this Enum en) where TExtendableEnum : IExtendableEnum

As 双端 ​

csharp
public static TExtendableEnum? As<TExtendableEnum>(this Enum en) where TExtendableEnum : struct, IExtendableEnum<TExtendableEnum>

Check if the enum's extended enum type extends , if so, return a cached instance of wrapping the enum value; otherwise, return null.

  • en — the inner enum used for check

返回:

Except 双端 ​

csharp
public static TEnum Except<TEnum>(this TEnum value, TEnum except) where TEnum : struct, Enum

Returns a new flag enum value with the specified flags removed.

  • value — The original enum value.
  • except — The flags to remove from the original value.

返回: A new enum value with the specified flags removed.

备注

This method performs a bitwise AND operation with the bitwise NOT of the except parameter, effectively removing the specified flags from the original value. Example: RoutedEvents.All.Except(RoutedEvents.PointerClicked)

Forget 双端 ​

csharp
public static void Forget(this Task task, Action<Exception>? innerExceptionHandler = null)

执行但不等待

  • task —
  • innerExceptionHandler — 自定义异常处理,当任务中出现异常时会执行对应的处理逻辑。 若没有设置,则异常会转到TaskUnhandledException中。
备注

执行一个异步任务,但不等待。但依然可以捕获异常。 可以自定义异常处理,若没有设置,则异常会转到TaskUnhandledException中。

LogError 双端 ​

csharp
public static void LogError(this ILogger logger, Exception? exception, StackTrace? callerStackTrace, string? message, params object?[] args)

Formats and writes an error log message.

  • logger — The ILogger to write to.
  • callerStackTrace — The stack trace of the caller.
  • exception — The exception to log.
  • message — Format string of the log message in message template format. Example: "User {User} logged in from {Address}".
  • args — An object array that contains zero or more objects to format.

LogException 双端 ​

csharp
public static void LogException(this ILogger logger, Exception ex, StackTrace? callerStackTrace = null)

LogException 双端 ​

csharp
public static void LogException(this ILogger logger, Exception ex, string message)

PrintLog 双端 ​

csharp
public static void PrintLog(this object obj, LogLevel logLevel, params object[] span)

ResolveComponent 双端 ​

csharp
public static (bool ownerIsHost, IAttachedObject? attachedOwner, int propertyHashShort, int attachedSyncId) ResolveComponent(this ICooldownHost host, long propertyHashLong)

Resolves a component based on a property hash and returns the associated owner and identifiers.

  • host — The context in which the property is being resolved.
  • propertyHashLong — A long value representing the property hash used for resolution.

返回: Returns a tuple containing the owner, a short property hash, and an attached synchronization ID.

ResolveComponent 双端 ​

csharp
public static (bool ownerIsHost, IAttachedObject? attachedOwner, int propertyHashShort, int attachedSyncId) ResolveComponent(this ICooldownHost host, ReplicatePropertyKey propertyKey)

ResolveToIntPair 双端 ​

csharp
public static (int higher, int lower) ResolveToIntPair(this long longValue)

CreateStackTrace 双端 ​

csharp
public static StackTrace CreateStackTrace(int skipFrames = 1)

创建一个跳过指定帧数的堆栈跟踪,避免包含不相关的调用帧

  • skipFrames — 要跳过的帧数,默认为1(跳过当前方法)

返回: 新的堆栈跟踪实例

LogErrorLazy 双端 ​

csharp
public static void LogErrorLazy(this ILogger logger, Exception? exception, Func<StackTrace?> createStackTrace, string? message, params object?[] args)

带性能考虑的LogError扩展方法 只有在Error级别启用时才会创建堆栈跟踪

  • logger — 日志记录器
  • exception — 异常
  • createStackTrace — 是否创建堆栈跟踪的函数
  • message — 日志消息
  • args — 消息参数

LogExceptionWithContext 双端 ​

csharp
public static void LogExceptionWithContext(this ILogger logger, Exception exception, string message, int skipFrames = 1)

简化的异常日志记录方法,自动跳过当前调用帧

  • logger — 日志记录器
  • exception — 异常
  • message — 自定义消息
  • skipFrames — 要跳过的帧数,默认为1

HasStackTrace 双端 ​

csharp
public static bool HasStackTrace(this Exception exception)

检查异常是否包含有用的堆栈跟踪信息

  • exception — 要检查的异常

返回: 如果异常包含堆栈跟踪信息则返回true

GetExceptionAssemblyName 双端 ​

csharp
public static string? GetExceptionAssemblyName(this Exception exception)

获取引发异常的程序集名称

  • exception — 异常对象

返回: 程序集名称,如果无法确定则返回null

GetExceptionAssemblyFullName 双端 ​

csharp
public static string? GetExceptionAssemblyFullName(this Exception exception)

获取引发异常的程序集完整名称

  • exception — 异常对象

返回: 程序集完整名称,如果无法确定则返回null

OrderByPriority 双端 ​

csharp
public static IOrderedEnumerable<T> OrderByPriority<T>(this IEnumerable<T> source, params Comparison<T>[] comparisons)

OrderByPriority 双端 ​

csharp
public static IOrderedEnumerable<T> OrderByPriority<T>(this IEnumerable<T> source, PriorityComparer<T> comparisons)

OrderByPriority 双端 ​

csharp
public static IOrderedEnumerable<T> OrderByPriority<TContext, T>(this IEnumerable<T> source, TContext context, params ContextualComparison<TContext, T>[] comparisons)

OrderByPriority 双端 ​

csharp
public static IOrderedEnumerable<T> OrderByPriority<TContext, T>(this IEnumerable<T> source, TContext context, ContextualPriorityComparer<TContext, T> comparer)

字段 ​

EnumExtensionMap 双端 ​

csharp
public static readonly QuickDictionary<Type, Type> EnumExtensionMap

GameDataCategoryAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class GameDataCategoryAttribute : Attribute

Marks a class as a game data category, indicating that it represents a configuration data type used by the game engine.

备注

This attribute is used to identify classes that contain game configuration data, allowing the engine to automatically discover, load, and manage these data types. Classes marked with this attribute are typically used for defining game rules, unit properties, abilities, items, and other configurable game elements that can be modified without recompiling the game code.

构造函数 ​

GameDataCategoryAttribute 双端 ​

csharp
public GameDataCategoryAttribute()

GameDataNodeTypeAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class GameDataNodeTypeAttribute<T, V> : Attribute where T : GameDataCategory<T> where V : T

构造函数 ​

GameDataNodeTypeAttribute 双端 ​

csharp
public GameDataNodeTypeAttribute()

GameObjectAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class GameObjectAttribute<TData> : Attribute where TData : IGameData<TData>

构造函数 ​

GameObjectAttribute 双端 ​

csharp
public GameObjectAttribute()

PropertyHostFacetAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class PropertyHostFacetAttribute : Attribute

标记枚举以自动生成 PropertyHostComponent 属性组件(facet)。

备注

与 PropertyObjectWrapperAttribute 平行,但生成的类派生自 GameGraph 的 PropertyHostComponent, 用于「位置走 node(客户端原生平滑)、游戏数据走同步属性」的混合形态。EPropertyXxx 生成 Xxx : PropertyHostComponent。 成员可用 PropertyTypeAttribute 指定类型(推荐显式标注;缺省则按命名约定推断)、 PropertyIgnoreAttribute 跳过、PropertySyncTypeAttribute 声明 per-property 同步范围 (如把私有数据设为 Self,仅 owner 可见——反作弊)。 使用示例: [PropertyHostFacet] [EnumExtension(Extendable = true)] public enum EPropertyHybridSoldier { [PropertyType(typeof(int))] Score, // 默认 All(双方可见) [PropertyType(typeof(int))] [PropertySyncType(SyncType.Self)] // 私有:仅 owner 可见 SecretLoadout, } // 自动生成: // public partial class HybridSoldier : PropertyHostComponent // { // public int Score { get => GetProperty(...); /* #if SERVER / set => SetProperty(...); } // public int SecretLoadout { ... } // / #if SERVER */ protected override void RegisterPropertySyncTypes() // => PropertyObject.DeclarePropertySyncType(PropertyHybridSoldier.SecretLoadout, SyncType.Self); // } // // 用法: var s = node.AddPropertyHost<HybridSoldier>(player, SyncType.All); s.Score = 10;

构造函数 ​

PropertyHostFacetAttribute 双端 ​

csharp
public PropertyHostFacetAttribute()

PropertyIgnoreAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class PropertyIgnoreAttribute : Attribute

标记枚举字段不生成包装器属性

备注

用于内部或调试字段,避免生成不必要的包装器属性。 使用示例: [PropertyObjectWrapper] [EnumExtension(Extendable = true)] public enum EPropertyBird { BirdY, Score, [PropertyIgnore] // 不生成此属性 InternalDebugValue, }

构造函数 ​

PropertyIgnoreAttribute 双端 ​

csharp
public PropertyIgnoreAttribute()

PropertyObjectWrapperAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class PropertyObjectWrapperAttribute : Attribute

标记枚举以自动生成 PropertyObject 包装器

备注

使用此特性标记扩展枚举,Source Generator 将自动生成对应的强类型包装器类。 使用示例: [PropertyObjectWrapper] [EnumExtension(Extendable = true)] public enum EPropertyBird { PlayerId, BirdY, BirdVelocity, IsAlive, } // 自动生成 Bird 类(包装器) // public partial class Bird // { // public PropertyObject PropertyObject { get; } // public int PlayerId { get; set; } // public float BirdY { get; set; } // public float BirdVelocity { get; set; } // public bool IsAlive { get; set; } // }

构造函数 ​

PropertyObjectWrapperAttribute 双端 ​

csharp
public PropertyObjectWrapperAttribute()

PropertySyncTypeAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class PropertySyncTypeAttribute : Attribute

声明某条属性的同步范围(per-property)。默认 All(双方可见)。

备注

典型用途:把私有数据(如背包、隐藏装备)设为 Self,使其只同步给 owner、敌方收不到字节(反作弊)。 codegen 会在属性组件 RegisterPropertySyncTypes(首次写入前)按此声明设置全局默认,使初始快照与后续增量都按目标范围分发。

构造函数 ​

PropertySyncTypeAttribute 双端 ​

csharp
public PropertySyncTypeAttribute(SyncType syncType)
  • syncType — 该属性的目标同步范围(Self / Ally / All 等)。

属性 ​

SyncType 双端 ​

csharp
public SyncType SyncType { get; }

同步范围。

PropertyTypeAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class PropertyTypeAttribute : Attribute

指定属性的类型(用于代码生成)

构造函数 ​

PropertyTypeAttribute 双端 ​

csharp
public PropertyTypeAttribute(Type type)

属性 ​

Type 双端 ​

csharp
public Type Type { get; }

TriggerExtensions 双端 ​

命名空间 GameCore.Extension

csharp
public static class TriggerExtensions

Trigger1` 的便捷扩展方法。

方法 ​

RegisterGlobal 双端 ​

csharp
public static Trigger<TEvent> RegisterGlobal<TEvent>(this Trigger<TEvent> trigger) where TEvent : class, ITriggerEvent<TEvent>

将触发器注册到全局事件总线(Instance)。

  • trigger — 要注册的触发器

返回: 触发器自身,支持链式调用

WaitForEventAttribute 双端 ​

命名空间 GameCore.Extension

csharp
public class WaitForEventAttribute : Attribute

构造函数 ​

WaitForEventAttribute 双端 ​

csharp
public WaitForEventAttribute()