mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 13:23:05 +00:00
add open hatch event
This commit is contained in:
parent
6d612a0004
commit
d20739d2f3
@ -63,5 +63,6 @@
|
||||
public static string QSBExitPlatform = "QSBExitPlatform";
|
||||
public static string QSBCampfireState = "QSBCampfireState";
|
||||
public static string QSBMarshmallowEvent = "QSBMarshmallowEvent";
|
||||
public static string QSBOpenHatch = "QSBOpenHatch";
|
||||
}
|
||||
}
|
@ -43,6 +43,7 @@
|
||||
CampfireState,
|
||||
Roasting,
|
||||
MarshmallowEvent,
|
||||
FlyShip
|
||||
FlyShip,
|
||||
OpenHatch
|
||||
}
|
||||
}
|
@ -78,7 +78,8 @@ namespace QSB.Events
|
||||
new IdentifyFrequencyEvent(),
|
||||
new IdentifySignalEvent(),
|
||||
// Ship
|
||||
new FlyShipEvent()
|
||||
new FlyShipEvent(),
|
||||
new OpenHatchEvent()
|
||||
};
|
||||
|
||||
if (UnitTestDetector.IsInUnitTest)
|
||||
|
@ -11,6 +11,7 @@ using QSB.OrbSync.Patches;
|
||||
using QSB.PoolSync.Patches;
|
||||
using QSB.QuantumSync.Patches;
|
||||
using QSB.RoastingSync.Patches;
|
||||
using QSB.ShipSync.Patches;
|
||||
using QSB.StatueSync.Patches;
|
||||
using QSB.TimeSync.Patches;
|
||||
using QSB.TranslationSync.Patches;
|
||||
@ -49,7 +50,8 @@ namespace QSB.Patches
|
||||
new GeyserPatches(),
|
||||
new PoolPatches(),
|
||||
new CampfirePatches(),
|
||||
new RoastingPatches()
|
||||
new RoastingPatches(),
|
||||
new ShipPatches()
|
||||
};
|
||||
|
||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||
|
@ -225,7 +225,8 @@
|
||||
<Compile Include="RoastingSync\Patches\RoastingPatches.cs" />
|
||||
<Compile Include="SectorSync\FakeSector.cs" />
|
||||
<Compile Include="ShipSync\Events\FlyShipEvent.cs" />
|
||||
<Compile Include="ShipSync\Events\HatchEvent.cs" />
|
||||
<Compile Include="ShipSync\Events\OpenHatchEvent.cs" />
|
||||
<Compile Include="ShipSync\Patches\ShipPatches.cs" />
|
||||
<Compile Include="ShipSync\ShipManager.cs" />
|
||||
<Compile Include="StatueSync\Events\StartStatueEvent.cs" />
|
||||
<Compile Include="StatueSync\Events\StartStatueMessage.cs" />
|
||||
|
@ -39,7 +39,7 @@ namespace QSB.ShipSync.Events
|
||||
{
|
||||
SetCurrentFlyer(message.Value, message.AboutId);
|
||||
var shipCockpitController = GameObject.Find("ShipCockpitController").GetComponent<ShipCockpitController>();
|
||||
var interactVolume = shipCockpitController.GetValue<SingleInteractionVolume>("_interactVolumes");
|
||||
var interactVolume = shipCockpitController.GetValue<SingleInteractionVolume>("_interactVolume");
|
||||
if (message.Value)
|
||||
{
|
||||
interactVolume.DisableInteraction();
|
||||
|
@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QSB.ShipSync.Events
|
||||
{
|
||||
class HatchEvent
|
||||
{
|
||||
}
|
||||
}
|
31
QSB/ShipSync/Events/OpenHatchEvent.cs
Normal file
31
QSB/ShipSync/Events/OpenHatchEvent.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using OWML.Utils;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.ShipSync.Events
|
||||
{
|
||||
class OpenHatchEvent : QSBEvent<PlayerMessage>
|
||||
{
|
||||
public override EventType Type => EventType.OpenHatch;
|
||||
|
||||
public override void SetupListener()
|
||||
=> GlobalMessenger.AddListener(EventNames.QSBOpenHatch, Handler);
|
||||
|
||||
public override void CloseListener()
|
||||
=> GlobalMessenger.RemoveListener(EventNames.QSBOpenHatch, Handler);
|
||||
|
||||
private void Handler() => SendEvent(CreateMessage());
|
||||
|
||||
private PlayerMessage CreateMessage() => new PlayerMessage
|
||||
{
|
||||
AboutId = LocalPlayerId
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool server, PlayerMessage message)
|
||||
{
|
||||
var shipTransform = Locator.GetShipTransform();
|
||||
var hatchController = shipTransform.GetComponentInChildren<HatchController>();
|
||||
hatchController.Invoke("OpenHatch");
|
||||
}
|
||||
}
|
||||
}
|
22
QSB/ShipSync/Patches/ShipPatches.cs
Normal file
22
QSB/ShipSync/Patches/ShipPatches.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
|
||||
namespace QSB.ShipSync.Patches
|
||||
{
|
||||
class ShipPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
=> QSBCore.HarmonyHelper.AddPrefix<HatchController>("OnPressInteract", typeof(ShipPatches), nameof(HatchController_OnPressInteract));
|
||||
|
||||
public override void DoUnpatches()
|
||||
=> QSBCore.HarmonyHelper.Unpatch<HatchController>("OnPressInteract");
|
||||
|
||||
public static bool HatchController_OnPressInteract()
|
||||
{
|
||||
QSBEventManager.FireEvent(EventNames.QSBOpenHatch);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user