[+] 接入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,75 @@
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using TrueSync;
namespace ET
{
public static class LSWorldSystem
{
public static LSWorld LSWorld(this LSEntity entity)
{
return entity.IScene as LSWorld;
}
public static long GetId(this LSEntity entity)
{
return entity.LSWorld().GetId();
}
public static TSRandom GetRandom(this LSEntity entity)
{
return entity.LSWorld().Random;
}
}
[EnableMethod]
[ChildOf]
[ComponentOf]
public class LSWorld: LSEntity, IAwake, IScene, IRegisterLSEntitySystem
{
public LSWorld()
{
}
public LSWorld(SceneType sceneType)
{
this.Id = this.GetId();
this.SceneType = sceneType;
Log.Info($"LSScene create: {this.Id} {this.InstanceId}");
}
private readonly LSUpdater updater = new();
[BsonIgnore]
public Fiber Fiber { get; set; }
[BsonElement]
private long idGenerator;
public long GetId()
{
return ++this.idGenerator;
}
public TSRandom Random { get; set; }
[BsonIgnore]
public SceneType SceneType { get; set; }
public int Frame { get; set; }
public void Update()
{
this.updater.Update();
++this.Frame;
}
public void RegisterSystem(LSEntity entity)
{
this.updater.Add(entity);
}
}
}