mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-04-01 10:20:53 +00:00
do the stuff
This commit is contained in:
parent
f7aa68d0b2
commit
b4232bd09b
@ -23,6 +23,11 @@ namespace QSB.CampfireSync.Events
|
|||||||
|
|
||||||
public override void OnReceiveRemote(bool server, EnumWorldObjectMessage<Campfire.State> message)
|
public override void OnReceiveRemote(bool server, EnumWorldObjectMessage<Campfire.State> message)
|
||||||
{
|
{
|
||||||
|
if (!QSBSceneManager.IsInUniverse)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var campfireObj = QSBWorldSync.GetWorldFromId<QSBCampfire>(message.ObjectId);
|
var campfireObj = QSBWorldSync.GetWorldFromId<QSBCampfire>(message.ObjectId);
|
||||||
campfireObj.SetState(message.EnumValue);
|
campfireObj.SetState(message.EnumValue);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
public static string DialogueCondition = "DialogueConditionChanged";
|
public static string DialogueCondition = "DialogueConditionChanged";
|
||||||
public static string EnterQuantumMoon = "PlayerEnterQuantumMoon";
|
public static string EnterQuantumMoon = "PlayerEnterQuantumMoon";
|
||||||
public static string ExitQuantumMoon = "PlayerExitQuantumMoon";
|
public static string ExitQuantumMoon = "PlayerExitQuantumMoon";
|
||||||
|
public static string EnterRoastingMode = "EnterRoastingMode";
|
||||||
|
public static string ExitRoastingMode = "ExitRoastingMode";
|
||||||
|
|
||||||
// Custom event names -- change if you want! These can be anything, as long as both
|
// 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.
|
// sides of the GlobalMessenger (fireevent and addlistener) reference the same thing.
|
||||||
@ -58,5 +60,6 @@
|
|||||||
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";
|
public static string QSBCampfireState = "QSBCampfireState";
|
||||||
|
public static string QSBMarshmallowEvent = "QSBMarshmallowEvent";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -42,10 +42,6 @@
|
|||||||
PlayerKick,
|
PlayerKick,
|
||||||
CampfireState,
|
CampfireState,
|
||||||
Roasting,
|
Roasting,
|
||||||
MarshmallowToss,
|
MarshmallowEvent
|
||||||
MarshmallowBurn,
|
|
||||||
MarshmallowRemove,
|
|
||||||
MarshmallowShrivel,
|
|
||||||
MarshmallowSpawn
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ using QSB.LogSync.Events;
|
|||||||
using QSB.OrbSync.Events;
|
using QSB.OrbSync.Events;
|
||||||
using QSB.Player.Events;
|
using QSB.Player.Events;
|
||||||
using QSB.QuantumSync.Events;
|
using QSB.QuantumSync.Events;
|
||||||
|
using QSB.RoastingSync.Events;
|
||||||
using QSB.StatueSync.Events;
|
using QSB.StatueSync.Events;
|
||||||
using QSB.TimeSync.Events;
|
using QSB.TimeSync.Events;
|
||||||
using QSB.Tools.Events;
|
using QSB.Tools.Events;
|
||||||
@ -48,6 +49,8 @@ namespace QSB.Events
|
|||||||
new ServerTimeEvent(),
|
new ServerTimeEvent(),
|
||||||
new PlayerEntangledEvent(),
|
new PlayerEntangledEvent(),
|
||||||
new PlayerKickEvent(),
|
new PlayerKickEvent(),
|
||||||
|
new EnterExitRoastingEvent(),
|
||||||
|
new MarshmallowEventEvent(),
|
||||||
// World Objects
|
// World Objects
|
||||||
new ElevatorEvent(),
|
new ElevatorEvent(),
|
||||||
new GeyserEvent(),
|
new GeyserEvent(),
|
||||||
|
21
QSB/Messaging/BoolMessage.cs
Normal file
21
QSB/Messaging/BoolMessage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using QuantumUNET.Transport;
|
||||||
|
|
||||||
|
namespace QSB.Messaging
|
||||||
|
{
|
||||||
|
public class BoolMessage : PlayerMessage
|
||||||
|
{
|
||||||
|
public bool Value;
|
||||||
|
|
||||||
|
public override void Deserialize(QNetworkReader reader)
|
||||||
|
{
|
||||||
|
base.Deserialize(reader);
|
||||||
|
Value = reader.ReadBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Serialize(QNetworkWriter writer)
|
||||||
|
{
|
||||||
|
base.Serialize(writer);
|
||||||
|
writer.Write(Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ using QSB.LogSync.Patches;
|
|||||||
using QSB.OrbSync.Patches;
|
using QSB.OrbSync.Patches;
|
||||||
using QSB.PoolSync.Patches;
|
using QSB.PoolSync.Patches;
|
||||||
using QSB.QuantumSync.Patches;
|
using QSB.QuantumSync.Patches;
|
||||||
|
using QSB.RoastingSync.Patches;
|
||||||
using QSB.StatueSync.Patches;
|
using QSB.StatueSync.Patches;
|
||||||
using QSB.TimeSync.Patches;
|
using QSB.TimeSync.Patches;
|
||||||
using QSB.TranslationSync.Patches;
|
using QSB.TranslationSync.Patches;
|
||||||
@ -47,7 +48,8 @@ namespace QSB.Patches
|
|||||||
new StatuePatches(),
|
new StatuePatches(),
|
||||||
new GeyserPatches(),
|
new GeyserPatches(),
|
||||||
new PoolPatches(),
|
new PoolPatches(),
|
||||||
new CampfirePatches()
|
new CampfirePatches(),
|
||||||
|
new RoastingPatches()
|
||||||
};
|
};
|
||||||
|
|
||||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using QSB.Animation;
|
using QSB.Animation;
|
||||||
using QSB.QuantumSync;
|
using QSB.QuantumSync;
|
||||||
|
using QSB.RoastingSync;
|
||||||
using QSB.Tools;
|
using QSB.Tools;
|
||||||
using QSB.Utility;
|
using QSB.Utility;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -19,6 +20,7 @@ namespace QSB.Player
|
|||||||
public OWCamera Camera { get; set; }
|
public OWCamera Camera { get; set; }
|
||||||
public GameObject CameraBody { get; set; }
|
public GameObject CameraBody { get; set; }
|
||||||
public GameObject Body { get; set; }
|
public GameObject Body { get; set; }
|
||||||
|
public GameObject RoastingStick { get; set; }
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
public GameObject ProbeBody { get; set; }
|
public GameObject ProbeBody { get; set; }
|
||||||
@ -32,6 +34,7 @@ namespace QSB.Player
|
|||||||
public Transform SharedStoneSocket => CameraBody.transform.Find("SharedStoneSocket");
|
public Transform SharedStoneSocket => CameraBody.transform.Find("SharedStoneSocket");
|
||||||
public Transform WarpCoreSocket => CameraBody.transform.Find("WarpCoreSocket");
|
public Transform WarpCoreSocket => CameraBody.transform.Find("WarpCoreSocket");
|
||||||
public Transform VesselCoreSocket => CameraBody.transform.Find("VesselCoreSocket");
|
public Transform VesselCoreSocket => CameraBody.transform.Find("VesselCoreSocket");
|
||||||
|
public QSBMarshmallow Marshmallow { get; set; }
|
||||||
|
|
||||||
// Conversation
|
// Conversation
|
||||||
public int CurrentDialogueID { get; set; }
|
public int CurrentDialogueID { get; set; }
|
||||||
|
@ -73,6 +73,9 @@
|
|||||||
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath>
|
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ParticleSystemModule">
|
||||||
|
<HintPath>D:\EpicGames\OuterWilds\OuterWilds_Data\Managed\UnityEngine.ParticleSystemModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
<HintPath>$(GameDir)\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
@ -138,6 +141,7 @@
|
|||||||
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
|
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
|
||||||
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
|
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
|
||||||
<Compile Include="Instruments\InstrumentsManager.cs" />
|
<Compile Include="Instruments\InstrumentsManager.cs" />
|
||||||
|
<Compile Include="Messaging\BoolMessage.cs" />
|
||||||
<Compile Include="PoolSync\CustomNomaiRemoteCameraPlatform.cs" />
|
<Compile Include="PoolSync\CustomNomaiRemoteCameraPlatform.cs" />
|
||||||
<Compile Include="PoolSync\CustomNomaiRemoteCameraStreaming.cs" />
|
<Compile Include="PoolSync\CustomNomaiRemoteCameraStreaming.cs" />
|
||||||
<Compile Include="ItemSync\Events\DropItemEvent.cs" />
|
<Compile Include="ItemSync\Events\DropItemEvent.cs" />
|
||||||
@ -213,11 +217,17 @@
|
|||||||
<Compile Include="QuantumSync\QuantumManager.cs" />
|
<Compile Include="QuantumSync\QuantumManager.cs" />
|
||||||
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
||||||
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
||||||
|
<Compile Include="RoastingSync\QSBMarshmallow.cs" />
|
||||||
|
<Compile Include="RoastingSync\Events\EnterExitRoastingEvent.cs" />
|
||||||
|
<Compile Include="RoastingSync\Events\MarshmallowEventEvent.cs" />
|
||||||
|
<Compile Include="RoastingSync\MarshmallowEventType.cs" />
|
||||||
|
<Compile Include="RoastingSync\Patches\RoastingPatches.cs" />
|
||||||
<Compile Include="SectorSync\FakeSector.cs" />
|
<Compile Include="SectorSync\FakeSector.cs" />
|
||||||
<Compile Include="StatueSync\Events\StartStatueEvent.cs" />
|
<Compile Include="StatueSync\Events\StartStatueEvent.cs" />
|
||||||
<Compile Include="StatueSync\Events\StartStatueMessage.cs" />
|
<Compile Include="StatueSync\Events\StartStatueMessage.cs" />
|
||||||
<Compile Include="StatueSync\Patches\StatuePatches.cs" />
|
<Compile Include="StatueSync\Patches\StatuePatches.cs" />
|
||||||
<Compile Include="StatueSync\StatueManager.cs" />
|
<Compile Include="StatueSync\StatueManager.cs" />
|
||||||
|
<Compile Include="TransformSync\RoastingStickTransformSync.cs" />
|
||||||
<Compile Include="TranslationSync\Events\SetAsTranslatedEvent.cs" />
|
<Compile Include="TranslationSync\Events\SetAsTranslatedEvent.cs" />
|
||||||
<Compile Include="TranslationSync\Events\SetAsTranslatedMessage.cs" />
|
<Compile Include="TranslationSync\Events\SetAsTranslatedMessage.cs" />
|
||||||
<Compile Include="TranslationSync\NomaiTextType.cs" />
|
<Compile Include="TranslationSync\NomaiTextType.cs" />
|
||||||
|
36
QSB/RoastingSync/Events/EnterExitRoastingEvent.cs
Normal file
36
QSB/RoastingSync/Events/EnterExitRoastingEvent.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Messaging;
|
||||||
|
using QSB.Utility;
|
||||||
|
|
||||||
|
namespace QSB.RoastingSync.Events
|
||||||
|
{
|
||||||
|
class EnterExitRoastingEvent : QSBEvent<BoolMessage>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.Roasting;
|
||||||
|
|
||||||
|
public override void SetupListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger<Campfire>.AddListener(EventNames.EnterRoastingMode, (Campfire fire) => Handler(true));
|
||||||
|
GlobalMessenger.AddListener(EventNames.ExitRoastingMode, () => Handler(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CloseListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger<Campfire>.RemoveListener(EventNames.EnterRoastingMode, (Campfire fire) => Handler(true));
|
||||||
|
GlobalMessenger.RemoveListener(EventNames.ExitRoastingMode, () => Handler(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Handler(bool roasting) => SendEvent(CreateMessage(roasting));
|
||||||
|
|
||||||
|
private BoolMessage CreateMessage(bool roasting) => new BoolMessage
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
Value = roasting
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool server, BoolMessage message)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"Get roasting value {message.Value} for {message.AboutId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
QSB/RoastingSync/Events/MarshmallowEventEvent.cs
Normal file
27
QSB/RoastingSync/Events/MarshmallowEventEvent.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Messaging;
|
||||||
|
using QSB.Utility;
|
||||||
|
|
||||||
|
namespace QSB.RoastingSync.Events
|
||||||
|
{
|
||||||
|
class MarshmallowEventEvent : QSBEvent<EnumMessage<MarshmallowEventType>>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.MarshmallowEvent;
|
||||||
|
|
||||||
|
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 EnumMessage<MarshmallowEventType>
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
EnumValue = type
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool server, EnumMessage<MarshmallowEventType> message)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"Get marshmallow event {message.EnumValue} from {message.AboutId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
QSB/RoastingSync/MarshmallowEventType.cs
Normal file
12
QSB/RoastingSync/MarshmallowEventType.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace QSB.RoastingSync
|
||||||
|
{
|
||||||
|
public enum MarshmallowEventType
|
||||||
|
{
|
||||||
|
Toss,
|
||||||
|
Burn,
|
||||||
|
Extinguish,
|
||||||
|
Replace,
|
||||||
|
Remove,
|
||||||
|
Shrivel
|
||||||
|
}
|
||||||
|
}
|
159
QSB/RoastingSync/Patches/RoastingPatches.cs
Normal file
159
QSB/RoastingSync/Patches/RoastingPatches.cs
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Patches;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace QSB.RoastingSync.Patches
|
||||||
|
{
|
||||||
|
class RoastingPatches : QSBPatch
|
||||||
|
{
|
||||||
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||||
|
|
||||||
|
public override void DoPatches()
|
||||||
|
{
|
||||||
|
QSBCore.HarmonyHelper.AddPrefix<RoastingStickController>("UpdateMarshmallowInput", typeof(RoastingPatches), nameof(RoastingStickController_UpdateMarshmallowInput));
|
||||||
|
QSBCore.HarmonyHelper.AddPrefix<Marshmallow>("Burn", typeof(RoastingPatches), nameof(Marshmallow_Burn));
|
||||||
|
QSBCore.HarmonyHelper.AddPrefix<Marshmallow>("Shrivel", typeof(RoastingPatches), nameof(Marshmallow_Shrivel));
|
||||||
|
QSBCore.HarmonyHelper.AddPrefix<Marshmallow>("RemoveMallow", typeof(RoastingPatches), nameof(Marshmallow_RemoveMallow));
|
||||||
|
QSBCore.HarmonyHelper.AddPrefix<Marshmallow>("SpawnMallow", typeof(RoastingPatches), nameof(Marshmallow_SpawnMallow));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DoUnpatches()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Marshmallow_SpawnMallow()
|
||||||
|
{
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Replace);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Marshmallow_Burn(
|
||||||
|
ref Marshmallow.MallowState ____mallowState,
|
||||||
|
MeshRenderer ____fireRenderer,
|
||||||
|
ref float ____toastedFraction,
|
||||||
|
ref float ____initBurnTime,
|
||||||
|
PlayerAudioController ____audioController)
|
||||||
|
{
|
||||||
|
if (____mallowState == Marshmallow.MallowState.Default)
|
||||||
|
{
|
||||||
|
____fireRenderer.enabled = true;
|
||||||
|
____toastedFraction = 1f;
|
||||||
|
____initBurnTime = Time.time;
|
||||||
|
____mallowState = Marshmallow.MallowState.Burning;
|
||||||
|
____audioController.PlayMarshmallowCatchFire();
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Burn);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Marshmallow_Shrivel(
|
||||||
|
ref Marshmallow.MallowState ____mallowState,
|
||||||
|
ref float ____initShrivelTime)
|
||||||
|
{
|
||||||
|
if (____mallowState == Marshmallow.MallowState.Burning)
|
||||||
|
{
|
||||||
|
____initShrivelTime = Time.time;
|
||||||
|
____mallowState = Marshmallow.MallowState.Shriveling;
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Shrivel);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Marshmallow_RemoveMallow(
|
||||||
|
ParticleSystem ____smokeParticles,
|
||||||
|
MeshRenderer ____fireRenderer,
|
||||||
|
MeshRenderer ____mallowRenderer,
|
||||||
|
ref Marshmallow.MallowState ____mallowState,
|
||||||
|
Marshmallow __instance)
|
||||||
|
{
|
||||||
|
____smokeParticles.Stop();
|
||||||
|
____fireRenderer.enabled = false;
|
||||||
|
____mallowRenderer.enabled = false;
|
||||||
|
____mallowState = Marshmallow.MallowState.Gone;
|
||||||
|
__instance.enabled = false;
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Remove);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RoastingStickController_UpdateMarshmallowInput(
|
||||||
|
float ____extendFraction,
|
||||||
|
Marshmallow ____marshmallow,
|
||||||
|
GameObject ____mallowBodyPrefab,
|
||||||
|
Transform ____stickTransform,
|
||||||
|
Campfire ____campfire,
|
||||||
|
ref string ____promptText,
|
||||||
|
ScreenPrompt ____mallowPrompt,
|
||||||
|
ref bool ____showMallowPrompt,
|
||||||
|
ref bool ____showRemovePrompt)
|
||||||
|
{
|
||||||
|
var changePromptText = false;
|
||||||
|
var showRemovePrompt = false;
|
||||||
|
string text = string.Empty;
|
||||||
|
if (____extendFraction == 0f)
|
||||||
|
{
|
||||||
|
if (____marshmallow.IsEdible())
|
||||||
|
{
|
||||||
|
text = UITextLibrary.GetString(UITextType.RoastingEatPrompt);
|
||||||
|
changePromptText = true;
|
||||||
|
if (____marshmallow.IsBurned())
|
||||||
|
{
|
||||||
|
showRemovePrompt = true;
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.cancel, true, InputMode.Roasting))
|
||||||
|
{
|
||||||
|
____marshmallow.Remove();
|
||||||
|
Locator.GetPlayerAudioController().PlayMarshmallowToss();
|
||||||
|
var spawnedMarshmallow = UnityEngine.Object.Instantiate<GameObject>(____mallowBodyPrefab, ____stickTransform.position, ____stickTransform.rotation);
|
||||||
|
var rigidbody = spawnedMarshmallow.GetComponent<OWRigidbody>();
|
||||||
|
rigidbody.SetVelocity(____campfire.GetAttachedOWRigidbody(false).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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting) && ____marshmallow.IsEdible())
|
||||||
|
{
|
||||||
|
____marshmallow.Eat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (____marshmallow.GetState() == Marshmallow.MallowState.Burning)
|
||||||
|
{
|
||||||
|
text = UITextLibrary.GetString(UITextType.RoastingExtinguishPrompt);
|
||||||
|
changePromptText = true;
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting))
|
||||||
|
{
|
||||||
|
____marshmallow.Extinguish();
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBMarshmallowEvent, MarshmallowEventType.Extinguish);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (____marshmallow.GetState() == Marshmallow.MallowState.Gone)
|
||||||
|
{
|
||||||
|
text = UITextLibrary.GetString(UITextType.RoastingReplacePrompt);
|
||||||
|
changePromptText = true;
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting))
|
||||||
|
{
|
||||||
|
____marshmallow.SpawnMallow(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changePromptText && ____promptText != text)
|
||||||
|
{
|
||||||
|
____promptText = text;
|
||||||
|
____mallowPrompt.SetText(____promptText);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Roasting))
|
||||||
|
{
|
||||||
|
____campfire.StopRoasting();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
____showMallowPrompt = changePromptText;
|
||||||
|
____showRemovePrompt = showRemovePrompt;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
184
QSB/RoastingSync/QSBMarshmallow.cs
Normal file
184
QSB/RoastingSync/QSBMarshmallow.cs
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace QSB.RoastingSync
|
||||||
|
{
|
||||||
|
public class QSBMarshmallow : MonoBehaviour
|
||||||
|
{
|
||||||
|
public const float RAW_TOASTED_FRACTION = 0.2f;
|
||||||
|
public const float PERFECT_TOASTED_FRACTION = 0.7f;
|
||||||
|
public const float HEAT_CAPACITY = 300f;
|
||||||
|
public const float BURN_THRESHOLD = 25f;
|
||||||
|
public const float BURN_DURATION = 5f;
|
||||||
|
public MeshRenderer _fireRenderer;
|
||||||
|
public ParticleSystem _smokeParticles;
|
||||||
|
public MeshRenderer _mallowRenderer;
|
||||||
|
public Color _rawColor;
|
||||||
|
public Color _toastedColor;
|
||||||
|
public Color _burntColor;
|
||||||
|
private Marshmallow.MallowState _mallowState;
|
||||||
|
private ParticleSystem.MainModule _smokeParticlesSettings;
|
||||||
|
private float _heatPerSecond;
|
||||||
|
private float _toastedFraction;
|
||||||
|
private float _initBurnTime;
|
||||||
|
private float _initShrivelTime;
|
||||||
|
private SunController _sunController;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_smokeParticlesSettings = _smokeParticles.main;
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
_smokeParticles.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
if (Locator.GetSunTransform() != null)
|
||||||
|
{
|
||||||
|
_sunController = Locator.GetSunTransform().GetComponent<SunController>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpawnMallow()
|
||||||
|
{
|
||||||
|
transform.localPosition = new Vector3(0f, 0f, 0.3f);
|
||||||
|
transform.localScale = Vector3.one;
|
||||||
|
_smokeParticles.Stop();
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
_toastedFraction = 0f;
|
||||||
|
_mallowRenderer.enabled = true;
|
||||||
|
_mallowState = Marshmallow.MallowState.Default;
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
_smokeParticles.Stop();
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extinguish()
|
||||||
|
{
|
||||||
|
if (_mallowState == Marshmallow.MallowState.Burning)
|
||||||
|
{
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
_mallowState = Marshmallow.MallowState.Default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateRoast(Campfire campfire)
|
||||||
|
{
|
||||||
|
UpdateHeatExposure(campfire);
|
||||||
|
UpdateVisuals();
|
||||||
|
transform.localPosition = Vector3.MoveTowards(transform.localPosition, Vector3.zero, Time.deltaTime);
|
||||||
|
if (_mallowState != Marshmallow.MallowState.Default)
|
||||||
|
{
|
||||||
|
if (_mallowState == Marshmallow.MallowState.Burning)
|
||||||
|
{
|
||||||
|
if (Time.time > _initBurnTime + BURN_DURATION)
|
||||||
|
{
|
||||||
|
Shrivel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_mallowState == Marshmallow.MallowState.Shriveling)
|
||||||
|
{
|
||||||
|
var shrivelFraction = Mathf.Clamp01((Time.time - _initShrivelTime) / 2f);
|
||||||
|
if (shrivelFraction >= 0.5 && _fireRenderer.enabled)
|
||||||
|
{
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
}
|
||||||
|
if (shrivelFraction >= 1f)
|
||||||
|
{
|
||||||
|
RemoveMallow();
|
||||||
|
}
|
||||||
|
transform.localScale = Vector3.one * (1f - shrivelFraction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_heatPerSecond = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateHeatExposure(Campfire campfire)
|
||||||
|
{
|
||||||
|
if (_sunController != null)
|
||||||
|
{
|
||||||
|
var distanceToSupernova = Vector3.Distance(transform.position, _sunController.transform.position) - _sunController.GetSupernovaRadius();
|
||||||
|
if (distanceToSupernova < 2000f)
|
||||||
|
{
|
||||||
|
Burn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_heatPerSecond = campfire.GetHeatAtPosition(transform.position);
|
||||||
|
_toastedFraction += _heatPerSecond * Time.deltaTime / HEAT_CAPACITY;
|
||||||
|
_toastedFraction = Mathf.Clamp01(_toastedFraction);
|
||||||
|
if (_heatPerSecond > BURN_THRESHOLD)
|
||||||
|
{
|
||||||
|
Burn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateVisuals()
|
||||||
|
{
|
||||||
|
var num = _heatPerSecond / BURN_THRESHOLD;
|
||||||
|
if (num > 0f)
|
||||||
|
{
|
||||||
|
if (!_smokeParticles.isEmitting)
|
||||||
|
{
|
||||||
|
_smokeParticles.Play();
|
||||||
|
}
|
||||||
|
var smokeColor = new Color(1f, 1f, 1f, num);
|
||||||
|
_smokeParticlesSettings.startColor = smokeColor;
|
||||||
|
}
|
||||||
|
else if (_smokeParticles.isEmitting)
|
||||||
|
{
|
||||||
|
_smokeParticles.Stop();
|
||||||
|
}
|
||||||
|
Color newColor;
|
||||||
|
if (_toastedFraction < PERFECT_TOASTED_FRACTION)
|
||||||
|
{
|
||||||
|
var fractionTowardsPerfect = _toastedFraction / PERFECT_TOASTED_FRACTION;
|
||||||
|
newColor = Color.Lerp(_rawColor, _toastedColor, fractionTowardsPerfect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var fractionTowardsBurnt = (_toastedFraction - PERFECT_TOASTED_FRACTION) / 0.3f;
|
||||||
|
newColor = Color.Lerp(_toastedColor, _burntColor, fractionTowardsBurnt);
|
||||||
|
}
|
||||||
|
_mallowRenderer.material.color = Color.Lerp(_mallowRenderer.material.color, newColor, RAW_TOASTED_FRACTION);
|
||||||
|
_smokeParticles.transform.forward = Locator.GetPlayerTransform().up;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Burn()
|
||||||
|
{
|
||||||
|
if (_mallowState == Marshmallow.MallowState.Default)
|
||||||
|
{
|
||||||
|
_fireRenderer.enabled = true;
|
||||||
|
_toastedFraction = 1f;
|
||||||
|
_initBurnTime = Time.time;
|
||||||
|
_mallowState = Marshmallow.MallowState.Burning;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Shrivel()
|
||||||
|
{
|
||||||
|
if (_mallowState == Marshmallow.MallowState.Burning)
|
||||||
|
{
|
||||||
|
_initShrivelTime = Time.time;
|
||||||
|
_mallowState = Marshmallow.MallowState.Shriveling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveMallow()
|
||||||
|
{
|
||||||
|
_smokeParticles.Stop();
|
||||||
|
_fireRenderer.enabled = false;
|
||||||
|
_mallowRenderer.enabled = false;
|
||||||
|
_mallowState = Marshmallow.MallowState.Gone;
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -92,6 +92,7 @@ namespace QSB.Tools
|
|||||||
private static void CreateFlashlight(Transform cameraBody)
|
private static void CreateFlashlight(Transform cameraBody)
|
||||||
{
|
{
|
||||||
var flashlightRoot = Object.Instantiate(GameObject.Find("FlashlightRoot"));
|
var flashlightRoot = Object.Instantiate(GameObject.Find("FlashlightRoot"));
|
||||||
|
flashlightRoot.name += "-RemotePlayer";
|
||||||
flashlightRoot.SetActive(false);
|
flashlightRoot.SetActive(false);
|
||||||
var oldComponent = flashlightRoot.GetComponent<Flashlight>();
|
var oldComponent = flashlightRoot.GetComponent<Flashlight>();
|
||||||
var component = flashlightRoot.AddComponent<QSBFlashlight>();
|
var component = flashlightRoot.AddComponent<QSBFlashlight>();
|
||||||
|
11
QSB/TransformSync/RoastingStickTransformSync.cs
Normal file
11
QSB/TransformSync/RoastingStickTransformSync.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace QSB.TransformSync
|
||||||
|
{
|
||||||
|
class RoastingStickTransformSync
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"defaultServerIP": "localhost",
|
"defaultServerIP": "localhost",
|
||||||
"port": 7777,
|
"port": 7777,
|
||||||
"debugMode": false,
|
"debugMode": true,
|
||||||
"showLinesInDebug": false,
|
"showLinesInDebug": false,
|
||||||
"socketedObjToDebug": -1
|
"socketedObjToDebug": -1
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user