mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] 接入ET8服务端
[+] 接入ET8服务端
This commit is contained in:
62
Assets/GameScripts/DotNet/Model/Share/Module/Unit/Unit.cs
Normal file
62
Assets/GameScripts/DotNet/Model/Share/Module/Unit/Unit.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Diagnostics;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ET
|
||||
{
|
||||
[ChildOf(typeof(UnitComponent))]
|
||||
[DebuggerDisplay("ViewName,nq")]
|
||||
public class Unit: Entity, IAwake<int>
|
||||
{
|
||||
public int ConfigId { get; set; } //配置表id
|
||||
|
||||
[BsonIgnore]
|
||||
public UnitConfig Config => UnitConfigCategory.Instance.Get(this.ConfigId);
|
||||
|
||||
public UnitType Type => (UnitType)UnitConfigCategory.Instance.Get(this.ConfigId).Type;
|
||||
|
||||
[BsonElement]
|
||||
private float3 position; //坐标
|
||||
|
||||
[BsonIgnore]
|
||||
public float3 Position
|
||||
{
|
||||
get => this.position;
|
||||
set
|
||||
{
|
||||
float3 oldPos = this.position;
|
||||
this.position = value;
|
||||
EventSystem.Instance.Publish(this.Scene(), new EventType.ChangePosition() { Unit = this, OldPos = oldPos });
|
||||
}
|
||||
}
|
||||
|
||||
[BsonIgnore]
|
||||
public float3 Forward
|
||||
{
|
||||
get => math.mul(this.Rotation, math.forward());
|
||||
set => this.Rotation = quaternion.LookRotation(value, math.up());
|
||||
}
|
||||
|
||||
[BsonElement]
|
||||
private quaternion rotation;
|
||||
|
||||
[BsonIgnore]
|
||||
public quaternion Rotation
|
||||
{
|
||||
get => this.rotation;
|
||||
set
|
||||
{
|
||||
this.rotation = value;
|
||||
EventSystem.Instance.Publish(this.Scene(), new EventType.ChangeRotation() { Unit = this });
|
||||
}
|
||||
}
|
||||
|
||||
protected override string ViewName
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{this.GetType().FullName} ({this.Id})";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3da3f3ce5b234ff4e9a0ac52abeb8638
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
namespace ET
|
||||
{
|
||||
|
||||
[ComponentOf(typeof(Scene))]
|
||||
public class UnitComponent: Entity, IAwake, IDestroy
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e471c38a87a0d7d47a324bfcdb9fa160
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,18 @@
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ET
|
||||
{
|
||||
namespace EventType
|
||||
{
|
||||
public struct ChangePosition
|
||||
{
|
||||
public Unit Unit;
|
||||
public float3 OldPos;
|
||||
}
|
||||
|
||||
public struct ChangeRotation
|
||||
{
|
||||
public Unit Unit;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 536f5650e527ebc4abd29873e5beaa23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
namespace ET
|
||||
{
|
||||
public enum UnitType: byte
|
||||
{
|
||||
Player = 1,
|
||||
Monster = 2,
|
||||
NPC = 3,
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36e597b9a37681d43afd1812cf5008dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user