mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
修复主从交互bug
This commit is contained in:
@@ -8,6 +8,8 @@ namespace Game.JNGFrame.Logic.Entity
|
||||
{
|
||||
|
||||
public override IContext[] allContexts { get; } = { new EDNodeContext(),new EDPlayerContext(),new EDBossContext(), };
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.State.Tile;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
using JNGame.Sync.System.Data;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace Game.Logic.Entity
|
||||
{
|
||||
@@ -24,7 +26,17 @@ namespace Game.Logic.Entity
|
||||
}
|
||||
return LVector3.Down;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void TileSyncData(ISTileData data)
|
||||
{
|
||||
Transform.Position = data.GetDataPosition();
|
||||
}
|
||||
|
||||
public override void OnTileSlaveExit()
|
||||
{
|
||||
base.OnTileSlaveExit();
|
||||
//从服务器 - 实体移出后立即删除
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
}
|
@@ -34,6 +34,10 @@ namespace Game.JNGFrame.Logic.Entity.Controller
|
||||
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
|
||||
//Player 同步到从服务器
|
||||
TileEntity.IsSyncSlave = true;
|
||||
|
||||
base.OnSyncStart();
|
||||
Move.Speed = LFloat.L10;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Game.JNGFrame.Logic.Entity.Controller;
|
||||
using Entitas;
|
||||
using Game.JNGFrame.Logic.Entity.Controller;
|
||||
using Game.Logic.Entity.Nodes;
|
||||
using Game.Logic.Entity.Nodes.Component.Components;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
@@ -7,6 +8,7 @@ namespace Game.JNGFrame.Logic.Entity.Contexts
|
||||
{
|
||||
public sealed partial class EDPlayerContext : JNTileContext<EDPlayer>
|
||||
{
|
||||
|
||||
protected override EDPlayer BindComponent(EDPlayer entity)
|
||||
{
|
||||
base.BindComponent(entity);
|
||||
@@ -14,5 +16,6 @@ namespace Game.JNGFrame.Logic.Entity.Contexts
|
||||
entity.AddComponent<EDPlayerController>();
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -13,12 +13,6 @@ namespace Game.Logic.Entity.Nodes
|
||||
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);
|
||||
public EDBossController Controller => CLookup.Query<EDBossController>(this);
|
||||
|
||||
public override void TileSyncData(ISTileData data)
|
||||
{
|
||||
var nodeData = data as EDBossData;
|
||||
Transform.Position = nodeData.Value.Position.ToLVector3();
|
||||
}
|
||||
|
||||
public override JNEntityLookup NewCLookup()
|
||||
{
|
||||
return new EDBoosLookup();
|
||||
|
@@ -12,13 +12,6 @@ namespace Game.Logic.Entity.Nodes
|
||||
|
||||
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);
|
||||
|
||||
|
||||
public override void TileSyncData(ISTileData data)
|
||||
{
|
||||
var nodeData = data as EDNodeData;
|
||||
Transform.Position = nodeData.Value.Position.ToLVector3();
|
||||
}
|
||||
|
||||
public override JNEntityLookup NewCLookup()
|
||||
{
|
||||
return new EDNodeLookup();
|
||||
|
@@ -16,9 +16,9 @@ namespace Game.Logic.Entity.Nodes
|
||||
|
||||
public override void TileSyncData(ISTileData data)
|
||||
{
|
||||
base.TileSyncData(data);
|
||||
var nodeData = data as EDPlayerData;
|
||||
Controller.AuthBind(nodeData.Value.Auth.Value);
|
||||
Transform.Position = nodeData.Value.Position.ToLVector3();
|
||||
}
|
||||
|
||||
public override JNEntityLookup NewCLookup()
|
||||
|
@@ -30,5 +30,11 @@ namespace Game.Logic.System
|
||||
return LVector3.Down;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [状态同步生命周期] 玩家离开服务器 不在游戏线程中执行
|
||||
/// </summary>
|
||||
public virtual void OnPlayerExitServer(int auth){}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
using DotRecast.Core.Collections;
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using Game.Logic.Entity.Nodes;
|
||||
using JNGame.Math;
|
||||
@@ -40,5 +39,20 @@ namespace Game.Logic.System.Logic
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void OnPlayerExitServer(int auth)
|
||||
{
|
||||
base.OnPlayerExitServer(auth);
|
||||
|
||||
NodeContext.GetHostEntities().ForEach(child =>
|
||||
{
|
||||
if (child.Controller.Auth == auth)
|
||||
{
|
||||
child.DelayDestroy();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user