mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-15 22:50:56 +00:00
marshmallow
This commit is contained in:
parent
e00aa13461
commit
c4228f1440
@ -34,12 +34,13 @@ namespace QSB.Animation.Player.Messages
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
if (!QSBPlayerManager.GetPlayer(PlayerId).IsReady)
|
||||
var player = QSBPlayerManager.GetPlayer(PlayerId);
|
||||
if (!player.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QSBPlayerManager.GetPlayer(PlayerId).AnimationSync.SetAnimationType(Value);
|
||||
player.AnimationSync.SetAnimationType(Value);
|
||||
QSBPlayerManager.GetSyncObject<InstrumentsManager>(PlayerId).CheckInstrumentProps(Value);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using QSB.Player;
|
||||
using QSB.WorldSync;
|
||||
using QuantumUNET.Transport;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.ConversationSync.Messages
|
||||
{
|
||||
@ -57,11 +58,11 @@ namespace QSB.ConversationSync.Messages
|
||||
}
|
||||
|
||||
var tree = QSBWorldSync.OldDialogueTrees[Id];
|
||||
UnityEngine.Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
|
||||
Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
|
||||
break;
|
||||
|
||||
case ConversationType.ClosePlayer:
|
||||
UnityEngine.Object.Destroy(QSBPlayerManager.GetPlayer((uint)Id).CurrentDialogueBox);
|
||||
Object.Destroy(QSBPlayerManager.GetPlayer((uint)Id).CurrentDialogueBox);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.ClientServerStateSync;
|
||||
using OWML.Common;
|
||||
using QSB.ClientServerStateSync;
|
||||
using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
|
||||
@ -21,7 +22,7 @@ namespace QSB.DeathSync.Messages
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Got StartLoop event when not in universe!", OWML.Common.MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - Got StartLoop event when not in universe!", MessageType.Error);
|
||||
ClientStateManager.Instance.SendChangeClientStateMessage(ClientState.NotLoaded);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
// Custom event names -- change if you want! These can be anything, as long as both
|
||||
// sides of the GlobalMessenger (fireevent and addlistener) reference the same thing.
|
||||
public const string QSBMarshmallowEvent = nameof(QSBMarshmallowEvent);
|
||||
public const string QSBAnimTrigger = nameof(QSBAnimTrigger);
|
||||
public const string QSBNpcAnimEvent = nameof(QSBNpcAnimEvent);
|
||||
public const string QSBProbeEvent = nameof(QSBProbeEvent);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using OWML.Utils;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.CampfireSync.Messages;
|
||||
using QSB.CampfireSync.WorldObjects;
|
||||
using QSB.ClientServerStateSync;
|
||||
@ -52,7 +53,7 @@ namespace QSB.Player.Messages
|
||||
{
|
||||
if (_waitingForEvent)
|
||||
{
|
||||
DebugLog.ToConsole($"Did not receive PlayerInformationEvent in time. Setting _waitingForEvent to false.", OWML.Common.MessageType.Info);
|
||||
DebugLog.ToConsole($"Did not receive PlayerInformationEvent in time. Setting _waitingForEvent to false.", MessageType.Info);
|
||||
_waitingForEvent = false;
|
||||
}
|
||||
}, 60);
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace QSB.RoastingSync
|
||||
{
|
||||
public enum MarshmallowEventType
|
||||
public enum MarshmallowMessageType
|
||||
{
|
||||
Toss,
|
||||
Burn,
|
@ -1,4 +1,5 @@
|
||||
using QSB.CampfireSync.WorldObjects;
|
||||
using OWML.Common;
|
||||
using QSB.CampfireSync.WorldObjects;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
@ -56,7 +57,7 @@ namespace QSB.RoastingSync.Messages
|
||||
{
|
||||
if (Value && ObjectId == -1)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Null campfire supplied for start roasting event!", OWML.Common.MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - Null campfire supplied for start roasting event!", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
using OWML.Utils;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.RoastingSync.Messages
|
||||
{
|
||||
internal class MarshmallowEventEvent : QSBEvent<EnumMessage<MarshmallowEventType>>
|
||||
{
|
||||
public override bool RequireWorldObjectsReady => true;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<MarshmallowEventType>.AddListener(EventNames.QSBMarshmallowEvent, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<MarshmallowEventType>.RemoveListener(EventNames.QSBMarshmallowEvent, Handler);
|
||||
|
||||
private void Handler(MarshmallowEventType type) => SendEvent(CreateMessage(type));
|
||||
|
||||
private EnumMessage<MarshmallowEventType> CreateMessage(MarshmallowEventType type) => new()
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
EnumValue = type
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool server, EnumMessage<MarshmallowEventType> message)
|
||||
{
|
||||
var marshmallow = QSBPlayerManager.GetPlayer(message.AboutId).Marshmallow;
|
||||
if (marshmallow == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Marshmallow is null for player {message.AboutId}.", OWML.Common.MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (message.EnumValue)
|
||||
{
|
||||
case MarshmallowEventType.Burn:
|
||||
marshmallow.Burn();
|
||||
break;
|
||||
case MarshmallowEventType.Extinguish:
|
||||
marshmallow.Extinguish();
|
||||
break;
|
||||
case MarshmallowEventType.Remove:
|
||||
marshmallow.RemoveMallow();
|
||||
break;
|
||||
case MarshmallowEventType.Replace:
|
||||
marshmallow.SpawnMallow();
|
||||
break;
|
||||
case MarshmallowEventType.Shrivel:
|
||||
marshmallow.Shrivel();
|
||||
break;
|
||||
case MarshmallowEventType.Toss:
|
||||
TossMarshmallow(message.AboutId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void TossMarshmallow(uint playerId)
|
||||
{
|
||||
var player = QSBPlayerManager.GetPlayer(playerId);
|
||||
var stick = player.RoastingStick;
|
||||
var stickTip = stick.transform.GetChild(0);
|
||||
|
||||
var mallowPrefab = QSBWorldSync.GetUnityObjects<RoastingStickController>().First().GetValue<GameObject>("_mallowBodyPrefab");
|
||||
|
||||
var tossedMallow = Object.Instantiate(mallowPrefab, stickTip.position, stickTip.rotation);
|
||||
var rigidbody = tossedMallow.GetComponent<OWRigidbody>();
|
||||
if (player.Campfire == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Campfire for {playerId} is null.", OWML.Common.MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
rigidbody.SetVelocity(player.Campfire.AttachedObject.GetAttachedOWRigidbody(false).GetPointVelocity(stickTip.position) + (stickTip.forward * 3f));
|
||||
rigidbody.SetAngularVelocity(stickTip.right * 10f);
|
||||
if (player.Marshmallow == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Marshmallow for {playerId} is null.", OWML.Common.MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
tossedMallow.GetComponentInChildren<MeshRenderer>().material.color = player.Marshmallow._burntColor;
|
||||
}
|
||||
}
|
||||
}
|
78
QSB/RoastingSync/Messages/MarshmallowEventMessage.cs
Normal file
78
QSB/RoastingSync/Messages/MarshmallowEventMessage.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.RoastingSync.Messages
|
||||
{
|
||||
internal class MarshmallowEventMessage : QSBEnumMessage<MarshmallowMessageType>
|
||||
{
|
||||
public MarshmallowEventMessage(MarshmallowMessageType type) => Value = type;
|
||||
|
||||
public MarshmallowEventMessage() { }
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var player = QSBPlayerManager.GetPlayer(From);
|
||||
if (player.Marshmallow == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Marshmallow is null for player {player.PlayerId}.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Value)
|
||||
{
|
||||
case MarshmallowMessageType.Burn:
|
||||
player.Marshmallow.Burn();
|
||||
break;
|
||||
case MarshmallowMessageType.Extinguish:
|
||||
player.Marshmallow.Extinguish();
|
||||
break;
|
||||
case MarshmallowMessageType.Remove:
|
||||
player.Marshmallow.RemoveMallow();
|
||||
break;
|
||||
case MarshmallowMessageType.Replace:
|
||||
player.Marshmallow.SpawnMallow();
|
||||
break;
|
||||
case MarshmallowMessageType.Shrivel:
|
||||
player.Marshmallow.Shrivel();
|
||||
break;
|
||||
case MarshmallowMessageType.Toss:
|
||||
TossMarshmallow(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void TossMarshmallow(PlayerInfo player)
|
||||
{
|
||||
var stick = player.RoastingStick;
|
||||
var stickTip = stick.transform.GetChild(0);
|
||||
|
||||
var mallowPrefab = QSBWorldSync.GetUnityObjects<RoastingStickController>().First().GetValue<GameObject>("_mallowBodyPrefab");
|
||||
|
||||
var tossedMallow = Object.Instantiate(mallowPrefab, stickTip.position, stickTip.rotation);
|
||||
var rigidbody = tossedMallow.GetComponent<OWRigidbody>();
|
||||
if (player.Campfire == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Campfire for {player.PlayerId} is null.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
rigidbody.SetVelocity(player.Campfire.AttachedObject.GetAttachedOWRigidbody().GetPointVelocity(stickTip.position) + stickTip.forward * 3f);
|
||||
rigidbody.SetAngularVelocity(stickTip.right * 10f);
|
||||
if (player.Marshmallow == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Marshmallow for {player.PlayerId} is null.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
tossedMallow.GetComponentInChildren<MeshRenderer>().material.color = player.Marshmallow._burntColor;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.RoastingSync.Messages;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.RoastingSync.Patches
|
||||
@ -14,7 +15,7 @@ namespace QSB.RoastingSync.Patches
|
||||
[HarmonyPatch(typeof(Marshmallow), nameof(Marshmallow.SpawnMallow))]
|
||||
public static bool Marshmallow_SpawnMallow()
|
||||
{
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Replace);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Replace).Send();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ namespace QSB.RoastingSync.Patches
|
||||
____initBurnTime = Time.time;
|
||||
____mallowState = Marshmallow.MallowState.Burning;
|
||||
____audioController.PlayMarshmallowCatchFire();
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Burn);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Burn).Send();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -50,7 +51,7 @@ namespace QSB.RoastingSync.Patches
|
||||
{
|
||||
____initShrivelTime = Time.time;
|
||||
____mallowState = Marshmallow.MallowState.Shriveling;
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Shrivel);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Shrivel).Send();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -70,7 +71,7 @@ namespace QSB.RoastingSync.Patches
|
||||
____mallowRenderer.enabled = false;
|
||||
____mallowState = Marshmallow.MallowState.Gone;
|
||||
__instance.enabled = false;
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Remove);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Remove).Send();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,13 +104,13 @@ namespace QSB.RoastingSync.Patches
|
||||
{
|
||||
____marshmallow.Remove();
|
||||
Locator.GetPlayerAudioController().PlayMarshmallowToss();
|
||||
var spawnedMarshmallow = UnityEngine.Object.Instantiate<GameObject>(____mallowBodyPrefab, ____stickTransform.position, ____stickTransform.rotation);
|
||||
var spawnedMarshmallow = Object.Instantiate(____mallowBodyPrefab, ____stickTransform.position, ____stickTransform.rotation);
|
||||
var rigidbody = spawnedMarshmallow.GetComponent<OWRigidbody>();
|
||||
rigidbody.SetVelocity(____campfire.GetAttachedOWRigidbody(false).GetPointVelocity(____stickTransform.position) + (____stickTransform.forward * 3f));
|
||||
rigidbody.SetVelocity(____campfire.GetAttachedOWRigidbody().GetPointVelocity(____stickTransform.position) + ____stickTransform.forward * 3f);
|
||||
rigidbody.SetAngularVelocity(____stickTransform.right * 10f);
|
||||
var burntColor = ____marshmallow.GetBurntColor();
|
||||
spawnedMarshmallow.GetComponentInChildren<MeshRenderer>().material.color = burntColor;
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Toss);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Toss).Send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +126,7 @@ namespace QSB.RoastingSync.Patches
|
||||
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting))
|
||||
{
|
||||
____marshmallow.Extinguish();
|
||||
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Extinguish);
|
||||
new MarshmallowEventMessage(MarshmallowMessageType.Extinguish).Send();
|
||||
}
|
||||
}
|
||||
else if (____marshmallow.GetState() == Marshmallow.MallowState.Gone)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.Menus;
|
||||
using OWML.Common;
|
||||
using QSB.Menus;
|
||||
using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Transport;
|
||||
@ -85,7 +86,7 @@ namespace QSB.SaveSync.Messages
|
||||
{
|
||||
if (QSBSceneManager.CurrentScene != OWScene.TitleScreen)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Tried to handle GameStateEvent when not in TitleScreen!", OWML.Common.MessageType.Error);
|
||||
DebugLog.ToConsole($"Error - Tried to handle GameStateEvent when not in TitleScreen!", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using QSB.Events;
|
||||
using OWML.Common;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
@ -28,7 +29,7 @@ namespace QSB.Tools.ProbeLauncherTool.Messages
|
||||
|
||||
if (_nonPlayerLauncherEquipped)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Trying to equip/unequip player launcher whilst non player launcher is still equipped?", OWML.Common.MessageType.Warning);
|
||||
DebugLog.ToConsole($"Warning - Trying to equip/unequip player launcher whilst non player launcher is still equipped?", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user