{"id":16210149,"url":"https://github.com/gameframex/com.gameframex.unity.fsm","last_synced_at":"2025-10-11T09:07:10.310Z","repository":{"id":232333215,"uuid":"784041993","full_name":"GameFrameX/com.gameframex.unity.fsm","owner":"GameFrameX","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-31T01:53:57.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-31T12:48:16.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GameFrameX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-09T04:22:54.000Z","updated_at":"2025-05-31T01:54:00.000Z","dependencies_parsed_at":"2024-10-10T10:35:21.437Z","dependency_job_id":"1d9e3c2e-6196-411d-81b1-88de917129d8","html_url":"https://github.com/GameFrameX/com.gameframex.unity.fsm","commit_stats":null,"previous_names":["alianblank/com.alianblank.gameframex.unity.fsm","gameframex/com.gameframex.unity.fsm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GameFrameX/com.gameframex.unity.fsm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.fsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.fsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.fsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.fsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GameFrameX","download_url":"https://codeload.github.com/GameFrameX/com.gameframex.unity.fsm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.fsm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006757,"owners_count":26084176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T10:35:34.714Z","updated_at":"2025-10-11T09:07:10.283Z","avatar_url":"https://github.com/GameFrameX.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿## HOMEPAGE\nGameFrameX 的 Fsm 有限状态机组件\n\n **Fsm 有限状态机组件 (Fsm Component)** - 提供状态机组件相关的接口。\n\n\n# 使用文档(文档编写于GPT4)\n# 有限状态机组件 `FsmComponent` 说明文档\n\n## 简介\n`FsmComponent` 是一个集成于Game Framework游戏框架的有限状态机组件，用于管理和控制有限状态机（FSM）的创建、获取、检查以及销毁。\n\n## 功能\n- `Count` 属性：获取当前状态机的数量。\n- `HasFsm` 方法：检查指定类型的状态机是否已经存在。\n- `GetFsm` 方法：根据指定类型获取状态机实例。\n- `GetAllFsmList` 方法：获取所有状态机实例。\n- `CreateFsm` 方法：创建新的状态机实例。\n- `DestroyFsm` 方法：销毁指定的状态机实例。\n\n## 使用方法\n\n### 初始化组件\n在游戏开始时，`Awake` 方法会被自动调用。\n\n```csharp\nprotected override void Awake()\n{\n    base.Awake();\n    new FsmManager();\n    m_FsmManager = GameFrameworkEntry.GetModule\u003cIFsmManager\u003e();\n    if (m_FsmManager == null)\n    {\n        Log.Fatal(\"FSM manager is invalid.\");\n        return;\n    }\n}\n```\n\n### 创建状态机\n使用 `CreateFsm` 方法创建一个新的有限状态机。需要提供拥有者对象、状态机名称（可选）和状态集合。\n\n```csharp\npublic IFsm\u003cT\u003e CreateFsm\u003cT\u003e(T owner, params FsmState\u003cT\u003e[] states) where T : class\n{\n    return m_FsmManager.CreateFsm(owner, states);\n}\n```\n\n### 获取状态机\n根据拥有者类型或名称来获取对应的有限状态机。\n\n```csharp\npublic IFsm\u003cT\u003e GetFsm\u003cT\u003e() where T : class\n{\n    return m_FsmManager.GetFsm\u003cT\u003e();\n}\n```\n\n### 检查状态机存在\n调用 `HasFsm` 方法确认是否已创建特定的有限状态机。\n\n```csharp\npublic bool HasFsm\u003cT\u003e() where T : class\n{\n    return m_FsmManager.HasFsm\u003cT\u003e();\n}\n```\n\n### 销毁状态机\n使用 `DestroyFsm` 方法销毁不再需要的状态机，回收资源。\n\n```csharp\npublic bool DestroyFsm\u003cT\u003e(IFsm\u003cT\u003e fsm) where T : class\n{\n    return m_FsmManager.DestroyFsm(fsm);\n}\n```\n\n## 注意事项\n确保在调用任何状态机管理方法之前，状态机管理器 `m_FsmManager` 已被正确初始化，否则可能会引发错误。\n\n此组件需要与游戏框架的其他模块和组件进行交互使用，需保证游戏框架已被正确设置并初始化。\n\n# 使用方式(任选其一)\n\n1. 直接在 `manifest.json` 的文件中的 `dependencies` 节点下添加以下内容\n   ```json\n      {\"com.gameframex.unity.fsm\": \"https://github.com/AlianBlank/com.gameframex.unity.fsm.git\"}\n    ```\n2. 在Unity 的`Packages Manager` 中使用`Git URL` 的方式添加库,地址为：https://github.com/AlianBlank/com.gameframex.unity.fsm.git\n\n3. 直接下载仓库放置到Unity 项目的`Packages` 目录下。会自动加载识别","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.fsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.fsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.fsm/lists"}