Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
JohnCorby 2022-03-25 10:33:29 -07:00
commit 1e1d565be4
11 changed files with 127 additions and 16 deletions

Binary file not shown.

View File

@ -0,0 +1,13 @@
using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.DreamLantern.Messages;
internal class DreamLanternLitMessage : QSBWorldObjectMessage<QSBDreamLanternItem, bool>
{
public DreamLanternLitMessage(bool lit) : base(lit) { }
public override void OnReceiveRemote()
=> QSBPatch.RemoteCall(() => WorldObject.AttachedObject.SetLit(Data));
}

View File

@ -12,8 +12,6 @@ internal class DreamLanternStateMessage : QSBMessage<(DreamLanternActionType Typ
public override void OnReceiveRemote()
{
DebugLog.DebugWrite($"{From} Action:{Data.Type} BoolValue:{Data.BoolValue} FloatValue:{Data.FloatValue}");
var heldItem = QSBPlayerManager.GetPlayer(From).HeldItem;
if (heldItem is not QSBDreamLanternItem lantern)

View File

@ -4,6 +4,7 @@ using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Patches;
using QSB.Player;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Linq;
@ -91,4 +92,16 @@ internal class DreamLanternPatches : QSBPatch
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(DreamLanternItem), nameof(DreamLanternItem.SetLit))]
public static void SetLit(DreamLanternItem __instance, bool lit)
{
if (Remote)
{
return;
}
__instance.GetWorldObject<QSBDreamLanternItem>().SendMessage(new DreamLanternLitMessage(lit));
}
}

View File

@ -0,0 +1,23 @@
using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Player;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
internal class EnterDreamWorldMessage : QSBMessage<int>
{
public EnterDreamWorldMessage(int lanternId) : base(lanternId) { }
public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
player.InDreamWorld = true;
player.AssignedSimulationLantern = QSBWorldSync.GetWorldObject<QSBDreamLanternItem>(Data);
}
}

View File

@ -0,0 +1,27 @@
using HarmonyLib;
using QSB.EchoesOfTheEye.DreamWorld.Messages;
using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Patches;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QSB.EchoesOfTheEye.DreamWorld.Patches;
internal class DreamWorldPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(DreamWorldController), nameof(DreamWorldController.SpawnInDreamWorld))]
public static void EnterDreamWorld()
{
var currentLantern = (DreamLanternItem)Locator.GetToolModeSwapper().GetItemCarryTool().GetHeldItem();
var currentQSBLantern = currentLantern.GetWorldObject<QSBDreamLanternItem>();
new EnterDreamWorldMessage(currentQSBLantern.ObjectId).Send();
}
}

View File

@ -1,6 +1,7 @@
using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
namespace QSB.ItemSync.Messages;
@ -27,6 +28,7 @@ internal class MoveToCarryMessage : QSBWorldObjectMessage<IQSBItem>
ItemType.VisionTorch => player.VisionTorchSocket,
_ => player.ItemSocket
};
WorldObject.PickUpItem(itemSocket);
switch (itemType)
@ -55,10 +57,9 @@ internal class MoveToCarryMessage : QSBWorldObjectMessage<IQSBItem>
player.AnimationSync.VisibleAnimator.SetTrigger("HoldLantern");
break;
case ItemType.SlideReel:
break;
case ItemType.DreamLantern:
break;
case ItemType.VisionTorch:
DebugLog.ToConsole($"Warning - {itemType} has no implemented holding pose.", OWML.Common.MessageType.Warning);
break;
}
}

View File

@ -1,3 +1,3 @@
namespace QSB.ItemSync.WorldObjects.Items;
internal class QSBDreamLanternItem : QSBItem<DreamLanternItem> { }
public class QSBDreamLanternItem : QSBItem<DreamLanternItem> { }

View File

@ -9,7 +9,7 @@ using UnityEngine;
namespace QSB.ItemSync.WorldObjects.Items;
internal class QSBItem<T> : WorldObject<T>, IQSBItem
public class QSBItem<T> : WorldObject<T>, IQSBItem
where T : OWItem
{
private Transform _lastParent;

View File

@ -0,0 +1,14 @@
using QSB.ItemSync.WorldObjects.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QSB.Player;
public partial class PlayerInfo
{
public bool InDreamWorld { get; set; }
public QSBDreamLanternItem AssignedSimulationLantern { get; set; }
}

View File

@ -1,10 +1,12 @@
using QSB.CampfireSync.WorldObjects;
using OWML.Common;
using QSB.CampfireSync.WorldObjects;
using QSB.ItemSync.WorldObjects.Items;
using QSB.RoastingSync;
using QSB.Tools;
using QSB.Tools.FlashlightTool;
using QSB.Tools.ProbeLauncherTool;
using QSB.Tools.ProbeTool;
using QSB.Utility;
using UnityEngine;
namespace QSB.Player;
@ -44,15 +46,35 @@ public partial class PlayerInfo
return _handPivot;
}
}
public Transform ItemSocket => HandPivot.Find("REMOTE_ItemSocket");
public Transform ScrollSocket => HandPivot.Find("REMOTE_ScrollSocket");
public Transform SharedStoneSocket => HandPivot.Find("REMOTE_SharedStoneSocket");
public Transform WarpCoreSocket => HandPivot.Find("REMOTE_WarpCoreSocket");
public Transform VesselCoreSocket => HandPivot.Find("REMOTE_VesselCoreSocket");
public Transform SimpleLanternSocket => HandPivot.Find("REMOTE_SimpleLanternSocket");
public Transform DreamLanternSocket => HandPivot.Find("REMOTE_DreamLanternSocket");
public Transform SlideReelSocket => HandPivot.Find("REMOTE_SlideReelSocket");
public Transform VisionTorchSocket => HandPivot.Find("REMOTE_VisionTorchSocket");
public Transform ItemSocket => GetSocket("REMOTE_ItemSocket");
public Transform ScrollSocket => GetSocket("REMOTE_ScrollSocket");
public Transform SharedStoneSocket => GetSocket("REMOTE_SharedStoneSocket");
public Transform WarpCoreSocket => GetSocket("REMOTE_WarpCoreSocket");
public Transform VesselCoreSocket => GetSocket("REMOTE_VesselCoreSocket");
public Transform SimpleLanternSocket => GetSocket("REMOTE_SimpleLanternSocket");
public Transform DreamLanternSocket => GetSocket("REMOTE_DreamLanternSocket");
public Transform SlideReelSocket => GetSocket("REMOTE_SlideReelSocket");
public Transform VisionTorchSocket => GetSocket("REMOTE_VisionTorchSocket");
private Transform GetSocket(string name)
{
var handSocket = HandPivot.Find(name);
if (handSocket != null)
{
return handSocket;
}
var cameraSocket = CameraBody.transform.Find("REMOTE_ItemCarryTool").Find(name);
if (cameraSocket != null)
{
DebugLog.ToConsole($"Warning - Could not find hand socket for socket name {name}, defaulting to camera socket.", MessageType.Warning);
return cameraSocket;
}
DebugLog.ToConsole($"Error - Could not find hand socket or camera socket for socket name {name}.", MessageType.Error);
return null;
}
public QSBMarshmallow Marshmallow { get; set; }
public QSBCampfire Campfire { get; set; }
public IQSBItem HeldItem { get; set; }