Skip to content

Commit 597be80

Browse files
Fully sync exosuits and drilling (SubnauticaNitrox#2304)
1 parent 019ee4e commit 597be80

53 files changed

Lines changed: 808 additions & 390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using BinaryPack.Attributes;
4+
5+
namespace Nitrox.Model.Subnautica.DataStructures.GameLogic.Entities.Metadata;
6+
7+
[Serializable]
8+
[DataContract]
9+
public class DrillableMetadata : EntityMetadata
10+
{
11+
[DataMember(Order = 1)]
12+
public float[] ChunkHealth { get; }
13+
14+
[DataMember(Order = 2)]
15+
public float TimeLastDrilled { get; }
16+
17+
[IgnoreConstructor]
18+
protected DrillableMetadata()
19+
{
20+
//Constructor for serialization. Has to be "protected" for json serialization.
21+
}
22+
23+
public DrillableMetadata(float[] chunkHealth, float timeLastDrilled)
24+
{
25+
ChunkHealth = chunkHealth;
26+
TimeLastDrilled = timeLastDrilled;
27+
}
28+
29+
public override string ToString()
30+
{
31+
return $"[DrillableMetadata ChunkHealth: {string.Join(",", ChunkHealth)} TimeLastDrilled: {TimeLastDrilled}]";
32+
}
33+
}

Nitrox.Model.Subnautica/DataStructures/GameLogic/Entities/Metadata/EntityMetadata.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace Nitrox.Model.Subnautica.DataStructures.GameLogic.Entities.Metadata
4040
[ProtoInclude(81, typeof(EggMetadata))]
4141
[ProtoInclude(82, typeof(PlantableMetadata))]
4242
[ProtoInclude(83, typeof(FruitPlantMetadata))]
43+
[ProtoInclude(84, typeof(DrillableMetadata))]
4344
public abstract class EntityMetadata
4445
{
4546
}

Nitrox.Model.Subnautica/Packets/ExosuitArmActionPacket.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
1+
using System;
22
using Nitrox.Model.DataStructures;
3-
using Nitrox.Model.DataStructures.Unity;
43
using Nitrox.Model.Packets;
54

65
namespace Nitrox.Model.Subnautica.Packets
@@ -9,23 +8,21 @@ namespace Nitrox.Model.Subnautica.Packets
98
public class ExosuitArmActionPacket : Packet
109
{
1110
public TechType TechType { get; }
12-
public NitroxId ArmId { get; }
11+
public NitroxId ExosuitId { get; }
12+
public Exosuit.Arm ArmSide { get; }
1313
public ExosuitArmAction ArmAction { get; }
14-
public NitroxVector3? OpVector { get; }
15-
public NitroxQuaternion? OpRotation { get; }
1614

17-
public ExosuitArmActionPacket(TechType techType, NitroxId armId, ExosuitArmAction armAction, NitroxVector3? opVector, NitroxQuaternion? opRotation)
15+
public ExosuitArmActionPacket(TechType techType, NitroxId exosuitId, Exosuit.Arm armSide, ExosuitArmAction armAction)
1816
{
1917
TechType = techType;
20-
ArmId = armId;
18+
ExosuitId = exosuitId;
19+
ArmSide = armSide;
2120
ArmAction = armAction;
22-
OpVector = opVector;
23-
OpRotation = opRotation;
2421
}
2522

2623
public override string ToString()
2724
{
28-
return $"[ExosuitArmAction - TechType: {TechType}, ArmId:{ArmId}, ArmAction: {ArmAction}, Vector: {OpVector}, Rotation: {OpRotation}]";
25+
return $"[ExosuitArmAction - TechType: {TechType}, ExosuitId:{ExosuitId}, ArmSide: {ArmSide}, ArmAction: {ArmAction}]";
2926
}
3027
}
3128

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using Nitrox.Model.DataStructures;
3+
using Nitrox.Model.DataStructures.Unity;
4+
using Nitrox.Model.Networking;
5+
using Nitrox.Model.Packets;
6+
7+
namespace Nitrox.Model.Subnautica.Packets;
8+
9+
[Serializable]
10+
public class GrapplingHookMovement : Packet
11+
{
12+
public NitroxId ExosuitId { get; }
13+
public Exosuit.Arm ArmSide { get; }
14+
public NitroxVector3 Position { get; }
15+
public NitroxVector3 Velocity { get; }
16+
public NitroxQuaternion Rotation { get; }
17+
18+
public GrapplingHookMovement(NitroxId exosuitId, Exosuit.Arm armSide, NitroxVector3 position, NitroxVector3 velocity, NitroxQuaternion rotation)
19+
{
20+
ExosuitId = exosuitId;
21+
ArmSide = armSide;
22+
Position = position;
23+
Velocity = velocity;
24+
Rotation = rotation;
25+
DeliveryMethod = NitroxDeliveryMethod.DeliveryMethod.UNRELIABLE_SEQUENCED;
26+
UdpChannel = UdpChannelId.MOVEMENTS;
27+
}
28+
}

Nitrox.Model.Subnautica/Packets/ModuleAdded.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

Nitrox.Model.Subnautica/Packets/ModuleRemoved.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

Nitrox.Model.Subnautica/Packets/VehicleMovements.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ public VehicleMovements(List<MovementData> data, double realTime)
2626
public abstract record class MovementData(NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation) { }
2727

2828
[Serializable]
29-
public record class SimpleMovementData(NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation) : MovementData(Id, Position, Rotation) { }
29+
public record class SimpleMovementData(NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation)
30+
: MovementData(Id, Position, Rotation) { }
3031

3132
[Serializable]
32-
public record class DrivenVehicleMovementData(NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation, sbyte SteeringWheelYaw, sbyte SteeringWheelPitch, bool ThrottleApplied) : MovementData(Id, Position, Rotation) { }
33+
public record class DrivenVehicleMovementData(
34+
NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation,
35+
sbyte SteeringWheelYaw, sbyte SteeringWheelPitch, bool ThrottleApplied)
36+
: MovementData(Id, Position, Rotation) { }
37+
38+
[Serializable]
39+
public record class ExosuitMovementData(NitroxId Id, NitroxVector3 Position, NitroxQuaternion Rotation,
40+
NitroxVector3 AimTargetLeft, NitroxVector3 AimTargetRight, sbyte SteeringWheelYaw,
41+
sbyte SteeringWheelPitch, bool ThrottleApplied, bool IKEnabled)
42+
: DrivenVehicleMovementData(Id, Position, Rotation, SteeringWheelYaw, SteeringWheelPitch, ThrottleApplied) { }

Nitrox.Server.Subnautica/Models/Packets/Processors/EntityReparentedProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override void Process(EntityReparented packet, Player player)
2828
Log.Error($"Couldn't find parent entity for {packet.NewParentId}");
2929
return;
3030
}
31-
31+
3232
entityRegistry.ReparentEntity(packet.Id, packet.NewParentId);
3333
playerManager.SendPacketToOtherPlayers(packet, player);
3434
}

Nitrox.Server.Subnautica/Models/Packets/Processors/ModuleAddedProcessor.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

Nitrox.Server.Subnautica/Models/Packets/Processors/ModuleRemovedProcessor.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)