mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 03:32:47 +00:00
Custom network manager
This commit is contained in:
parent
bcfa41b26b
commit
65c8943bd8
@ -9,11 +9,7 @@ namespace QSB {
|
|||||||
public static NetworkPlayer localInstance { get; private set; }
|
public static NetworkPlayer localInstance { get; private set; }
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
if (isLocalPlayer) {
|
QSB.Log("Start NetworkPlayer", netId.Value);
|
||||||
QSB.LogToScreen("Started LOCAL network player", netId.Value);
|
|
||||||
} else {
|
|
||||||
QSB.LogToScreen("Started REMOTE network player", netId.Value);
|
|
||||||
}
|
|
||||||
QSB.playerSectors[netId.Value] = Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform;
|
QSB.playerSectors[netId.Value] = Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform;
|
||||||
|
|
||||||
transform.parent = Locator.GetRootTransform();
|
transform.parent = Locator.GetRootTransform();
|
||||||
@ -35,7 +31,6 @@ namespace QSB {
|
|||||||
} else {
|
} else {
|
||||||
NetworkManager.singleton.client.RegisterHandler(SectorMessage.Type, QSB.OnReceiveMessage);
|
NetworkManager.singleton.client.RegisterHandler(SectorMessage.Type, QSB.OnReceiveMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnterSector (Sector sector) {
|
public void EnterSector (Sector sector) {
|
||||||
|
13
QSB/QSB.cs
13
QSB/QSB.cs
@ -26,10 +26,14 @@ namespace QSB {
|
|||||||
playerSectors = new Dictionary<uint, Transform>();
|
playerSectors = new Dictionary<uint, Transform>();
|
||||||
|
|
||||||
var assetBundle = ModHelper.Assets.LoadBundle("assets/network");
|
var assetBundle = ModHelper.Assets.LoadBundle("assets/network");
|
||||||
var networkManager = Instantiate(assetBundle.LoadAsset<GameObject>("assets/networkmanager.prefab"));
|
//var networkManager = Instantiate(assetBundle.LoadAsset<GameObject>("assets/networkmanager.prefab"));
|
||||||
var networkPlayerPrefab = assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
|
var networkPlayerPrefab = assetBundle.LoadAsset<GameObject>("assets/networkplayer.prefab");
|
||||||
networkPlayerPrefab.AddComponent<NetworkPlayer>();
|
networkPlayerPrefab.AddComponent<NetworkPlayer>();
|
||||||
networkManager.GetComponent<NetworkManager>().playerPrefab = networkPlayerPrefab;
|
|
||||||
|
var networkManager = gameObject.AddComponent<QSBNetworkManager>();
|
||||||
|
networkManager.playerPrefab = networkPlayerPrefab;
|
||||||
|
|
||||||
|
gameObject.AddComponent<NetworkManagerHUD>();
|
||||||
|
|
||||||
ModHelper.HarmonyHelper.AddPrefix<PlayerSectorDetector>("OnAddSector", typeof(Patches), "OnAddSector");
|
ModHelper.HarmonyHelper.AddPrefix<PlayerSectorDetector>("OnAddSector", typeof(Patches), "OnAddSector");
|
||||||
}
|
}
|
||||||
@ -47,6 +51,11 @@ namespace QSB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void LogToScreen (params object[] logObjects) {
|
public static void LogToScreen (params object[] logObjects) {
|
||||||
|
if (Locator.GetPlayerBody() == null) {
|
||||||
|
Log("Warning: tried to log to HUD but player is not ready.");
|
||||||
|
Log(logObjects);
|
||||||
|
return;
|
||||||
|
}
|
||||||
NotificationData data = new NotificationData(NotificationTarget.Player, JoinAll(logObjects), 5f, true);
|
NotificationData data = new NotificationData(NotificationTarget.Player, JoinAll(logObjects), 5f, true);
|
||||||
NotificationManager.SharedInstance.PostNotification(data, false);
|
NotificationManager.SharedInstance.PostNotification(data, false);
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,12 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="QSBNetworkManager.cs" />
|
||||||
<Compile Include="SectorMessage.cs" />
|
<Compile Include="SectorMessage.cs" />
|
||||||
<Compile Include="QSB.cs" />
|
<Compile Include="QSB.cs" />
|
||||||
<Compile Include="NetworkPlayer.cs" />
|
<Compile Include="NetworkPlayer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SectorSync.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="default-config.json" />
|
<None Include="default-config.json" />
|
||||||
@ -100,6 +102,6 @@ copy /y "$(ProjectDir)\default-config.json" "$(StartWorkingDirectory)"
|
|||||||
|
|
||||||
copy /y "$(ProjectDir)\manifest.json" "$(StartWorkingDirectory)"
|
copy /y "$(ProjectDir)\manifest.json" "$(StartWorkingDirectory)"
|
||||||
|
|
||||||
copy /y "$(ProjectDir)\Assets" "$(StartWorkingDirectory)"</PostBuildEvent>
|
copy /y "$(ProjectDir)\Assets" "$(StartWorkingDirectory)\assets"</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
18
QSB/QSBNetworkManager.cs
Normal file
18
QSB/QSBNetworkManager.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
|
namespace QSB {
|
||||||
|
class QSBNetworkManager: NetworkManager {
|
||||||
|
void Awake () {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnClientConnect (NetworkConnection conn) {
|
||||||
|
base.OnClientConnect(conn);
|
||||||
|
|
||||||
|
QSB.Log("OnClientConnect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
QSB/SectorSync.cs
Normal file
9
QSB/SectorSync.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace QSB {
|
||||||
|
class SectorSync {
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"filename": "QuantumSpaceBuddies.dll",
|
"filename": "QSB.dll",
|
||||||
"author": "Raicuparta",
|
"author": "Raicuparta",
|
||||||
"name": "QuantumSpaceBuddies",
|
"name": "QuantumSpaceBuddies",
|
||||||
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
|
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user