1
This commit is contained in:
34
Src/Crafting/ICraftingEnvironment.cs
Normal file
34
Src/Crafting/ICraftingEnvironment.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.WorldNode;
|
||||
|
||||
namespace Net.Project.B.Craft
|
||||
{
|
||||
|
||||
// 合成环境,例如工作台(制造),篝火(烹饪或温度)
|
||||
public interface ICraftEnvironment
|
||||
{
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public class CraftingWorkbench:ICraftEnvironment,IWorldNode
|
||||
{
|
||||
public override bool Equals(object obj) => obj is CraftingWorkbench;
|
||||
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
}
|
||||
[Serializable]
|
||||
public class CraftingTemperatureSource:ICraftEnvironment,IWorldNode
|
||||
{
|
||||
public override bool Equals(object obj) => obj is CraftingTemperatureSource;
|
||||
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
}
|
||||
[Serializable]
|
||||
public class CraftingWaterSource:ICraftEnvironment,IWorldNode
|
||||
{
|
||||
public override bool Equals(object obj) => obj is CraftingWaterSource;
|
||||
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
}
|
||||
}
|
11
Src/Crafting/ICraftingEnvironment.cs.meta
Normal file
11
Src/Crafting/ICraftingEnvironment.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e73646397d685e24ea49a0c4d45353fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
57
Src/Crafting/ICrating.cs
Normal file
57
Src/Crafting/ICrating.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Net.Project.B.Craft
|
||||
{
|
||||
// 合成配方
|
||||
public interface ICraftRecipe
|
||||
{
|
||||
int Id { get; }
|
||||
public int CraftItemId { get; }
|
||||
IReadOnlyDictionary<int,int> RequiredItems { get; }
|
||||
IReadOnlyDictionary<string,int> RequiredTags { get; }
|
||||
IReadOnlyCollection<ICraftEnvironment> RequiredEnvironments { get; }
|
||||
}
|
||||
|
||||
public class CraftRecipe : ICraftRecipe
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CraftItemId { get; set; }
|
||||
public readonly Dictionary<int, int> RequiredItems = new();
|
||||
public readonly Dictionary<string,int> RequiredTag = new();
|
||||
public readonly HashSet<ICraftEnvironment> RequiredEnvironments = new();
|
||||
|
||||
IReadOnlyDictionary<int, int> ICraftRecipe.RequiredItems => RequiredItems;
|
||||
IReadOnlyDictionary<string, int> ICraftRecipe.RequiredTags => RequiredTag;
|
||||
IReadOnlyCollection<ICraftEnvironment> ICraftRecipe.RequiredEnvironments => RequiredEnvironments;
|
||||
}
|
||||
// 合成服务
|
||||
public interface ICraftingService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取可合成配方(无 GC 分配),写入调用方传入的缓冲区
|
||||
/// </summary>
|
||||
/// <param name="buffer">结果缓冲区</param>
|
||||
/// <returns>写入的个数</returns>
|
||||
int GetCraftableRecipesNonGc(
|
||||
ICraftRecipe[] buffer);
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否可以合成(无 GC)
|
||||
/// </summary>
|
||||
bool CanCraftNonGc(ICraftRecipe recipe,out ICraftRecipe missing);
|
||||
|
||||
/// <summary>
|
||||
/// 执行合成(不会分配新对象)
|
||||
/// </summary>
|
||||
bool TryCraftNonGc(ICraftRecipe recipe);
|
||||
|
||||
/// <summary>
|
||||
/// 获取合成环境
|
||||
/// </summary>
|
||||
/// <param name="buffer"></param>
|
||||
/// <returns></returns>
|
||||
int QueryCraftEnvironments(ICraftEnvironment[] buffer);
|
||||
}
|
||||
|
||||
}
|
11
Src/Crafting/ICrating.cs.meta
Normal file
11
Src/Crafting/ICrating.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bb537c45fe82d5499d8ac656a415c6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Src/Crafting/Net.Project.B.Crafting.asmdef
Normal file
19
Src/Crafting/Net.Project.B.Crafting.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Net.Project.B.Crafting",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:d750d221812bb1d48baff92e6ef73e28"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": true
|
||||
}
|
7
Src/Crafting/Net.Project.B.Crafting.asmdef.meta
Normal file
7
Src/Crafting/Net.Project.B.Crafting.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 564e9f22877ff6544a2f3c9b209a7752
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user