wine cellar sync

This commit is contained in:
Mister_Nebula 2022-09-22 13:02:40 +01:00
parent 4e556248a0
commit 88023725b9
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,8 @@
using QSB.Messaging;
namespace QSB.EchoesOfTheEye.WineCellar.Messages;
internal class WineCellarSwitchMessage : QSBWorldObjectMessage<QSBWineCellarSwitch>
{
public override void OnReceiveRemote() => WorldObject.AttachedObject.OnPressInteract();
}

View File

@ -0,0 +1,25 @@
using HarmonyLib;
using QSB.EchoesOfTheEye.WineCellar.Messages;
using QSB.Messaging;
using QSB.Patches;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.WineCellar.Patches;
internal class WineCellarPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(WineCellarSwitch), nameof(WineCellarSwitch.OnPressInteract))]
public static void OnPressInteract(WineCellarSwitch __instance)
{
if (Remote)
{
return;
}
var worldObject = __instance.GetWorldObject<QSBWineCellarSwitch>();
worldObject.SendMessage(new WineCellarSwitchMessage());
}
}

View File

@ -0,0 +1,5 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.WineCellar;
internal class QSBWineCellarSwitch : WorldObject<WineCellarSwitch> { }

View File

@ -0,0 +1,14 @@
using Cysharp.Threading.Tasks;
using QSB.WorldSync;
using System.Threading;
namespace QSB.EchoesOfTheEye.WineCellar;
internal class WineCellarManager : WorldObjectManager
{
public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem;
public override bool DlcOnly => true;
public async override UniTask BuildWorldObjects(OWScene scene, CancellationToken ct)
=> QSBWorldSync.Init<QSBWineCellarSwitch, WineCellarSwitch>();
}