[+] 接入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,13 @@
namespace ET.Client
{
[ActorMessageHandler(SceneType.Demo)]
public class M2C_CreateMyUnitHandler: ActorMessageHandler<Scene, M2C_CreateMyUnit>
{
protected override async ETTask Run(Scene root, M2C_CreateMyUnit message)
{
// 通知场景切换协程继续往下走
root.GetComponent<ObjectWait>().Notify(new Wait_CreateMyUnit() {Message = message});
await ETTask.CompletedTask;
}
}
}

View File

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

View File

@@ -0,0 +1,22 @@
namespace ET.Client
{
[ActorMessageHandler(SceneType.Demo)]
public class M2C_CreateUnitsHandler: ActorMessageHandler<Scene, M2C_CreateUnits>
{
protected override async ETTask Run(Scene root, M2C_CreateUnits message)
{
Scene currentScene = root.CurrentScene();
UnitComponent unitComponent = currentScene.GetComponent<UnitComponent>();
foreach (UnitInfo unitInfo in message.Units)
{
if (unitComponent.Get(unitInfo.UnitId) != null)
{
continue;
}
Unit unit = UnitFactory.Create(currentScene, unitInfo);
}
await ETTask.CompletedTask;
}
}
}

View File

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

View File

@@ -0,0 +1,21 @@
namespace ET.Client
{
[ActorMessageHandler(SceneType.Demo)]
public class M2C_RemoveUnitsHandler: ActorMessageHandler<Scene, M2C_RemoveUnits>
{
protected override async ETTask Run(Scene root, M2C_RemoveUnits message)
{
UnitComponent unitComponent = root.CurrentScene()?.GetComponent<UnitComponent>();
if (unitComponent == null)
{
return;
}
foreach (long unitId in message.Units)
{
unitComponent.Remove(unitId);
}
await ETTask.CompletedTask;
}
}
}

View File

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

View File

@@ -0,0 +1,41 @@
using Unity.Mathematics;
namespace ET.Client
{
public static partial class UnitFactory
{
public static Unit Create(Scene currentScene, UnitInfo unitInfo)
{
UnitComponent unitComponent = currentScene.GetComponent<UnitComponent>();
Unit unit = unitComponent.AddChildWithId<Unit, int>(unitInfo.UnitId, unitInfo.ConfigId);
unitComponent.Add(unit);
unit.Position = unitInfo.Position;
unit.Forward = unitInfo.Forward;
NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
foreach (var kv in unitInfo.KV)
{
numericComponent.Set(kv.Key, kv.Value);
}
unit.AddComponent<MoveComponent>();
if (unitInfo.MoveInfo != null)
{
if (unitInfo.MoveInfo.Points.Count > 0)
{
unitInfo.MoveInfo.Points[0] = unit.Position;
unit.MoveToAsync(unitInfo.MoveInfo.Points).Coroutine();
}
}
unit.AddComponent<ObjectWait>();
unit.AddComponent<XunLuoPathComponent>();
EventSystem.Instance.Publish(unit.Scene(), new EventType.AfterUnitCreate() {Unit = unit});
return unit;
}
}
}

View File

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

View File

@@ -0,0 +1,18 @@
namespace ET.Client
{
public static partial class UnitHelper
{
public static Unit GetMyUnitFromClientScene(Scene root)
{
PlayerComponent playerComponent = root.GetComponent<PlayerComponent>();
Scene currentScene = root.GetComponent<CurrentScenesComponent>().Scene;
return currentScene.GetComponent<UnitComponent>().Get(playerComponent.MyId);
}
public static Unit GetMyUnitFromCurrentScene(Scene currentScene)
{
PlayerComponent playerComponent = currentScene.Root().GetComponent<PlayerComponent>();
return currentScene.GetComponent<UnitComponent>().Get(playerComponent.MyId);
}
}
}

View File

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