临时提交

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-19 03:51:59 +08:00
parent 425f2eabea
commit 1315802fa2
162 changed files with 16452 additions and 11111 deletions

View File

@@ -0,0 +1,18 @@
using JNGame.Runtime.System;
namespace GASSamples.Scripts
{
public class App
{
public static readonly JNGResService Resource = new JNGResService();
public static SystemBase[] AllSystem()
{
return new SystemBase[]
{
Resource
};
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3e00a9df020484eb50717285a43b5ef
timeCreated: 1729273609

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 878a2703693549d4b29a70a1977c5dc1
timeCreated: 1729273912

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 948b04fc24754ee587ad380cc15a923a
timeCreated: 1729276738

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Concurrent;
using GASSamples.Scripts.Game.Entity.Contexts;
using JNGame.Sync.System;
using JNGame.Sync.System.Data;
using JNGame.Sync.System.Data.Type;
using NotImplementedException = System.NotImplementedException;
namespace GASSamples.Scripts.Game.Logic.Data
{
public enum JNGASBoxValueCode : int
{
Auth = 201
}
[Serializable]
public class JNGASBoxValue
{
public DValuePosition Position = null;
}
public class JNGASBoxData : ISData
{
public JNGASBoxValue Value;
public override bool IsEquals(ISData data)
{
return true;
}
}
public class JNGASBoxDataSystem : SFrameDataSystem<JNGASBoxData>
{
public JNGASBoxContext NodeContext => Contexts.GetContext<JNGASBoxContext>();
private ConcurrentDictionary<ulong, JNGASBoxData> DataCache = new();
public override ConcurrentDictionary<ulong, JNGASBoxData> GetLatest()
{
DataCache.Clear();
foreach (var entity in NodeContext.GetEntities())
{
DataCache.TryAdd(entity.Id,new JNGASBoxData()
{
Value = new ()
{
Position = DValuePosition.Build(entity.Position)
}
});
}
return DataCache;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 83c5b3168ed74b8e981a1fc232d7330d
timeCreated: 1729276758

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed36be30121349c08ceeaab6cef326f7
timeCreated: 1729275942

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1887a92680244fa5a4b2035d03a3bc77
timeCreated: 1729276479

View File

@@ -0,0 +1,14 @@
using GASSamples.Scripts.Game.Entity.Nodes;
using JNGame.Sync.Frame.Entity;
namespace GASSamples.Scripts.Game.Entity.Contexts
{
public class JNGASBoxContext : JNContext<JNGASBox>
{
protected override JNGASBox BindComponent(JNGASBox entity)
{
base.BindComponent(entity);
return entity;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: be628b374d154c98b85694955b4cda4b
timeCreated: 1729276498

View File

@@ -0,0 +1,13 @@
using Entitas;
using GASSamples.Scripts.Game.Entity.Contexts;
using JNGame.Sync.Entity;
namespace GASSamples.Scripts.Game.Entity
{
public class EDContexts : JNContexts
{
public override IContext[] allContexts { get; } = { new JNGASBoxContext() };
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 781261aba7f946b297d7c655cf953acd
timeCreated: 1729275955

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c9ed407f62c44feaa88de076fbc503f3
timeCreated: 1729276082

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 52e508ba3ff44352bb0f463042536728
timeCreated: 1729276165

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d7e90ad7c34d49eb90791ea5a1a9ffe8
timeCreated: 1729276182

View File

@@ -0,0 +1,9 @@
using JNGame.Sync.Entity.Component;
namespace GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup
{
public class JNGASBoxLookup : JNEntityLookup
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ee66d5996b334ea1850e8bf9e150e15b
timeCreated: 1729276195

View File

@@ -0,0 +1,14 @@
using GASSamples.Scripts.Game.Entity.Nodes.Component.Lookup;
using JNGame.Sync.Entity;
using JNGame.Sync.Entity.Component;
namespace GASSamples.Scripts.Game.Entity.Nodes
{
public class JNGASBox : JNEntity
{
public override JNEntityLookup NewCLookup()
{
return new JNGASBoxLookup();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 69b1a0b196ea4395990aeabd34fe28fc
timeCreated: 1729276118

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1393a03eb1b743a2a5347cbf505f3692
timeCreated: 1729273918

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using JNGame.Runtime.Util.Types;
using JNGame.Sync.System.View;
namespace Game.Input
{
public class DInputSystem : JNInputSystem
{
private KeyValue<Type, int> _tClass = new KeyValue<Type, int>();
protected override KeyValue<Type, int> TClass => _tClass;
protected override void OnInit()
{
base.OnInit();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a531fb10faef4b5ca7e947adb946d7df
timeCreated: 1729273925

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 21cf75d98dcc4a89855767a1e60af869
timeCreated: 1729275624

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 41ff96ba3e4748b5a1a2114a635f821a
timeCreated: 1729275629

View File

@@ -0,0 +1,19 @@
using GASSamples.Scripts.Game.Entity.Contexts;
using JNGame.Math;
using JNGame.Sync.System;
namespace GASSamples.Scripts.Game.Logic.System
{
public class DWorldSystem : SLogicSystem
{
public JNGASBoxContext BoxContext => Contexts.GetContext<JNGASBoxContext>();
public override void OnSyncStart()
{
base.OnSyncStart();
BoxContext.CreateEntity();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1a28375952b744eb85bae40b66f7ef81
timeCreated: 1729275863

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d7ad083af7024cf7855026315132abe5
timeCreated: 1729277967

View File

@@ -0,0 +1,31 @@
using GASSamples.Scripts.Game.View.Entity;
using JNGame.Runtime.Util;
using JNGame.Sync.System;
using JNGame.Sync.View;
namespace GASSamples.Scripts.Game.View
{
public class DViewSystem : SViewSystem
{
private readonly IViewData[] views;
public DViewSystem()
{
views = new IViewData[] {
new VDBox(this), //显示Demo实体
};
}
public override void OnSyncUpdate(int dt)
{
base.OnSyncUpdate(dt);
foreach (var view in views)
{
//视图逻辑交给主线程运行
UnityMainThreadDispatcher.Instance.Enqueue(view.Execute);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8f87d86e0a34f3b9719bebe4383fe29
timeCreated: 1729277970

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ca9b410a5ca741b0b90219e999c290c9
timeCreated: 1729278058

View File

@@ -0,0 +1,41 @@
using System.Collections.Concurrent;
using DG.Tweening;
using GASSamples.Scripts.Game.Logic.Data;
using JNGame.Sync.System;
using JNGame.Sync.View;
using UnityEngine;
namespace GASSamples.Scripts.Game.View.Entity
{
public class VDBox : ViewData<JNGASBoxData>
{
public GameObject World => App.Resource.World;
public GameObject Box => App.Resource.Box;
public VDBox(SViewSystem root) : base(root)
{
}
public override void ViewUpdate(JNGASBoxData data, GameObject view)
{
view.transform.DOMove(data.Value.Position.ToVector3(),0.5f);
}
public override GameObject NewView(JNGASBoxData data)
{
var view = Object.Instantiate(Box, World.transform);
view.name = $"Boss_{data.Id}";
return view;
}
public override ConcurrentDictionary<ulong, JNGASBoxData> GetData()
{
return GetService<JNGASBoxDataSystem>().Data;
}
public override void ViewRemove(GameObject view)
{
Object.Destroy(view);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6ad7eb0cc9c84346b06e5c32cda46266
timeCreated: 1729278090

View File

@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using JNGame.Network;
using UnityEngine;
namespace GASSamples.Scripts
{
public class JNGResService : JNServerBase
{
public GameObject World;
//Box
public GameObject Box;
public override Task OnInit()
{
return base.OnInit();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 123c85e1eb584e4682234f65e4fe4ec9
timeCreated: 1729279133

View File

@@ -1,13 +1,55 @@
using UnityEngine;
using System;
using DefaultNamespace;
using JNGame.Runtime;
using UnityEngine;
namespace Demo.Scripts
namespace GASSamples.Scripts
{
public class Main : MonoBehaviour
{
private void Start()
public GameObject World;
public GameObject Box;
private JNGASFrameSystem _frameSystem;
private int _totalTime;
private int _frameIndex;
private async void Awake()
{
await JNetGame.Instance.Init(App.AllSystem());
App.Resource.World = World;
App.Resource.Box = Box;
_frameSystem = new JNGASFrameSystem();
_frameSystem.Initialize();
_frameSystem.TStartExecute();
}
private void Update()
{
if (_frameSystem is null) return;
_totalTime += (int)(Time.deltaTime * 1000);
//自动推帧
if (_totalTime >= _frameSystem.NSyncTime)
{
_frameSystem.AddFrame(new JNFrameInfo()
{
Index = _frameIndex++
});
}
}
private void OnApplicationQuit()
{
_frameSystem?.Dispose();
}
protected void OnDisable()
{
_frameSystem?.Dispose();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: db4b70c6d32f43e596928f4be96e77cb
timeCreated: 1729273692

View File

@@ -0,0 +1,80 @@
using Cysharp.Threading.Tasks;
using Game.Input;
using GASSamples.Scripts.Game.Entity;
using GASSamples.Scripts.Game.Logic.Data;
using GASSamples.Scripts.Game.Logic.System;
using GASSamples.Scripts.Game.View;
using JNGame.Sync.Entity;
using JNGame.Sync.Frame;
using JNGame.Sync.System;
namespace DefaultNamespace
{
public class JNGASFrameSystem : JNSyncFrameService
{
public override bool IsStartGame => true;
public override SLogicSystem[] NewLogicSystems()
{
return new SLogicSystem[]
{
//基础数据
new DInputSystem(), //游戏输入
new DWorldSystem(), //世界逻辑
};
}
public override SDataSystemBase[] NewDataSystems()
{
return new SDataSystemBase[] {
new JNGASBoxDataSystem(),
};
}
public override SViewSystem[] NewViewSystems()
{
return new SViewSystem[]
{
//视图层
new DViewSystem(), //游戏视图
};
}
public override JNContexts CreateContexts()
{
return new EDContexts();
}
//获取输入
protected override JNFrameInputs GetInputs()
{
return new JNFrameInputs();
}
//发送输入
protected override void OnSendInput(JNFrameInputs inputs){}
protected override void OnRunSimulate()
{
if (!(NFrameQueue.TryDequeue(out var frame))) return;
//插入当前输入
foreach (var child in frame.Messages)
{
GetSystem<DInputSystem>().Enqueue(child);
}
Simulate();
}
/// <summary>
/// 追帧数据
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
/// <returns></returns>
protected override async UniTask<JNFrameInfos> OnServerData(int start, int end)
{
await UniTask.Delay(1);
return new JNFrameInfos();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fb60ec3a5bba4f57ac82e4862a01860d
timeCreated: 1729273723