# PloyBase **Repository Path**: maoyinhang/ploy-base ## Basic Information - **Project Name**: PloyBase - **Description**: 同一套设计哲学跨语言复现 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-11 - **Last Updated**: 2026-06-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PolyBase > 多语言基础库合集 — 同一套设计哲学在 C# / TypeScript / C++ 中跨语言复现。 ## 模块 | 模块 | C# | C++ | TS | 说明 | |------|----|----|----|------| | **StateMachine** | PolyBase.StateMachine | state_machine | state-machine | 队列+防重入状态机 | | **ObjectPool** | PolyBase.ObjectPool | object_pool | object-pool | 对象池 / 引用池 / 集合池 | | **EventBus** | PolyBase.EventBus | event_bus | event-bus | 发布-订阅事件总线 | 每个模块均提供 **单线程默认实现** 和 **Concurrent 子命名空间的多线程版**。 ## 仓库结构 ``` ├── csharp/ │ ├── PolyBase.StateMachine/ │ ├── PolyBase.ObjectPool/ │ │ └── Concurrent/ │ └── PolyBase.EventBus/ │ └── Concurrent/ ├── cpp/ │ ├── state_machine/ │ ├── object_pool/ │ │ └── Concurrent/ │ └── event_bus/ │ └── Concurrent/ ├── ts/ │ ├── state-machine/ │ ├── object-pool/ │ │ └── concurrent/ │ └── event-bus/ │ └── concurrent/ ├── LICENSE └── README.md ``` ## 快速使用 ### C\# ```csharp // 状态机 public class PlayerStateMachine : BaseStateMachine { } // 对象池(单线程) var pool = new PolyBase.ObjectPool.ObjectPool(null, b => b.Reset()); // 对象池(多线程) var pool = new PolyBase.ObjectPool.Concurrent.ObjectPool(null, b => b.Reset()); // 事件总线 var bus = new PolyBase.EventBus.EventBus(); bus.Subscribe(e => Console.WriteLine("Game Over")); bus.Publish(new PlayerDiedEvent()); ``` ### TypeScript ```ts import { BaseStateMachine, BaseState } from './state-machine/BaseStateMachine'; import { ObjectPool } from './object-pool/ObjectPool'; import { EventBus } from './event-bus/EventBus'; ``` ### C++ ```cpp #include "state_machine/BaseStateMachine.hpp" #include "object_pool/ObjectPool.hpp" #include "event_bus/EventBus.hpp" ``` ## 设计哲学 - **队列防重入** — StateMachine 切换请求入队,OnEnter/OnLeave 嵌套调用 ChangeState 不会递归 - **时间语义分离** — EventBus 的 Remove 立刻生效、Add 本轮不生效 - **单/多线程显式选择** — 命名空间级别区分,默认零锁开销 - **三语言同构** — 同一套 API 设计,降低跨语言认知负担 ## 许可 Copyright © 2025 Mao Yin Hang. All rights reserved.