-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
958dd40
commit 58c7b9b
Showing
8 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
QSB/EchoesOfTheEye/RaftSync/Messages/RaftCarrierOnEntryMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using QSB.EchoesOfTheEye.RaftSync.WorldObjects; | ||
using QSB.Messaging; | ||
using QSB.WorldSync; | ||
using UnityEngine; | ||
|
||
namespace QSB.EchoesOfTheEye.RaftSync.Messages; | ||
internal class RaftCarrierOnEntryMessage : QSBWorldObjectMessage<IQSBRaftCarrier, int> | ||
{ | ||
public RaftCarrierOnEntryMessage(QSBRaft raft) : base(raft.ObjectId) { } | ||
|
||
public override void OnReceiveRemote() | ||
{ | ||
// TODO : work out if we can just call RaftCarrier.OnEntry with a right gameobject? tried it with _fluidDetector.gameObject and it didn't work | ||
|
||
var qsbRaft = Data.GetWorldObject<QSBRaft>(); | ||
var attachedObj = WorldObject.AttachedObject as RaftCarrier; | ||
|
||
attachedObj._raft = qsbRaft.AttachedObject; | ||
attachedObj._raft.OnArriveAtTarget += attachedObj.OnArriveAtTarget; | ||
attachedObj.GetAlignDestination().localEulerAngles = Vector3.zero; | ||
|
||
var relativeDockForward = attachedObj.GetAlignDestination().InverseTransformDirection(attachedObj._raft.transform.forward); | ||
relativeDockForward.y = 0f; | ||
|
||
var targetRaftRotation = OWMath.Angle(Vector3.forward, relativeDockForward, Vector3.up); | ||
targetRaftRotation = OWMath.RoundToNearestMultiple(targetRaftRotation, 90f); | ||
attachedObj.GetAlignDestination().localEulerAngles = new Vector3(0f, targetRaftRotation, 0f); | ||
|
||
var raftMovementDirection = attachedObj.GetAlignDestination().position - attachedObj._raft.GetBody().GetPosition(); | ||
raftMovementDirection = Vector3.Project(raftMovementDirection, attachedObj._raft.transform.up); | ||
|
||
var targetPosition = attachedObj.GetAlignDestination().position - attachedObj.GetAlignDestination().up * raftMovementDirection.magnitude; | ||
|
||
attachedObj._raft.MoveToTarget(targetPosition, attachedObj.GetAlignDestination().rotation, attachedObj._raftAlignSpeed, false); | ||
attachedObj._oneShotAudio.PlayOneShot(global::AudioType.Raft_Reel_Start, 1f); | ||
attachedObj._loopingAudio.FadeIn(0.2f, false, false, 1f); | ||
attachedObj._state = RaftCarrier.DockState.AligningBelow; | ||
|
||
if (WorldObject.AttachedObject is RaftDock dock) | ||
{ | ||
if (dock._state == RaftCarrier.DockState.AligningBelow) | ||
{ | ||
dock.enabled = true; | ||
} | ||
} | ||
else if (WorldObject.AttachedObject is DamRaftLift lift) | ||
{ | ||
if (lift._state == RaftCarrier.DockState.AligningBelow) | ||
{ | ||
lift.enabled = true; | ||
|
||
foreach (var node in lift._liftNodes) | ||
{ | ||
node.localEulerAngles = lift.GetAlignDestination().localEulerAngles; | ||
} | ||
|
||
lift._nodeIndex = 1; | ||
lift._raftDockLights.SetLightsActivation(true, false); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using QSB.WorldSync; | ||
|
||
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; | ||
|
||
internal interface IQSBRaftCarrier : IWorldObject | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; | ||
|
||
internal class QSBDamRaftLift : QSBRaftCarrier<DamRaftLift> | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using QSB.WorldSync; | ||
|
||
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; | ||
|
||
public class QSBRaftCarrier<T> : WorldObject<T>, IQSBRaftCarrier | ||
where T : RaftCarrier | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
using QSB.ItemSync.WorldObjects; | ||
using QSB.WorldSync; | ||
|
||
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; | ||
|
||
public class QSBRaftDock : WorldObject<RaftDock>, IQSBDropTarget | ||
public class QSBRaftDock : QSBRaftCarrier<RaftDock>, IQSBDropTarget | ||
{ | ||
IItemDropTarget IQSBDropTarget.AttachedObject => AttachedObject; | ||
} |