添加transport库
This commit is contained in:
1 parent
e3f449f183
commit
3fe3366e75
18 files changed
+188
-66
No files matched your search
+13
-3
@@ -2,11 +2,21 @@ using Unity.Collections.LowLevel.Unsafe;
|
||||
|
||||
namespace GameCore.LowLevel
|
||||
{
|
||||
public static class StructUtility
|
||||
public static class LowLevelUtility
|
||||
{
|
||||
public static int HashCombine(int h1, int h2)
|
||||
{
|
||||
var hash = h1;
|
||||
hash = (hash * 397) ^ h2;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static int HashCombine(int h1, int h2, int h3)
|
||||
{
|
||||
return HashCombine(HashCombine(h1, h2), h3);
|
||||
}
|
||||
|
||||
public static int OffsetOf<T, F>()
|
||||
where T : struct
|
||||
where F : struct
|
||||
{
|
||||
var fields = typeof(T).GetFields();
|
||||
foreach (var f in fields)
|
||||
File renamed without changes.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 601e75d3d590e6d46a9e4dcc626bc18a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Collections;
|
||||
using Unity.Networking.Transport;
|
||||
using Unity.Networking.Transport.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameCore.Network
|
||||
{
|
||||
public class NewBehaviourScript : ScriptableObject
|
||||
{
|
||||
// private NetworkDriver CreateNetworkDriver()
|
||||
// {
|
||||
// var settings = new NetworkSettings(Allocator.Temp);
|
||||
// settings.WithNetworkConfigParameters(disconnectTimeoutMS: 5000);
|
||||
// settings.WithReliableStageParameters(32);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b79190dcfae6a2f4fbdfc9deccf00ef7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "nimin.network",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"Unity.Networking.Transport"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Android",
|
||||
"Editor",
|
||||
"iOS",
|
||||
"LinuxStandalone64",
|
||||
"Lumin",
|
||||
"macOSStandalone",
|
||||
"PS4",
|
||||
"Stadia",
|
||||
"Switch",
|
||||
"tvOS",
|
||||
"WSA",
|
||||
"WebGL",
|
||||
"WindowsStandalone32",
|
||||
"WindowsStandalone64",
|
||||
"XboxOne"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91141161d71157d48bf0b89f0037a92c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "com.nimin.network",
|
||||
"displayName": "GameCore Network",
|
||||
"version": "0.1.0",
|
||||
"unity": "2021.3",
|
||||
"description": "Network based on Unity Transport",
|
||||
"dependencies": {
|
||||
"com.unity.transport": "1.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"Network",
|
||||
"JobSystem"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d7dbfe60d6acb342bf4cf03c23adb14
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GameCore.LowLevel;
|
||||
|
||||
namespace GameCore.TinyECS
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace GameCore.TinyECS
|
||||
public override string ToString() => $"Entity<{type}>({index},{generation})";
|
||||
public bool Equals(Entity<TEnum> other) => type.Equals(other.type) && index == other.index && generation == other.generation;
|
||||
public override bool Equals(object obj) => obj is Entity<TEnum> other && Equals(other);
|
||||
public override int GetHashCode() => HashCode.Combine(type, index, generation);
|
||||
public override int GetHashCode() => LowLevelUtility.HashCombine(type.GetHashCode(), index, generation);
|
||||
public static bool operator ==(Entity<TEnum> lhs, Entity<TEnum> rhs) => lhs.Equals(rhs);
|
||||
public static bool operator !=(Entity<TEnum> lhs, Entity<TEnum> rhs) => !(lhs == rhs);
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace GameCore.TinyECS
|
||||
var id2 = ComponentId.Get<T2>();
|
||||
meta.componentIdToIndex[id1] = 1;
|
||||
meta.componentIdToIndex[id2] = 2;
|
||||
meta.componentIdToOffset[id1] = (short)StructUtility.OffsetOf<(T1, T2), T1>();
|
||||
meta.componentIdToOffset[id2] = (short)StructUtility.OffsetOf<(T1, T2), T2>();
|
||||
meta.componentIdToOffset[id1] = (short)LowLevelUtility.OffsetOf<(T1, T2), T1>();
|
||||
meta.componentIdToOffset[id2] = (short)LowLevelUtility.OffsetOf<(T1, T2), T2>();
|
||||
meta.elementSize = UnsafeUtility.SizeOf<(T1, T2)>();
|
||||
meta.elementAlign = UnsafeUtility.AlignOf<(T2, T2)>();
|
||||
return meta;
|
||||
|
||||
Reference in new issue
Block a user