[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,18 @@
using System;
namespace ET
{
public class AIHandlerAttribute: BaseAttribute
{
}
[AIHandler]
public abstract class AAIHandler
{
// 检查是否满足条件
public abstract int Check(AIComponent aiComponent, AIConfig aiConfig);
// 协程编写必须可以取消
public abstract ETTask Execute(AIComponent aiComponent, AIConfig aiConfig, ETCancellationToken cancellationToken);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e43892262fb7af4b95b158fa391da91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
namespace ET
{
// 客户端挂在ClientScene上服务端挂在Unit上
[ComponentOf(typeof(Scene))]
public class AIComponent: Entity, IAwake<int>, IDestroy
{
public int AIConfigId;
public ETCancellationToken CancellationToken;
public long Timer;
public int Current;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b13f63f82f588d4382b1e8cb779425e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.ComponentModel;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace ET
{
public partial class AIConfigCategory
{
[BsonIgnore]
public Dictionary<int, SortedDictionary<int, AIConfig>> AIConfigs = new Dictionary<int, SortedDictionary<int, AIConfig>>();
public SortedDictionary<int, AIConfig> GetAI(int aiConfigId)
{
return this.AIConfigs[aiConfigId];
}
public override void EndInit()
{
foreach (var kv in this.GetAll())
{
SortedDictionary<int, AIConfig> aiNodeConfig;
if (!this.AIConfigs.TryGetValue(kv.Value.AIConfigId, out aiNodeConfig))
{
aiNodeConfig = new SortedDictionary<int, AIConfig>();
this.AIConfigs.Add(kv.Value.AIConfigId, aiNodeConfig);
}
aiNodeConfig.Add(kv.Key, kv.Value);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f733a3428ecb9224d8917bd0aed54a0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
namespace ET
{
public class AIDispatcherComponent: SingletonLock<AIDispatcherComponent>, ISingletonAwake
{
private readonly Dictionary<string, AAIHandler> aiHandlers = new();
public void Awake()
{
var types = EventSystem.Instance.GetTypes(typeof (AIHandlerAttribute));
foreach (Type type in types)
{
AAIHandler aaiHandler = Activator.CreateInstance(type) as AAIHandler;
if (aaiHandler == null)
{
Log.Error($"robot ai is not AAIHandler: {type.Name}");
continue;
}
this.aiHandlers.Add(type.Name, aaiHandler);
}
}
public AAIHandler Get(string key)
{
this.aiHandlers.TryGetValue(key, out var aaiHandler);
return aaiHandler;
}
public override void Load()
{
World.Instance.AddSingleton<AIDispatcherComponent>(true);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70505ae07c0ed05469c46867370eae98
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: