mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
add campfire sync
This commit is contained in:
parent
14d7c9422e
commit
fe968e9510
30
QSB/CampfireSync/Events/CampfireStateEvent.cs
Normal file
30
QSB/CampfireSync/Events/CampfireStateEvent.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using QSB.CampfireSync.WorldObjects;
|
||||||
|
using QSB.Events;
|
||||||
|
using QSB.WorldSync;
|
||||||
|
using QSB.WorldSync.Events;
|
||||||
|
|
||||||
|
namespace QSB.CampfireSync.Events
|
||||||
|
{
|
||||||
|
class CampfireStateEvent : QSBEvent<EnumWorldObjectMessage<Campfire.State>>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.CampfireState;
|
||||||
|
|
||||||
|
public override void SetupListener() => GlobalMessenger<int, Campfire.State>.AddListener(EventNames.QSBCampfireState, Handler);
|
||||||
|
public override void CloseListener() => GlobalMessenger<int, Campfire.State>.RemoveListener(EventNames.QSBCampfireState, Handler);
|
||||||
|
|
||||||
|
private void Handler(int objId, Campfire.State state) => SendEvent(CreateMessage(objId, state));
|
||||||
|
|
||||||
|
private EnumWorldObjectMessage<Campfire.State> CreateMessage(int objId, Campfire.State state) => new EnumWorldObjectMessage<Campfire.State>
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
ObjectId = objId,
|
||||||
|
EnumValue = state
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool server, EnumWorldObjectMessage<Campfire.State> message)
|
||||||
|
{
|
||||||
|
var campfireObj = QSBWorldSync.GetWorldFromId<QSBCampfire>(message.ObjectId);
|
||||||
|
campfireObj.SetState(message.EnumValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace QSB.CampfireSync.Events
|
|
||||||
{
|
|
||||||
class CampfireStateMessage
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
32
QSB/CampfireSync/Patches/CampfirePatches.cs
Normal file
32
QSB/CampfireSync/Patches/CampfirePatches.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using QSB.CampfireSync.WorldObjects;
|
||||||
|
using QSB.Events;
|
||||||
|
using QSB.Patches;
|
||||||
|
using QSB.WorldSync;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace QSB.CampfireSync.Patches
|
||||||
|
{
|
||||||
|
class CampfirePatches : QSBPatch
|
||||||
|
{
|
||||||
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||||
|
|
||||||
|
public override void DoPatches() => QSBCore.HarmonyHelper.AddPrefix<Campfire>("OnPressInteract", typeof(CampfirePatches), nameof(Campfire_OnPressInteract));
|
||||||
|
public override void DoUnpatches() => QSBCore.HarmonyHelper.Unpatch<Campfire>("OnPressInteract");
|
||||||
|
|
||||||
|
public static bool Campfire_OnPressInteract(Campfire __instance, Campfire.State ____state)
|
||||||
|
{
|
||||||
|
var qsbCampfire = QSBWorldSync.GetWorldFromUnity<QSBCampfire, Campfire>(__instance);
|
||||||
|
if (____state == Campfire.State.LIT)
|
||||||
|
{
|
||||||
|
qsbCampfire.StartRoasting();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsbCampfire.SetState(Campfire.State.LIT);
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBCampfireState, qsbCampfire.ObjectId, Campfire.State.LIT);
|
||||||
|
Locator.GetFlashlight().TurnOff(false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace QSB.CampfireSync.WorldObjects
|
namespace QSB.CampfireSync.WorldObjects
|
||||||
{
|
{
|
||||||
@ -10,6 +11,12 @@ namespace QSB.CampfireSync.WorldObjects
|
|||||||
AttachedObject = campfire;
|
AttachedObject = campfire;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartRoasting()
|
||||||
|
=> AttachedObject
|
||||||
|
.GetType()
|
||||||
|
.GetMethod("StartRoasting", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||||
|
.Invoke(AttachedObject, null);
|
||||||
|
|
||||||
public void SetState(Campfire.State newState)
|
public void SetState(Campfire.State newState)
|
||||||
=> AttachedObject.SetState(newState);
|
=> AttachedObject.SetState(newState);
|
||||||
}
|
}
|
||||||
|
@ -57,5 +57,6 @@
|
|||||||
public static string QSBPlayerKick = "QSBPlayerKick";
|
public static string QSBPlayerKick = "QSBPlayerKick";
|
||||||
public static string QSBEnterPlatform = "QSBEnterPlatform";
|
public static string QSBEnterPlatform = "QSBEnterPlatform";
|
||||||
public static string QSBExitPlatform = "QSBExitPlatform";
|
public static string QSBExitPlatform = "QSBExitPlatform";
|
||||||
|
public static string QSBCampfireState = "QSBCampfireState";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,6 +39,13 @@
|
|||||||
SocketItem,
|
SocketItem,
|
||||||
MoveToCarry,
|
MoveToCarry,
|
||||||
StartStatue,
|
StartStatue,
|
||||||
PlayerKick
|
PlayerKick,
|
||||||
|
CampfireState,
|
||||||
|
Roasting,
|
||||||
|
MarshmallowToss,
|
||||||
|
MarshmallowBurn,
|
||||||
|
MarshmallowRemove,
|
||||||
|
MarshmallowShrivel,
|
||||||
|
MarshmallowSpawn
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using QSB.Animation.Events;
|
using QSB.Animation.Events;
|
||||||
|
using QSB.CampfireSync.Events;
|
||||||
using QSB.ConversationSync.Events;
|
using QSB.ConversationSync.Events;
|
||||||
using QSB.DeathSync.Events;
|
using QSB.DeathSync.Events;
|
||||||
using QSB.ElevatorSync.Events;
|
using QSB.ElevatorSync.Events;
|
||||||
@ -63,6 +64,7 @@ namespace QSB.Events
|
|||||||
new SocketItemEvent(),
|
new SocketItemEvent(),
|
||||||
new MoveToCarryEvent(),
|
new MoveToCarryEvent(),
|
||||||
new StartStatueEvent(),
|
new StartStatueEvent(),
|
||||||
|
new CampfireStateEvent(),
|
||||||
// Conversation/dialogue/exploration
|
// Conversation/dialogue/exploration
|
||||||
new ConversationEvent(),
|
new ConversationEvent(),
|
||||||
new ConversationStartEndEvent(),
|
new ConversationStartEndEvent(),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
|
using QSB.CampfireSync.Patches;
|
||||||
using QSB.ConversationSync.Patches;
|
using QSB.ConversationSync.Patches;
|
||||||
using QSB.DeathSync.Patches;
|
using QSB.DeathSync.Patches;
|
||||||
using QSB.ElevatorSync.Patches;
|
using QSB.ElevatorSync.Patches;
|
||||||
@ -45,7 +46,8 @@ namespace QSB.Patches
|
|||||||
new ItemPatches(),
|
new ItemPatches(),
|
||||||
new StatuePatches(),
|
new StatuePatches(),
|
||||||
new GeyserPatches(),
|
new GeyserPatches(),
|
||||||
new PoolPatches()
|
new PoolPatches(),
|
||||||
|
new CampfirePatches()
|
||||||
};
|
};
|
||||||
|
|
||||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||||
|
@ -108,7 +108,8 @@
|
|||||||
<Compile Include="Animation\CrouchSync.cs" />
|
<Compile Include="Animation\CrouchSync.cs" />
|
||||||
<Compile Include="Animation\PlayerHeadRotationSync.cs" />
|
<Compile Include="Animation\PlayerHeadRotationSync.cs" />
|
||||||
<Compile Include="CampfireSync\CampfireManager.cs" />
|
<Compile Include="CampfireSync\CampfireManager.cs" />
|
||||||
<Compile Include="CampfireSync\Events\CampfireStateMessage.cs" />
|
<Compile Include="CampfireSync\Events\CampfireStateEvent.cs" />
|
||||||
|
<Compile Include="CampfireSync\Patches\CampfirePatches.cs" />
|
||||||
<Compile Include="CampfireSync\WorldObjects\QSBCampfire.cs" />
|
<Compile Include="CampfireSync\WorldObjects\QSBCampfire.cs" />
|
||||||
<Compile Include="ConversationSync\Events\DialogueConditionEvent.cs" />
|
<Compile Include="ConversationSync\Events\DialogueConditionEvent.cs" />
|
||||||
<Compile Include="ConversationSync\Events\DialogueConditionMessage.cs" />
|
<Compile Include="ConversationSync\Events\DialogueConditionMessage.cs" />
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
"name": "Quantum Space Buddies",
|
"name": "Quantum Space Buddies",
|
||||||
"description": "Adds online multiplayer to the game.",
|
"description": "Adds online multiplayer to the game.",
|
||||||
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
|
"uniqueName": "Raicuparta.QuantumSpaceBuddies",
|
||||||
"version": "0.9.1",
|
"version": "0.10.0",
|
||||||
"owmlVersion": "1.1.8"
|
"owmlVersion": "1.1.8"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user