mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-11 08:38:45 +00:00
提交
This commit is contained in:
18
JNFrame/Assets/Game/Plugins/App/App.asmdef
Normal file
18
JNFrame/Assets/Game/Plugins/App/App.asmdef
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "App",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:7a47da2842efe384ba63b83f4b1471db",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:9069ac25d95ca17448a247f3bb1c769f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
JNFrame/Assets/Game/Plugins/App/App.asmdef.meta
Normal file
7
JNFrame/Assets/Game/Plugins/App/App.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfa590ecbcd6ced438358a8dea07179c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
JNFrame/Assets/Game/Plugins/App/App.cs
Normal file
24
JNFrame/Assets/Game/Plugins/App/App.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Plugins.JNGame.System;
|
||||
using Plugins.JNGame.Util;
|
||||
|
||||
namespace Game.Plugins.App
|
||||
{
|
||||
public static class App
|
||||
{
|
||||
|
||||
public static readonly JNGSocket Socket = new JNGSocket();
|
||||
public static readonly JNGSyncFrame Sync = new JNGSyncFrame();
|
||||
public static readonly JAPI Api = new(new JAPIConfig(){BaseURL = "http://192.168.0.118:8080"});
|
||||
public static readonly EventDispatcher Event = EventDispatcher.Event;
|
||||
|
||||
public static SystemBase[] System()
|
||||
{
|
||||
return new SystemBase[]
|
||||
{
|
||||
Socket,
|
||||
Sync
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
3
JNFrame/Assets/Game/Plugins/App/App.cs.meta
Normal file
3
JNFrame/Assets/Game/Plugins/App/App.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41bc0098f83045f18891ef5190ac6a17
|
||||
timeCreated: 1705981534
|
||||
8
JNFrame/Assets/Game/Plugins/App/Game.meta
Normal file
8
JNFrame/Assets/Game/Plugins/App/Game.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c7041250350ad645a506ee45d362da3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
JNFrame/Assets/Game/Plugins/App/JNGSocket.cs
Normal file
14
JNFrame/Assets/Game/Plugins/App/JNGSocket.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Plugins.JNGame.Network;
|
||||
|
||||
namespace Game.Plugins.App
|
||||
{
|
||||
public class JNGSocket : JNSocket
|
||||
{
|
||||
protected override async UniTask<string> GetUrl()
|
||||
{
|
||||
await UniTask.NextFrame();
|
||||
return "ws://192.168.0.118:8080/websocket";
|
||||
}
|
||||
}
|
||||
}
|
||||
3
JNFrame/Assets/Game/Plugins/App/JNGSocket.cs.meta
Normal file
3
JNFrame/Assets/Game/Plugins/App/JNGSocket.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6018b3436d0447f18eb907f86db6504e
|
||||
timeCreated: 1705993176
|
||||
30
JNFrame/Assets/Game/Plugins/App/JNGSyncFrame.cs
Normal file
30
JNFrame/Assets/Game/Plugins/App/JNGSyncFrame.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Plugins.JNGame.Sync.Frame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Plugins.App
|
||||
{
|
||||
public class JNGSyncFrame : JNSyncFrame
|
||||
{
|
||||
protected override void OnSendInput(JNFrameInputs inputs)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override async UniTask<JNFrameInfos> OnServerData(int start, int end)
|
||||
{
|
||||
Debug.Log($"OnServerData - {start}");
|
||||
var data = (await App.Api.GetByte($"/sync/frame?start={start}"));
|
||||
if (data is { Length: > 0 })
|
||||
{
|
||||
JNFrameInfos info = JNFrameInfos.Parser.ParseFrom(data);
|
||||
Debug.Log($"OnServerData - {start} 结束");
|
||||
return info;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JNFrameInfos();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
JNFrame/Assets/Game/Plugins/App/JNGSyncFrame.cs.meta
Normal file
3
JNFrame/Assets/Game/Plugins/App/JNGSyncFrame.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3b45cb3cc954a99bface55dd2529ce6
|
||||
timeCreated: 1706241635
|
||||
3
JNFrame/Assets/Game/Plugins/App/Sync.meta
Normal file
3
JNFrame/Assets/Game/Plugins/App/Sync.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f844bda03d4d0c8dae20659066ca67
|
||||
timeCreated: 1706519193
|
||||
16
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrame.cs
Normal file
16
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrame.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Plugins.JNGame.Sync.Frame;
|
||||
using Plugins.JNGame.Sync.Frame.game;
|
||||
|
||||
namespace Game.Plugins.App.Sync
|
||||
{
|
||||
public abstract class JNGSyncFrame<T> : JNSyncFrameComponent<T>
|
||||
{
|
||||
protected override JNSyncFrame GetSync()
|
||||
{
|
||||
return App.Sync;
|
||||
}
|
||||
|
||||
public override void OnSyncLoad(){}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54720b15a706406c974db4ac581e6dbc
|
||||
timeCreated: 1706519239
|
||||
11
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrameDefault.cs
Normal file
11
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrameDefault.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Plugins.App.Sync
|
||||
{
|
||||
public class JNGSyncFrameDefault : JNGSyncFrame<Object>
|
||||
{
|
||||
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67efd019640f42afb3840659516d244a
|
||||
timeCreated: 1706773209
|
||||
52
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrameEntrust.cs
Normal file
52
JNFrame/Assets/Game/Plugins/App/Sync/JNGSyncFrameEntrust.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Plugins.JNGame.Sync.Frame.game;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Plugins.App.Sync
|
||||
{
|
||||
public class JNGSyncFrameEntrust : JNGSyncFrameDefault
|
||||
{
|
||||
|
||||
private IEnumerable<Component> _components;
|
||||
public IEnumerable<Component> Components => _components;
|
||||
|
||||
public Component[] allow;
|
||||
|
||||
public override void OnSyncLoad()
|
||||
{
|
||||
|
||||
//获取非同步的组件
|
||||
_components = this.GetComponents<Component>()
|
||||
.Where(item => !(item is IJNSyncFrameComponent))
|
||||
.Where(item => !(item is Transform))
|
||||
.Where(item => !(allow.Contains(item)));
|
||||
|
||||
Debug.Log($"{this.NID} 有{Components.Count()}组件不是同步组件 尝试接管同步 请保证被接管的组件有enabled 同时被接管的组件 enabled 禁止修改");
|
||||
|
||||
foreach (var component in Components)
|
||||
{
|
||||
var property = component.GetType().GetProperty("enabled");
|
||||
if (property == null)
|
||||
{
|
||||
Debug.Log($"{this.NID} 有组件不是同步组件 并且没有 enabled 为了防止不同步 直接删除!");
|
||||
Destroy(component);
|
||||
continue;
|
||||
}
|
||||
property.SetValue(component,false);
|
||||
}
|
||||
|
||||
_components = this.GetComponents<Component>()
|
||||
.Where(item => !(item.GetType().IsAssignableFrom(typeof(IJNSyncFrameComponent))));
|
||||
|
||||
}
|
||||
|
||||
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
|
||||
{
|
||||
base.OnSyncUpdate(dt, frame, input);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32f8b8b7207b1a24ea68368f6a1a91b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user