diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0e7b903
--- /dev/null
+++ b/README.md
@@ -0,0 +1,158 @@
+# ThreatSource Library
+
+威胁源仿真库是一个用于模拟和仿真各种威胁源的.NET类库。提供 .NET 和原生 C++ 两种接口。
+
+## 编译和打包
+
+### 编译 .NET 库
+
+编译 Debug 版本:
+
+```bash
+dotnet build ThreatSource/ThreatSource.csproj
+```
+
+编译 Release 版本:
+
+```bash
+dotnet build ThreatSource/ThreatSource.csproj -c Release
+```
+
+### 编译原生库
+
+1. 使用 Visual Studio 2022 打开 ThreatSourceNative/ThreatSourceNative.vcxproj
+2. 选择配置:Release,平台:x64
+3. 编译解决方案
+
+### 打包
+
+#### 打包 .NET 库
+
+使用打包脚本生成 zip 包:
+
+```bash
+./scripts/pack_dll.sh
+```
+
+生成的文件位于 `publish` 目录下,文件名格式为 `ThreatSourceLibrary-{version}.zip`。
+包含以下文件:
+
+- ThreatSource.dll - 主要的库文件
+- ThreatSource.deps.json - 依赖配置文件
+- ThreatSource.xml - API 文档文件
+
+#### 打包原生库
+
+使用打包脚本生成 zip 包:
+
+```bash
+./scripts/pack_native.sh
+```
+
+生成的文件位于 `publish` 目录下,文件名格式为 `ThreatSourceNative-{version}.zip`。
+包含以下文件:
+
+- bin/ThreatSourceNative.dll - 原生接口库
+- bin/ThreatSource.dll - 核心库
+- bin/ThreatSource.deps.json - 依赖配置文件
+- include/threat_source.h - C接口头文件
+
+### 生成文档
+
+生成 PDF 格式的文档:
+
+```bash
+# 先生成 HTML 文档
+docfx build docfx.json
+
+# 然后生成 PDF
+./scripts/generate_pdf.sh
+```
+
+生成的 PDF 文件位于 `publish` 目录下,文件名为 `ThreatSource-Library.pdf`。
+
+## 项目结构
+
+```text
+ThreatSource/
+├── src/
+│ ├── Target/
+│ │ └── Tank.cs
+│ ├── Indicator/
+│ │ ├── LaserDesignator.cs
+│ │ ├── LaserBeamRider.cs
+│ │ └── InfraredTracker.cs
+│ └── Missile/
+│ ├── BaseMissile.cs
+│ ├── LaserBeamRiderMissile.cs
+│ ├── InfraredCommandGuidedMissile.cs
+│ ├── LaserSemiActiveGuidedMissile.cs
+│ ├── InfraredImagingTerminalGuidedMissile.cs
+│ ├── MillimeterWaveTerminalGuidedMissile.cs
+│ ├── TerminalSensitiveMissile.cs
+│ └── TerminalSensitiveSubmunition.cs
+├── docs/ - 文档目录
+├── ThreatSourceNative/ - 原生接口库
+│ ├── include/
+│ │ └── threat_source.h - C接口头文件
+│ └── src/
+│ └── threat_source.cpp - C接口实现
+└── scripts/ - 工具脚本目录
+ ├── pack_dll.sh - .NET库打包脚本
+ ├── pack_native.sh - 原生库打包脚本
+ └── generate_pdf.sh - PDF生成脚本
+```
+
+## 开发环境要求
+
+- .NET 8.0 或更高版本
+- Visual Studio 2022 或更高版本
+- DocFX(用于生成文档)
+- wkhtmltopdf(用于生成 PDF)
+
+## 使用说明
+
+### C#/.NET 用户
+
+1. 通过 NuGet 包管理器安装:
+
+ ```bash
+ dotnet add package ThreatSource
+ ```
+
+2. 或直接引用 DLL 文件:
+ - 下载最新的 zip 包
+ - 解压并引用 ThreatSource.dll
+
+### C++用户
+
+有两种使用方式:
+
+#### 方式一:动态加载(推荐)
+
+1. 下载 ThreatSourceNative 包
+2. 将 bin 目录下的所有 DLL 复制到程序目录
+3. 将 include/threat_source.h 添加到项目
+4. 使用 C 风格接口调用库功能
+
+#### 方式二:CLR 集成
+
+如果需要使用 .NET 的完整功能:
+
+1. 配置项目属性:
+ - C/C++ -> 常规 -> 公共语言运行时支持:/clr
+ - 常规 -> 平台工具集:Visual Studio 2022 (v143)
+ - 常规 -> .NET目标框架:net8.0
+
+2. 引用 ThreatSource.dll
+
+## 示例代码
+
+请参考 [docs/examples](docs/examples) 目录下的示例代码:
+
+- [集成示例](docs/examples/Integration/README.md)
+- [仿真示例](docs/examples/Simulation/README.md)
+
+## 许可证
+
+MIT License
diff --git a/ThreatSource/ThreatSource.csproj b/ThreatSource/ThreatSource.csproj
index 77b618b..f9254cc 100644
--- a/ThreatSource/ThreatSource.csproj
+++ b/ThreatSource/ThreatSource.csproj
@@ -4,6 +4,12 @@
net8.0
enable
enable
+ 1.0.0
+ ThreatSource Library
+ A comprehensive library for missile simulation and threat source modeling.
+ Copyright © 2024
+ true
+
\ No newline at end of file
diff --git a/ThreatSourceNative/ThreatSourceNative.vcxproj b/ThreatSourceNative/ThreatSourceNative.vcxproj
new file mode 100644
index 0000000..29fe0ab
--- /dev/null
+++ b/ThreatSourceNative/ThreatSourceNative.vcxproj
@@ -0,0 +1,65 @@
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+ 16.0
+ {12345678-1234-1234-1234-123456789ABC}
+ Win32Proj
+ ThreatSourceNative
+ 10.0
+
+
+
+
+
+ DynamicLibrary
+ v143
+ Unicode
+ true
+
+
+
+
+
+ $(SolutionDir)bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)obj\$(Platform)\$(Configuration)\
+
+
+
+
+ Level3
+ THREATSOURCE_EXPORTS;%(PreprocessorDefinitions)
+ $(ProjectDir)include;%(AdditionalIncludeDirectories)
+
+
+ Windows
+ %(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\ThreatSource\bin\$(Configuration)\net8.0\ThreatSource.dll
+
+
+
+
+
\ No newline at end of file
diff --git a/ThreatSourceNative/include/threat_source.h b/ThreatSourceNative/include/threat_source.h
new file mode 100644
index 0000000..5ce7379
--- /dev/null
+++ b/ThreatSourceNative/include/threat_source.h
@@ -0,0 +1,70 @@
+#ifndef THREAT_SOURCE_H
+#define THREAT_SOURCE_H
+
+#ifdef _WIN32
+ #ifdef THREATSOURCE_EXPORTS
+ #define THREATSOURCE_API __declspec(dllexport)
+ #else
+ #define THREATSOURCE_API __declspec(dllimport)
+ #endif
+#else
+ #define THREATSOURCE_API
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// 错误码定义
+#define THREATSOURCE_SUCCESS 0
+#define THREATSOURCE_ERROR_INVALID_PARAM -1
+#define THREATSOURCE_ERROR_INIT_FAILED -2
+#define THREATSOURCE_ERROR_SIMULATION_FAILED -3
+
+// 仿真管理
+THREATSOURCE_API int TS_CreateSimulation();
+THREATSOURCE_API int TS_DestroySimulation();
+
+// 导弹相关
+THREATSOURCE_API int TS_CreateMissile(
+ const char* id,
+ double x, double y, double z, // 初始位置
+ double vx, double vy, double vz, // 初始速度
+ double max_speed, // 最大速度
+ double max_acceleration, // 最大加速度
+ double max_flight_time, // 最大飞行时间
+ double max_flight_distance, // 最大飞行距离
+ double mass // 质量
+);
+
+THREATSOURCE_API int TS_ActivateMissile(const char* id);
+THREATSOURCE_API int TS_DeactivateMissile(const char* id);
+THREATSOURCE_API int TS_FireMissile(const char* id);
+THREATSOURCE_API int TS_GetMissilePosition(const char* id, double* x, double* y, double* z);
+THREATSOURCE_API int TS_GetMissileVelocity(const char* id, double* vx, double* vy, double* vz);
+THREATSOURCE_API int TS_IsMissileActive(const char* id, int* active);
+
+// 目标相关
+THREATSOURCE_API int TS_CreateTarget(
+ const char* id,
+ double x, double y, double z, // 位置
+ double orientation // 朝向(弧度)
+);
+
+THREATSOURCE_API int TS_ActivateTarget(const char* id);
+THREATSOURCE_API int TS_DeactivateTarget(const char* id);
+THREATSOURCE_API int TS_GetTargetPosition(const char* id, double* x, double* y, double* z);
+THREATSOURCE_API int TS_GetTargetOrientation(const char* id, double* orientation);
+
+// 仿真控制
+THREATSOURCE_API int TS_UpdateSimulation(double deltaTime);
+THREATSOURCE_API int TS_GetSimulationTime(double* time);
+
+// 事件查询
+THREATSOURCE_API int TS_GetLastError(char* buffer, int buffer_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // THREAT_SOURCE_H
\ No newline at end of file
diff --git a/ThreatSourceNative/src/threat_source.cpp b/ThreatSourceNative/src/threat_source.cpp
new file mode 100644
index 0000000..6d9707e
--- /dev/null
+++ b/ThreatSourceNative/src/threat_source.cpp
@@ -0,0 +1,190 @@
+#include "../include/threat_source.h"
+#include
+#include
+#include
+#include
+
+using namespace System;
+using namespace ThreatSource::Simulation;
+
+// 全局变量
+static msclr::auto_gcroot g_manager;
+static std::unordered_map> g_missiles;
+static std::unordered_map> g_targets;
+static std::string g_last_error;
+
+// 辅助函数:设置错误信息
+void SetLastError(const char* error) {
+ g_last_error = error;
+}
+
+// 仿真管理
+THREATSOURCE_API int TS_CreateSimulation() {
+ try {
+ g_manager = gcnew SimulationManager();
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_INIT_FAILED;
+ }
+}
+
+THREATSOURCE_API int TS_DestroySimulation() {
+ try {
+ g_manager = nullptr;
+ g_missiles.clear();
+ g_targets.clear();
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+// 导弹相关
+THREATSOURCE_API int TS_CreateMissile(
+ const char* id,
+ double x, double y, double z,
+ double vx, double vy, double vz,
+ double max_speed,
+ double max_acceleration,
+ double max_flight_time,
+ double max_flight_distance,
+ double mass
+) {
+ if (!id) {
+ SetLastError("Invalid missile ID");
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ String^ managedId = gcnew String(id);
+
+ auto properties = gcnew MissileProperties();
+ properties->Id = managedId;
+ properties->InitialPosition = Vector3D(x, y, z);
+ properties->InitialVelocity = Vector3D(vx, vy, vz);
+ properties->MaxSpeed = max_speed;
+ properties->MaxAcceleration = max_acceleration;
+ properties->MaxFlightTime = max_flight_time;
+ properties->MaxFlightDistance = max_flight_distance;
+ properties->Mass = mass;
+
+ auto missile = gcnew TerminalSensitiveMissile(managedId, properties, g_manager);
+ g_manager->RegisterEntity(managedId, missile);
+ g_missiles[id] = missile;
+
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+THREATSOURCE_API int TS_ActivateMissile(const char* id) {
+ if (!id || g_missiles.find(id) == g_missiles.end()) {
+ SetLastError("Invalid missile ID");
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ g_missiles[id]->Activate();
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+THREATSOURCE_API int TS_DeactivateMissile(const char* id) {
+ if (!id || g_missiles.find(id) == g_missiles.end()) {
+ SetLastError("Invalid missile ID");
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ g_missiles[id]->Deactivate();
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+THREATSOURCE_API int TS_FireMissile(const char* id) {
+ if (!id || g_missiles.find(id) == g_missiles.end()) {
+ SetLastError("Invalid missile ID");
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ g_missiles[id]->Fire();
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+// 目标相关
+THREATSOURCE_API int TS_CreateTarget(
+ const char* id,
+ double x, double y, double z,
+ double orientation
+) {
+ if (!id) {
+ SetLastError("Invalid target ID");
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ String^ managedId = gcnew String(id);
+ auto target = gcnew Tank(managedId, Vector3D(x, y, z), orientation, g_manager);
+ g_manager->RegisterEntity(managedId, target);
+ g_targets[id] = target;
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+// 仿真控制
+THREATSOURCE_API int TS_UpdateSimulation(double deltaTime) {
+ try {
+ for (auto& pair : g_missiles) {
+ pair.second->Update(deltaTime);
+ }
+ for (auto& pair : g_targets) {
+ pair.second->Update(deltaTime);
+ }
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (Exception^ e) {
+ SetLastError(msclr::interop::marshal_as(e->Message).c_str());
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
+
+// 错误查询
+THREATSOURCE_API int TS_GetLastError(char* buffer, int buffer_size) {
+ if (!buffer || buffer_size <= 0) {
+ return THREATSOURCE_ERROR_INVALID_PARAM;
+ }
+
+ try {
+ strncpy(buffer, g_last_error.c_str(), buffer_size - 1);
+ buffer[buffer_size - 1] = '\0';
+ return THREATSOURCE_SUCCESS;
+ }
+ catch (...) {
+ return THREATSOURCE_ERROR_SIMULATION_FAILED;
+ }
+}
\ No newline at end of file
diff --git a/docs/articles/docfx-guide.md b/docfx-guide.md
similarity index 100%
rename from docs/articles/docfx-guide.md
rename to docfx-guide.md
diff --git a/docs/README.md b/docs/README.md
deleted file mode 100644
index 9891e20..0000000
--- a/docs/README.md
+++ /dev/null
@@ -1,103 +0,0 @@
-# ThreatSource Library
-
-## 项目描述
-
-ThreatSource Library 是一个专门用于军事目标和武器系统模拟的 C# 类库。该库提供了一套完整的类和接口,用于模拟各种军事目标(如坦克)、指示器(如激光指示器)以及不同类型的导弹系统。
-
-## 主要功能
-
-- 目标模拟(Target)
- - 坦克(Tank)等地面目标的模拟
-- 指示器系统(Indicator)
- - 激光指示器(LaserDesignator)
- - 激光波束制导(LaserBeamRider)
- - 红外追踪器(InfraredTracker)
-- 导弹系统(Missile)
- - 基础导弹类(BaseMissile)
- - 激光波束制导导弹(LaserBeamRiderMissile)
- - 红外指令制导导弹(InfraredCommandGuidedMissile)
- - 激光半主动制导导弹(LaserSemiActiveGuidedMissile)
- - 红外成像末制导导弹(InfraredImagingTerminalGuidedMissile)
- - 毫米波末制导导弹(MillimeterWaveTerminalGuidedMissile)
- - 末敏导弹(TerminalSensitiveMissile)
- - 末敏子弹药(TerminalSensitiveSubmunition)
-
-## 使用说明
-
-1. 引用项目
-
- ```csharp
- using ThreatSource;
- ```
-
-2. 创建目标实例
-
- ```csharp
- var tank = new Tank();
- ```
-
-3. 创建指示器
-
- ```csharp
- var laserDesignator = new LaserDesignator();
- ```
-
-4. 创建导弹
-
- ```csharp
- var missile = new LaserBeamRiderMissile();
- ```
-
-## 项目结构
-
-```text
-ThreatSource/
-├── Target/
-│ └── Tank.cs
-├── Indicator/
-│ ├── LaserDesignator.cs
-│ ├── LaserBeamRider.cs
-│ └── InfraredTracker.cs
-└── Missile/
- ├── BaseMissile.cs
- ├── LaserBeamRiderMissile.cs
- ├── InfraredCommandGuidedMissile.cs
- ├── LaserSemiActiveGuidedMissile.cs
- ├── InfraredImagingTerminalGuidedMissile.cs
- ├── MillimeterWaveTerminalGuidedMissile.cs
- ├── TerminalSensitiveMissile.cs
- └── TerminalSensitiveSubmunition.cs
-```
-
-## 开发环境
-
-- .NET 6.0 或更高版本
-- Visual Studio 2022 或更高版本
-- xUnit(用于单元测试)
-
-## 测试
-
-项目使用 xUnit 作为测试框架。所有测试文件都位于 `ThreatSource.Tests` 目录下。
-
-运行测试:
-
-1. 在 Visual Studio 中打开测试资源管理器
-2. 点击"运行所有测试"或选择特定测试运行
-
-或使用命令行:
-
-```bash
-dotnet test
-```
-
-## 贡献指南
-
-1. Fork 项目
-2. 创建特性分支
-3. 提交更改
-4. 推送到分支
-5. 创建 Pull Request
-
-## 许可证
-
-MIT License
diff --git a/docs/articles/intro.md b/docs/articles/intro.md
index 63cb01a..21751f6 100644
--- a/docs/articles/intro.md
+++ b/docs/articles/intro.md
@@ -1,35 +1,197 @@
# 入门指南
-## 安装
+## 安装和使用
-### C#版本
+### C#/.NET 版本
-通过NuGet包管理器安装威胁源仿真库:
+1. 下载 ThreatSourceLibrary 包并解压
+2. 将以下文件复制到你的项目目录(建议放在 lib 文件夹下):
+ - ThreatSource.dll - 主要的库文件
+ - ThreatSource.deps.json - 依赖配置文件
+ - ThreatSource.xml - API 文档文件
-```bash
-dotnet add package ThreatSource
+3. 在 Visual Studio 中添加引用:
+ - 右键项目 -> 添加 -> 引用
+ - 浏览 -> 选择 ThreatSource.dll
+
+4. 在代码中使用:
+
+```csharp
+using ThreatSource.Simulation;
+
+class Program
+{
+ static void Main()
+ {
+ try
+ {
+ // 创建仿真管理器
+ var simulationManager = new SimulationManager();
+
+ // 创建导弹配置
+ var missileProperties = new MissileProperties
+ {
+ Id = "missile1",
+ InitialPosition = new Vector3D(0, 0, 0),
+ InitialVelocity = new Vector3D(0, 0, 0),
+ MaxSpeed = 1000,
+ MaxAcceleration = 10,
+ MaxFlightTime = 30,
+ MaxFlightDistance = 5000,
+ Mass = 50
+ };
+
+ // 创建导弹实例
+ var missile = new TerminalSensitiveMissile(
+ "target1",
+ missileProperties,
+ simulationManager
+ );
+
+ // 注册实体
+ simulationManager.RegisterEntity(missile.Id, missile);
+
+ // 激活并发射导弹
+ missile.Activate();
+ missile.Fire();
+
+ // 仿真主循环
+ double deltaTime = 0.01;
+ while (missile.IsActive)
+ {
+ missile.Update(deltaTime);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Error: {ex.Message}");
+ }
+ }
+}
```
### C++版本
-有两种使用方式:
+C++项目有两种使用方式:
-#### 方式一:C++/CLI(推荐)
+#### 方式一:动态加载(推荐)
-1. 创建C++/CLI项目(Visual Studio -> 新建项目 -> CLR类库)
-2. 通过NuGet包管理器安装ThreatSource
-3. 配置项目属性:
- - 公共语言运行时支持:/clr
- - 平台工具集:Visual Studio 2022 (v143)
- - .NET目标框架:net8.0
+这种方式适合纯C++项目,不需要配置CLR支持。
-#### 方式二:原生C++
+1. 下载 ThreatSourceNative 包并解压
+2. 将 bin 目录下的所有 DLL 文件复制到程序目录
+3. 将 include/threat_source.h 添加到项目中
+4. 使用 C 风格接口调用库功能
-1. 下载对应版本的 ThreatSource.dll
-2. 将DLL放置在项目输出目录
-3. 确保DLL版本与项目平台配置匹配(x86/x64)
+示例代码:
-## C#基本用法
+```cpp
+#include "threat_source.h"
+#include
+
+int main() {
+ // 初始化仿真
+ if (TS_CreateSimulation() != THREATSOURCE_SUCCESS) {
+ printf("Failed to create simulation\n");
+ return 1;
+ }
+
+ // 创建导弹
+ const char* missile_id = "missile1";
+ int result = TS_CreateMissile(
+ missile_id,
+ 0, 0, 0, // 初始位置
+ 0, 0, 0, // 初始速度
+ 1000, // 最大速度
+ 10, // 最大加速度
+ 30, // 最大飞行时间
+ 5000, // 最大飞行距离
+ 50 // 质量
+ );
+
+ if (result != THREATSOURCE_SUCCESS) {
+ char error[256];
+ TS_GetLastError(error, sizeof(error));
+ printf("Failed to create missile: %s\n", error);
+ return 1;
+ }
+
+ // 激活并发射导弹
+ TS_ActivateMissile(missile_id);
+ TS_FireMissile(missile_id);
+
+ // 仿真主循环
+ double deltaTime = 0.01;
+ int is_active = 1;
+
+ while (is_active) {
+ TS_UpdateSimulation(deltaTime);
+ TS_IsMissileActive(missile_id, &is_active);
+ }
+
+ // 清理
+ TS_DestroySimulation();
+ return 0;
+}
+```
+
+#### 方式二:CLR 集成
+
+如果需要使用 .NET 的完整功能,可以选择 CLR 集成方式:
+
+1. 配置项目属性:
+ - C/C++ -> 常规 -> 公共语言运行时支持:/clr
+ - 常规 -> 平台工具集:Visual Studio 2022 (v143)
+ - 常规 -> .NET目标框架:net8.0
+
+2. 引用 ThreatSource.dll
+
+示例代码:
+
+```cpp
+using namespace System;
+using namespace ThreatSource::Simulation;
+
+int main() {
+ try {
+ // 创建仿真管理器
+ auto manager = gcnew SimulationManager();
+
+ // 创建导弹配置
+ auto properties = gcnew MissileProperties();
+ properties->Id = "missile1";
+ properties->InitialPosition = Vector3D(0, 0, 0);
+ properties->InitialVelocity = Vector3D(0, 0, 0);
+ properties->MaxSpeed = 1000;
+ properties->MaxAcceleration = 10;
+ properties->MaxFlightTime = 30;
+ properties->MaxFlightDistance = 5000;
+ properties->Mass = 50;
+
+ // 创建导弹
+ auto missile = gcnew TerminalSensitiveMissile("target1", properties, manager);
+ manager->RegisterEntity(missile->Id, missile);
+
+ // 激活并发射导弹
+ missile->Activate();
+ missile->Fire();
+
+ // 仿真主循环
+ double deltaTime = 0.01;
+ while (missile->IsActive) {
+ missile->Update(deltaTime);
+ }
+
+ return 0;
+ }
+ catch (Exception^ e) {
+ Console::WriteLine("Error: {0}", e->Message);
+ return 1;
+ }
+}
+```
+
+## 基本用法
### 初始化仿真管理器
@@ -98,9 +260,7 @@ while (missile.IsActive)
## C++使用指南
-在C++项目中使用威胁源仿真库有两种方式:C++/CLI和原生C++。以下重点介绍推荐的C++/CLI方式:
-
-### C++/CLI方式(推荐)
+### C++/CLI基本用法
#### 1. 创建包装类
@@ -176,28 +336,19 @@ int main()
}
```
-### 原生C++方式
-
-如果必须使用原生C++(不推荐),请参考以下方式:
-
### 注意事项
-1. C++/CLI vs 原生C++
- - C++/CLI方式更简单,直接使用.NET类型
- - 原生C++方式需要更多的封装和转换工作
- - C++/CLI性能可能略低,但开发效率更高
-
-2. 内存管理
+1. 内存管理
- C++/CLI使用垃圾回收
- 使用gcnew创建托管对象
- 注意托管和非托管资源的混合使用
-3. 错误处理
+2. 错误处理
- 使用托管异常处理(try/catch)
- 异常信息更详细,更容易调试
- 可以直接使用.NET的日志机制
-4. 类型系统
+3. 类型系统
- 使用托管类型(^)
- 注意值类型和引用类型的区别
- 使用安全的类型转换
diff --git a/publish/ThreatSourceLibrary-1.0.0.zip b/publish/ThreatSourceLibrary-1.0.0.zip
new file mode 100644
index 0000000..04ef32a
Binary files /dev/null and b/publish/ThreatSourceLibrary-1.0.0.zip differ
diff --git a/ThreatSource-Library.pdf b/publish/ThreatSourceLibraryGuide.pdf
similarity index 54%
rename from ThreatSource-Library.pdf
rename to publish/ThreatSourceLibraryGuide.pdf
index 8d89a37..de8a01e 100644
Binary files a/ThreatSource-Library.pdf and b/publish/ThreatSourceLibraryGuide.pdf differ
diff --git a/scripts/generate_pdf.sh b/scripts/generate_pdf.sh
index 75baa05..32485f2 100755
--- a/scripts/generate_pdf.sh
+++ b/scripts/generate_pdf.sh
@@ -9,6 +9,9 @@ temp_file="html_files.txt"
# 获取当前目录的绝对路径
current_dir=$(pwd)
+# 创建发布目录(如果不存在)
+mkdir -p "${current_dir}/publish"
+
# 首先添加主页
echo "file://${current_dir}/docs/_site/docs/index.html" >> $temp_file
@@ -24,6 +27,11 @@ find "${current_dir}/docs/_site/docs/api" -name "*.html" | sed 's|^|file://|' >>
# 构建wkhtmltopdf命令
cmd="wkhtmltopdf \
--enable-local-file-access \
+ --enable-javascript \
+ --javascript-delay 1000 \
+ --no-stop-slow-scripts \
+ --enable-external-links \
+ --enable-internal-links \
--page-size A4 \
--margin-top 15 \
--margin-bottom 15 \
@@ -43,7 +51,7 @@ while IFS= read -r file; do
done < "$temp_file"
# 添加输出文件名
-cmd="$cmd \"${current_dir}/ThreatSource-Library.pdf\""
+cmd="$cmd \"${current_dir}/publish/ThreatSource-Library.pdf\""
# 执行命令
eval $cmd
@@ -51,4 +59,4 @@ eval $cmd
# 删除临时文件
rm $temp_file
-echo "PDF generation completed: ThreatSource-Library.pdf"
\ No newline at end of file
+echo "PDF generation completed: publish/ThreatSource-Library.pdf"
\ No newline at end of file
diff --git a/scripts/pack_dll.sh b/scripts/pack_dll.sh
new file mode 100755
index 0000000..37cc61b
--- /dev/null
+++ b/scripts/pack_dll.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# 获取版本号(从项目文件中)
+version=$(grep -o '[^<]*' ThreatSource/ThreatSource.csproj | sed 's/\(.*\)<\/Version>/\1/')
+
+if [ -z "$version" ]; then
+ echo "Error: Could not find version number in ThreatSource.csproj"
+ exit 1
+fi
+
+# 创建发布目录(如果不存在)
+mkdir -p publish
+
+# 设置打包文件名
+package_name="ThreatSourceLibrary-${version}"
+package_dir="publish/${package_name}"
+
+# 创建临时目录
+mkdir -p "${package_dir}"
+
+# 复制文件
+cp ThreatSource/bin/Release/net8.0/ThreatSource.dll "${package_dir}/"
+cp ThreatSource/bin/Release/net8.0/ThreatSource.deps.json "${package_dir}/"
+cp ThreatSource/bin/Release/net8.0/ThreatSource.xml "${package_dir}/"
+
+# 创建 zip 文件
+cd publish
+zip -r "${package_name}.zip" "${package_name}"
+
+# 清理临时目录
+rm -rf "${package_name}"
+
+echo "Package created: publish/${package_name}.zip"
\ No newline at end of file
diff --git a/scripts/pack_native.sh b/scripts/pack_native.sh
new file mode 100644
index 0000000..7722f16
--- /dev/null
+++ b/scripts/pack_native.sh
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+# 获取版本号(从项目文件中)
+version=$(grep -o '[^<]*' ThreatSource/ThreatSource.csproj | sed 's/\(.*\)<\/Version>/\1/')
+
+if [ -z "$version" ]; then
+ echo "Error: Could not find version number in ThreatSource.csproj"
+ exit 1
+fi
+
+# 创建发布目录(如果不存在)
+mkdir -p publish
+
+# 设置打包文件名
+package_name="ThreatSourceNative-${version}"
+package_dir="publish/${package_name}"
+
+# 创建临时目录
+mkdir -p "${package_dir}/bin"
+mkdir -p "${package_dir}/include"
+
+# 复制文件
+cp ThreatSourceNative/bin/Release/x64/ThreatSourceNative.dll "${package_dir}/bin/"
+cp ThreatSource/bin/Release/net8.0/ThreatSource.dll "${package_dir}/bin/"
+cp ThreatSource/bin/Release/net8.0/ThreatSource.deps.json "${package_dir}/bin/"
+cp ThreatSourceNative/include/threat_source.h "${package_dir}/include/"
+
+# 创建说明文件
+cat > "${package_dir}/README.md" << EOL
+# ThreatSource Native Library
+
+版本:${version}
+
+## 文件说明
+
+- bin/ThreatSourceNative.dll - 原生接口库
+- bin/ThreatSource.dll - 核心库
+- bin/ThreatSource.deps.json - 依赖配置文件
+- include/threat_source.h - C接口头文件
+
+## 使用方法
+
+1. 将 bin 目录下的所有 DLL 文件复制到你的程序目录
+2. 将 include 目录下的头文件添加到你的项目中
+3. 在代码中包含头文件:
+ \`\`\`cpp
+ #include "threat_source.h"
+ \`\`\`
+
+## 示例代码
+
+\`\`\`cpp
+#include "threat_source.h"
+#include
+
+int main() {
+ // 初始化仿真
+ if (TS_CreateSimulation() != THREATSOURCE_SUCCESS) {
+ printf("Failed to create simulation\\n");
+ return 1;
+ }
+
+ // 创建导弹
+ const char* missile_id = "missile1";
+ int result = TS_CreateMissile(
+ missile_id,
+ 0, 0, 0, // 初始位置
+ 0, 0, 0, // 初始速度
+ 1000, // 最大速度
+ 10, // 最大加速度
+ 30, // 最大飞行时间
+ 5000, // 最大飞行距离
+ 50 // 质量
+ );
+
+ if (result != THREATSOURCE_SUCCESS) {
+ char error[256];
+ TS_GetLastError(error, sizeof(error));
+ printf("Failed to create missile: %s\\n", error);
+ return 1;
+ }
+
+ // 激活并发射导弹
+ TS_ActivateMissile(missile_id);
+ TS_FireMissile(missile_id);
+
+ // 仿真主循环
+ double deltaTime = 0.01;
+ int is_active = 1;
+
+ while (is_active) {
+ TS_UpdateSimulation(deltaTime);
+ TS_IsMissileActive(missile_id, &is_active);
+ }
+
+ // 清理
+ TS_DestroySimulation();
+ return 0;
+}
+\`\`\`
+
+## 注意事项
+
+1. 确保所有 DLL 文件在运行时可以被找到
+2. 检查每个函数的返回值,确保调用成功
+3. 如果函数返回错误,使用 TS_GetLastError 获取详细信息
+EOL
+
+# 创建 zip 文件
+cd publish
+zip -r "${package_name}.zip" "${package_name}"
+
+# 清理临时目录
+rm -rf "${package_name}"
+
+echo "Package created: publish/${package_name}.zip"
\ No newline at end of file