using DotRecast.Core.Collections; using Game.Input; using Game.JNGFrame.Logic.Entity; using Game.JNGFrame.Logic.Entity.Contexts; using JNGame.Math; using JNGame.Sync.Frame.Service; using JNGame.Sync.System; using UnityEngine; namespace Game.Logic.System { /// /// 玩家逻辑 /// public class DPlayerSystem : DGBasisSystem { //Node 节点 public EDPlayer[] Nodes => NodeContext.GetHostEntities(); public EDPlayerContext NodeContext => Contexts.GetContext(); public DInputSystem Input => GetSystem(); public override void OnSyncUpdate() { base.OnSyncUpdate(); //创建角色 GetSystem().SInput().ForEach(child => { var key = child.Key; var idWorld = (IDWorld)child.Value; if (idWorld != null && idWorld.IsPlayerCreate) { var entity = NodeContext.CreateEntity(); entity.Controller.AuthBind(key); var spawn = new LVector3(Random.Float(0, 0),Random.Float(0, 0),Random.Float(0, 0)); entity.Move.SetPosition(spawn); } }); } } }