first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class AggressiveWhenSeeTargetChanged : Packet
{
public NitroxId CreatureId { get; }
public NitroxId TargetId { get; }
public bool Locked { get; }
public float AggressionAmount { get; }
public AggressiveWhenSeeTargetChanged(NitroxId creatureId, NitroxId targetId, bool locked, float aggressionAmount)
{
CreatureId = creatureId;
TargetId = targetId;
Locked = locked;
AggressionAmount = aggressionAmount;
}
}

View File

@@ -0,0 +1,19 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class AnimationChangeEvent : Packet
{
public ushort PlayerId { get; }
public int Type { get; }
public int State { get; }
public AnimationChangeEvent(ushort playerId, int type, int state)
{
PlayerId = playerId;
Type = type;
State = state;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class AttackCyclopsTargetChanged : Packet
{
public NitroxId CreatureId { get; }
public NitroxId TargetId { get; }
public float AggressiveToNoiseAmount { get; }
public AttackCyclopsTargetChanged(NitroxId creatureId, NitroxId targetId, float aggressiveToNoiseAmount)
{
CreatureId = creatureId;
TargetId = targetId;
AggressiveToNoiseAmount = aggressiveToNoiseAmount;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets;
[Serializable]
public class AuroraAndTimeUpdate : Packet
{
public TimeData TimeData { get; }
public bool Restore { get; }
public AuroraAndTimeUpdate(TimeData timeData, bool restore)
{
TimeData = timeData;
Restore = restore;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class BaseDeconstructed : Packet
{
public NitroxId FormerBaseId { get; }
public GhostEntity ReplacerGhost { get; }
public BaseDeconstructed(NitroxId formerBaseId, GhostEntity replacerGhost)
{
FormerBaseId = formerBaseId;
ReplacerGhost = replacerGhost;
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class BedEnter : Packet
{
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public sealed class BuildingDesyncWarning : Packet
{
public Dictionary<NitroxId, int> Operations { get; }
public BuildingDesyncWarning(Dictionary<NitroxId, int> operations)
{
Operations = operations;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class BuildingResync : Packet
{
public Dictionary<BuildEntity, int> BuildEntities { get; }
public Dictionary<ModuleEntity, int> ModuleEntities { get; }
public BuildingResync(Dictionary<BuildEntity, int> buildEntities, Dictionary<ModuleEntity, int> moduleEntities)
{
BuildEntities = buildEntities;
ModuleEntities = moduleEntities;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public sealed class BuildingResyncRequest : Packet
{
public NitroxId EntityId { get; }
public bool ResyncEverything { get; }
public BuildingResyncRequest(NitroxId entityId = null, bool resyncEverything = true)
{
EntityId = entityId;
ResyncEverything = resyncEverything;
}
}

View File

@@ -0,0 +1,20 @@
using System;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets
{
[Serializable]
public class CellVisibilityChanged : Packet
{
public ushort PlayerId { get; }
public AbsoluteEntityCell[] Added { get; }
public AbsoluteEntityCell[] Removed { get; }
public CellVisibilityChanged(ushort playerId, AbsoluteEntityCell[] added, AbsoluteEntityCell[] removed)
{
PlayerId = playerId;
Added = added;
Removed = removed;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class ChatMessage : Packet
{
public ushort PlayerId { get; }
public string Text { get; }
public const ushort SERVER_ID = ushort.MaxValue;
public ChatMessage(ushort playerId, string text)
{
PlayerId = playerId;
Text = text;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class ClearPlanter : Packet
{
public NitroxId PlanterId { get; }
public ClearPlanter(NitroxId planterId)
{
PlanterId = planterId;
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public abstract class CorrelatedPacket : Packet
{
public string CorrelationId { get; protected set; }
protected CorrelatedPacket(string correlationId)
{
CorrelationId = correlationId;
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public sealed class CreatureActionChanged : Packet
{
public NitroxId CreatureId { get; }
public string CreatureActionType { get; }
public CreatureActionChanged(NitroxId creatureId, string creatureActionType)
{
CreatureId = creatureId;
CreatureActionType = creatureActionType;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class CreaturePoopPerformed : Packet
{
public NitroxId CreatureId { get; }
public CreaturePoopPerformed(NitroxId creatureId)
{
CreatureId = creatureId;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets
{
[Serializable]
public class DebugStartMapPacket : Packet
{
public List<NitroxVector3> StartPositions { get; }
public DebugStartMapPacket(List<NitroxVector3> startPositions)
{
StartPositions = startPositions;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets
{
[Serializable]
public class DeconstructionBegin : Packet
{
public NitroxId Id { get; }
public DeconstructionBegin(NitroxId id)
{
Id = id;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class Disconnect : Packet
{
public ushort PlayerId { get; }
public Disconnect(ushort playerId)
{
PlayerId = playerId;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class DiscordRequestIP : Packet
{
public string IpPort { get; set; }
public DiscordRequestIP(string ipPort)
{
IpPort = ipPort;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class DropSimulationOwnership : Packet
{
public NitroxId EntityId { get; set; }
public DropSimulationOwnership(NitroxId entityId)
{
EntityId = entityId;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class EntityDestroyed : Packet
{
public NitroxId Id { get; }
public EntityDestroyed(NitroxId id)
{
Id = id;
}
}

View File

@@ -0,0 +1,20 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Entities.Metadata;
namespace NitroxModel.Packets
{
[Serializable]
public class EntityMetadataUpdate : Packet
{
public NitroxId Id { get; }
public EntityMetadata NewValue { get; }
public EntityMetadataUpdate(NitroxId id, EntityMetadata newValue)
{
Id = id;
NewValue = newValue;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class EntityReparented : Packet
{
public NitroxId Id { get; }
public NitroxId NewParentId { get; }
public EntityReparented(NitroxId id, NitroxId newParentId)
{
Id = id;
NewParentId = newParentId;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets;
[Serializable]
public class EntitySpawnedByClient : Packet
{
public Entity Entity { get; }
public bool RequireRespawn { get; }
public bool RequireSimulation { get; }
public EntitySpawnedByClient(Entity entity, bool requireRespawn = false, bool requireSimulation = true)
{
Entity = entity;
RequireRespawn = requireRespawn;
RequireSimulation = requireSimulation;
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public class EntityTransformUpdates : Packet
{
public List<EntityTransformUpdate> Updates { get; }
public EntityTransformUpdates(List<EntityTransformUpdate> updates)
{
Updates = updates;
}
public override string ToString()
{
return $"[EntityTransformUpdates: {String.Join(" ", Updates)} ]";
}
[Serializable]
public abstract class EntityTransformUpdate
{
public NitroxId Id { get; }
public NitroxVector3 Position { get; }
public NitroxQuaternion Rotation { get; }
public EntityTransformUpdate(NitroxId id, NitroxVector3 position, NitroxQuaternion rotation)
{
Id = id;
Position = position;
Rotation = rotation;
}
}
[Serializable]
public class RawTransformUpdate : EntityTransformUpdate
{
public RawTransformUpdate(NitroxId id, NitroxVector3 position, NitroxQuaternion rotation) : base(id, position, rotation)
{
}
public override string ToString()
{
return $"[RawTransformUpdate Id:{Id} Position:{Position} Rotation:{Rotation}]";
}
}
[Serializable]
public class SplineTransformUpdate : EntityTransformUpdate
{
public NitroxVector3 DestinationPosition { get; }
public NitroxVector3 DestinationDirection { get; }
public float Velocity { get; }
public SplineTransformUpdate(NitroxId id, NitroxVector3 position, NitroxQuaternion rotation, NitroxVector3 destinationPosition, NitroxVector3 destinationDirection, float velocity) : base(id, position, rotation)
{
DestinationPosition = destinationPosition;
DestinationDirection = destinationDirection;
Velocity = velocity;
}
public override string ToString()
{
return $"[SplineTransformUpdate Id:{Id} Position:{Position} Rotation:{Rotation} DestinationPosition:{DestinationPosition} DestinationDirection:{DestinationDirection} Velocity:{Velocity} ]";
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Util;
namespace NitroxModel.Packets
{
[Serializable]
public class EscapePodChanged : Packet
{
public ushort PlayerId { get; }
public Optional<NitroxId> EscapePodId { get; }
public EscapePodChanged(ushort playerId, Optional<NitroxId> escapePodId)
{
PlayerId = playerId;
EscapePodId = escapePodId;
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Runtime.Serialization;
namespace NitroxModel.Packets.Exceptions
{
public class UncorrelatedPacketException : Exception
{
public CorrelatedPacket InvalidPacket { get; }
public string ExpectedCorrelationId { get; }
public UncorrelatedPacketException(CorrelatedPacket invalidPacket, string expectedCorrelationId)
{
InvalidPacket = invalidPacket;
ExpectedCorrelationId = expectedCorrelationId;
}
public UncorrelatedPacketException(string message, CorrelatedPacket invalidPacket, string expectedCorrelationId) : base(message)
{
InvalidPacket = invalidPacket;
ExpectedCorrelationId = expectedCorrelationId;
}
public UncorrelatedPacketException(string message, Exception innerException, CorrelatedPacket invalidPacket, string expectedCorrelationId) : base(message, innerException)
{
InvalidPacket = invalidPacket;
ExpectedCorrelationId = expectedCorrelationId;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public class FMODAssetPacket : Packet
{
public string AssetPath { get; }
public NitroxVector3 Position { get; }
public float Volume { get; set; }
public FMODAssetPacket(string assetPath, NitroxVector3 position, float volume)
{
AssetPath = assetPath;
Position = position;
Volume = volume;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class FMODCustomEmitterPacket : Packet
{
public NitroxId Id { get; }
public string AssetPath { get; }
public bool Play { get; }
public FMODCustomEmitterPacket(NitroxId id, string assetPath, bool play)
{
Id = id;
AssetPath = assetPath;
Play = play;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class FMODCustomLoopingEmitterPacket : Packet
{
public NitroxId Id { get; }
public string AssetPath { get; }
public FMODCustomLoopingEmitterPacket(NitroxId id, string assetPath)
{
Id = id;
AssetPath = assetPath;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public class FMODEventInstancePacket : FMODAssetPacket
{
public NitroxId Id { get; }
public bool Play { get; }
public FMODEventInstancePacket(NitroxId id, bool play, string assetPath, NitroxVector3 position, float volume) : base(assetPath, position, volume)
{
Id = id;
Play = play;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class FMODStudioEmitterPacket : Packet
{
public NitroxId Id { get; }
public string AssetPath { get; }
public bool Play { get; }
public bool AllowFadeout { get; }
public FMODStudioEmitterPacket(NitroxId id, string assetPath, bool play, bool allowFadeout)
{
Id = id;
AssetPath = assetPath;
Play = play;
AllowFadeout = allowFadeout;
}
}

View File

@@ -0,0 +1,22 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class FastCheatChanged : Packet
{
public FastCheat Cheat{ get; }
public bool Value { get; }
public FastCheatChanged(FastCheat cheat, bool value)
{
Cheat = cheat;
Value = value;
}
public enum FastCheat : byte
{
HATCH,
GROW
}
}

View File

@@ -0,0 +1,24 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets
{
/// <summary>
/// Triggered when a fire has been doused. Fire growth is a static thing, so we only need to track dousing
/// </summary>
[Serializable]
public class FireDoused : Packet
{
public NitroxId Id { get; }
public float DouseAmount { get; }
/// <param name="id">The Fire id</param>
/// <param name="douseAmount">The amount to douse the fire by. A large number will extinguish the fire. A large number still calls the same
/// method, <see cref="Fire.Douse(float)"/>, which will call <see cref="Fire.Extinguish"/> if the douse amount would extinguish it.</param>
public FireDoused(NitroxId id, float douseAmount)
{
Id = id;
DouseAmount = douseAmount;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class FootstepPacket : Packet
{
public ushort PlayerID { get; }
public StepSounds AssetIndex { get; }
public FootstepPacket(ushort playerID, StepSounds assetIndex)
{
PlayerID = playerID;
AssetIndex = assetIndex;
DeliveryMethod = Networking.NitroxDeliveryMethod.DeliveryMethod.UNRELIABLE_SEQUENCED;
UdpChannel = UdpChannelId.MOVEMENTS;
}
public enum StepSounds : byte
{
PRECURSOR,
METAL,
LAND
}
}

View File

@@ -0,0 +1,29 @@
using System;
using NitroxModel.Server;
namespace NitroxModel.Packets;
[Serializable]
public class GameModeChanged : Packet
{
public ushort PlayerId { get; }
public bool AllPlayers { get; }
public NitroxGameMode GameMode { get; }
public GameModeChanged(ushort playerId, bool allPlayers, NitroxGameMode gameMode)
{
PlayerId = playerId;
AllPlayers = allPlayers;
GameMode = gameMode;
}
public static GameModeChanged ForPlayer(ushort playerId, NitroxGameMode gameMode)
{
return new(playerId, false, gameMode);
}
public static GameModeChanged ForAllPlayers(NitroxGameMode gameMode)
{
return new(0, true, gameMode);
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class GoalCompleted : Packet
{
public string CompletedGoal { get; }
public float CompletionTime { get; }
public GoalCompleted(string completedGoal, float completionTime)
{
CompletedGoal = completedGoal;
CompletionTime = completionTime;
}
}

View File

@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic;
using NitroxModel.DataStructures.Unity;
using NitroxModel.DataStructures.Util;
using NitroxModel.MultiplayerSession;
using NitroxModel.Server;
namespace NitroxModel.Packets
{
[Serializable]
public class InitialPlayerSync : Packet
{
public NitroxId AssignedEscapePodId { get; }
public Dictionary<string, NitroxId> EquippedItems { get; }
public List<NitroxTechType> UsedItems { get; }
public Optional<NitroxId>[] QuickSlotsBindingIds { get; }
public NitroxId PlayerGameObjectId { get; }
public bool FirstTimeConnecting { get; }
public InitialPDAData PDAData { get; }
public InitialStoryGoalData StoryGoalData { get; }
public NitroxVector3 PlayerSpawnData { get; }
public NitroxQuaternion PlayerSpawnRotation { get; }
public Optional<NitroxId> PlayerSubRootId { get; }
public PlayerStatsData PlayerStatsData { get; }
public List<PlayerContext> OtherPlayers { get; }
public List<Entity> GlobalRootEntities { get; }
public List<SimulatedEntity> InitialSimulationOwnerships { get; }
public NitroxGameMode GameMode { get; }
public Perms Permissions { get; }
public IntroCinematicMode IntroCinematicMode { get; }
public SubnauticaPlayerPreferences Preferences { get; }
public TimeData TimeData { get; }
public bool IsFirstPlayer { get; }
public Dictionary<NitroxId, int> BuildOperationIds { get; }
public bool KeepInventoryOnDeath { get; }
public SessionSettings SessionSettings { get; }
public InitialPlayerSync(NitroxId playerGameObjectId,
bool firstTimeConnecting,
NitroxId assignedEscapePodId,
IDictionary<string, NitroxId> equipment,
IEnumerable<NitroxTechType> usedItems,
Optional<NitroxId>[] quickSlotsBindingIds,
InitialPDAData pdaData,
InitialStoryGoalData storyGoalData,
NitroxVector3 playerSpawnData,
NitroxQuaternion playerSpawnRotation,
Optional<NitroxId> playerSubRootId,
PlayerStatsData playerStatsData,
IEnumerable<PlayerContext> otherPlayers,
IEnumerable<Entity> globalRootEntities,
IEnumerable<SimulatedEntity> initialSimulationOwnerships,
NitroxGameMode gameMode,
Perms perms,
IntroCinematicMode introCinematicMode,
SubnauticaPlayerPreferences preferences,
TimeData timeData,
bool isFirstPlayer,
Dictionary<NitroxId, int> buildOperationIds,
bool keepInventoryOnDeath,
SessionSettings sessionSettings)
{
AssignedEscapePodId = assignedEscapePodId;
PlayerGameObjectId = playerGameObjectId;
FirstTimeConnecting = firstTimeConnecting;
EquippedItems = new(equipment);
UsedItems = usedItems.ToList();
QuickSlotsBindingIds = quickSlotsBindingIds;
PDAData = pdaData;
StoryGoalData = storyGoalData;
PlayerSpawnData = playerSpawnData;
PlayerSpawnRotation = playerSpawnRotation;
PlayerSubRootId = playerSubRootId;
PlayerStatsData = playerStatsData;
OtherPlayers = otherPlayers.ToList();
GlobalRootEntities = globalRootEntities.ToList();
InitialSimulationOwnerships = initialSimulationOwnerships.ToList();
GameMode = gameMode;
Permissions = perms;
IntroCinematicMode = introCinematicMode;
Preferences = preferences;
TimeData = timeData;
IsFirstPlayer = isFirstPlayer;
BuildOperationIds = buildOperationIds;
KeepInventoryOnDeath = keepInventoryOnDeath;
SessionSettings = sessionSettings;
}
/// <remarks>Used for deserialization</remarks>
public InitialPlayerSync(
NitroxId assignedEscapePodId,
Dictionary<string, NitroxId> equippedItems,
List<NitroxTechType> usedItems,
Optional<NitroxId>[] quickSlotsBindingIds,
NitroxId playerGameObjectId,
bool firstTimeConnecting,
InitialPDAData pdaData,
InitialStoryGoalData storyGoalData,
NitroxVector3 playerSpawnData,
NitroxQuaternion playerSpawnRotation,
Optional<NitroxId> playerSubRootId,
PlayerStatsData playerStatsData,
List<PlayerContext> otherPlayers,
List<Entity> globalRootEntities,
List<SimulatedEntity> initialSimulationOwnerships,
NitroxGameMode gameMode,
Perms permissions,
IntroCinematicMode introCinematicMode,
SubnauticaPlayerPreferences preferences,
TimeData timeData,
bool isFirstPlayer,
Dictionary<NitroxId, int> buildOperationIds,
bool keepInventoryOnDeath,
SessionSettings sessionSettings)
{
AssignedEscapePodId = assignedEscapePodId;
PlayerGameObjectId = playerGameObjectId;
FirstTimeConnecting = firstTimeConnecting;
EquippedItems = equippedItems;
UsedItems = usedItems;
QuickSlotsBindingIds = quickSlotsBindingIds;
PDAData = pdaData;
StoryGoalData = storyGoalData;
PlayerSpawnData = playerSpawnData;
PlayerSpawnRotation = playerSpawnRotation;
PlayerSubRootId = playerSubRootId;
PlayerStatsData = playerStatsData;
OtherPlayers = otherPlayers;
GlobalRootEntities = globalRootEntities;
InitialSimulationOwnerships = initialSimulationOwnerships;
GameMode = gameMode;
Permissions = permissions;
IntroCinematicMode = introCinematicMode;
Preferences = preferences;
TimeData = timeData;
IsFirstPlayer = isFirstPlayer;
BuildOperationIds = buildOperationIds;
KeepInventoryOnDeath = keepInventoryOnDeath;
SessionSettings = sessionSettings;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets
{
[Serializable]
public class ItemPosition : Packet
{
public NitroxId Id { get; }
public NitroxVector3 Position { get; }
public NitroxQuaternion Rotation { get; }
public ItemPosition(NitroxId id, NitroxVector3 position, NitroxQuaternion rotation)
{
Id = id;
Position = position;
Rotation = rotation;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class KeepInventoryChanged : Packet
{
public bool KeepInventoryOnDeath { get; }
public KeepInventoryChanged(bool keepInventoryOnDeath)
{
KeepInventoryOnDeath = keepInventoryOnDeath;
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets
{
[Serializable]
public class KnownTechEntryAdd : Packet
{
public enum EntryCategory
{
/// <summary>
/// <b>KnownTech.knownTech</b><br/>
/// Tech items that you learn about after fulfilling a requirement. Often times, discovering a new KnownTech.analyzedTech item will provide 1 or more KnownTech.knownTech items. (Peeper -> CookedPeeper)
/// </summary>
KNOWN = 0,
/// <summary>
/// <b>KnownTech.analyzedTech</b><br/>
/// Tech items that you find in the world and acquire. They often show a notification saying you found/learned about them. (Fish, Resources, etc)
/// <br/>
/// </summary>
ANALYZED = 1
}
public NitroxTechType TechType { get; }
public bool Verbose { get; }
public EntryCategory Category { get; }
public List<NitroxTechType> PartialTechTypesToRemove { get; }
public KnownTechEntryAdd(EntryCategory category, NitroxTechType techType, bool verbose, List<NitroxTechType> partialTechTypesToRemove = null)
{
Category = category;
TechType = techType;
Verbose = verbose;
PartialTechTypesToRemove = partialTechTypesToRemove;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Bases;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class LargeWaterParkDeconstructed : PieceDeconstructed
{
public Dictionary<NitroxId, List<NitroxId>> MovedChildrenIdsByNewHostId;
public LargeWaterParkDeconstructed(NitroxId baseId, NitroxId pieceId, BuildPieceIdentifier buildPieceIdentifier, GhostEntity replacerGhost, BaseData baseData, Dictionary<NitroxId, List<NitroxId>> movedChildrenIdsByNewHostId, int operationId) :
base(baseId, pieceId, buildPieceIdentifier, replacerGhost, baseData, operationId)
{
MovedChildrenIdsByNewHostId = movedChildrenIdsByNewHostId;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class LeakRepaired : Packet
{
public NitroxId BaseId { get; set; }
public NitroxId LeakId { get; set; }
public NitroxInt3 RelativeCell { get; set; }
public LeakRepaired(NitroxId baseId, NitroxId leakId, NitroxInt3 relativeCell)
{
BaseId = baseId;
LeakId = leakId;
RelativeCell = relativeCell;
}
}

View File

@@ -0,0 +1,22 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets
{
[Serializable]
public class MedicalCabinetClicked : Packet
{
public NitroxId Id { get; }
public bool DoorOpen { get; }
public bool HasMedKit { get; }
public float NextSpawnTime { get; }
public MedicalCabinetClicked(NitroxId id, bool doorOpen, bool hasMedKit, float nextSpawnTime)
{
Id = id;
DoorOpen = doorOpen;
HasMedKit = hasMedKit;
NextSpawnTime = nextSpawnTime;
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public sealed class ModifyConstructedAmount : Packet
{
public NitroxId GhostId { get; }
public float ConstructedAmount { get; }
public ModifyConstructedAmount(NitroxId ghostId, float constructedAmount)
{
GhostId = ghostId;
ConstructedAmount = constructedAmount;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class ModuleAdded : Packet
{
public NitroxId Id { get; }
public NitroxId ParentId { get; }
public string Slot { get; }
public ModuleAdded(NitroxId id, NitroxId parentId, string slot)
{
Id = id;
ParentId = parentId;
Slot = slot;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class ModuleRemoved : Packet
{
public NitroxId Id { get; }
public NitroxId NewParentId { get; }
public ModuleRemoved(NitroxId id, NitroxId newParentId)
{
Id = id;
NewParentId = newParentId;
}
}

View File

@@ -0,0 +1,14 @@
using System;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public abstract class Movement : Packet
{
public abstract ushort PlayerId { get; }
public abstract NitroxVector3 Position { get; }
public abstract NitroxVector3 Velocity { get; }
public abstract NitroxQuaternion BodyRotation { get; }
public abstract NitroxQuaternion AimingRotation { get; }
}

View File

@@ -0,0 +1,40 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.Helper;
using NitroxModel.MultiplayerSession;
namespace NitroxModel.Packets
{
[Serializable]
public class MultiplayerSessionPolicy : CorrelatedPacket
{
public bool RequiresServerPassword { get; }
public MultiplayerSessionAuthenticationAuthority AuthenticationAuthority { get; }
public bool DisableConsole { get; }
public int MaxConnections { get; }
public NitroxVersion NitroxVersionAllowed { get; }
public MultiplayerSessionPolicy(string correlationId, bool disableConsole, int maxConnections, bool requiresServerPassword) : base(correlationId)
{
RequiresServerPassword = requiresServerPassword;
AuthenticationAuthority = MultiplayerSessionAuthenticationAuthority.SERVER;
DisableConsole = disableConsole;
MaxConnections = maxConnections;
Version ver = NitroxEnvironment.Version;
// only the major and minor version number is required
NitroxVersionAllowed = new(ver.Major, ver.Minor);
}
/// <remarks>Used for deserialization</remarks>
public MultiplayerSessionPolicy(string correlationId, bool requiresServerPassword, MultiplayerSessionAuthenticationAuthority authenticationAuthority,
bool disableConsole, int maxConnections, NitroxVersion nitroxVersionAllowed) : base(correlationId)
{
RequiresServerPassword = requiresServerPassword;
AuthenticationAuthority = authenticationAuthority;
DisableConsole = disableConsole;
MaxConnections = maxConnections;
NitroxVersionAllowed = nitroxVersionAllowed;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets
{
/// <summary>
/// This is a packet that we use to "ping" a server to let it know that we'd like more information
/// on the current requirements to submit a reservation to the ongoing game session.
/// </summary>
[Serializable]
public class MultiplayerSessionPolicyRequest : CorrelatedPacket
{
public MultiplayerSessionPolicyRequest(string correlationId) : base(correlationId)
{
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using NitroxModel.MultiplayerSession;
namespace NitroxModel.Packets
{
[Serializable]
public class MultiplayerSessionReservation : CorrelatedPacket
{
public ushort PlayerId { get; }
public string ReservationKey { get; }
public MultiplayerSessionReservationState ReservationState { get; }
public MultiplayerSessionReservation(string correlationId, MultiplayerSessionReservationState reservationState) : base(correlationId)
{
ReservationState = reservationState;
}
public MultiplayerSessionReservation(string correlationId, ushort playerId, string reservationKey,
MultiplayerSessionReservationState reservationState = MultiplayerSessionReservationState.RESERVED) : this(correlationId, reservationState)
{
PlayerId = playerId;
ReservationKey = reservationKey;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.MultiplayerSession;
namespace NitroxModel.Packets
{
[Serializable]
public class MultiplayerSessionReservationRequest : CorrelatedPacket
{
public PlayerSettings PlayerSettings { get; }
public AuthenticationContext AuthenticationContext { get; }
public MultiplayerSessionReservationRequest(string correlationId, PlayerSettings playerSettings, AuthenticationContext authenticationContext) : base(correlationId)
{
PlayerSettings = playerSettings;
AuthenticationContext = authenticationContext;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class MutePlayer : Packet
{
public ushort PlayerId;
public bool Muted;
public MutePlayer(ushort playerId, bool muted)
{
PlayerId = playerId;
Muted = muted;
}
}

View File

@@ -0,0 +1,20 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets
{
[Serializable]
public class OpenableStateChanged : Packet
{
public NitroxId Id { get; }
public bool IsOpen { get; }
public float Duration { get; }
public OpenableStateChanged(NitroxId id, bool isOpen, float duration)
{
Id = id;
IsOpen = isOpen;
Duration = duration;
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public abstract class OrderedBuildPacket : Packet
{
public int OperationId { get; set; }
protected OrderedBuildPacket(int operationId)
{
OperationId = operationId;
}
}

View File

@@ -0,0 +1,19 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class PDAEncyclopediaEntryAdd : Packet
{
public string Key { get; }
/// <summary>
/// If true, shows a notification to the player.
/// </summary>
public bool Verbose { get; }
public PDAEncyclopediaEntryAdd(string key, bool verbose)
{
Key = key;
Verbose = verbose;
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class PDALogEntryAdd : Packet
{
public string Key { get; }
public float Timestamp { get; }
public PDALogEntryAdd(string key, float timestamp)
{
Key = key;
Timestamp = timestamp;
}
}

View File

@@ -0,0 +1,26 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets;
[Serializable]
public class PDAScanFinished : Packet
{
public NitroxId Id { get; }
public NitroxTechType TechType { get; }
public int UnlockedAmount { get; }
public bool FullyResearched { get; }
public bool Destroy { get; }
public bool WasAlreadyResearched { get; }
public PDAScanFinished(NitroxId id, NitroxTechType techType, int unlockedAmount, bool fullyResearched, bool destroy, bool wasAlreadyResearched = false)
{
Id = id;
TechType = techType;
UnlockedAmount = unlockedAmount;
FullyResearched = fullyResearched;
Destroy = destroy;
WasAlreadyResearched = wasAlreadyResearched;
}
}

View File

@@ -0,0 +1,144 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using BinaryPack;
using BinaryPack.Attributes;
using NitroxModel.Networking;
namespace NitroxModel.Packets
{
[Serializable]
public abstract class Packet
{
private static readonly Dictionary<Type, PropertyInfo[]> cachedPropertiesByType = new();
private static readonly StringBuilder toStringBuilder = new();
private static readonly object lockObject = new();
public static void InitSerializer()
{
static IEnumerable<Type> FindTypesInModelAssemblies()
{
return AppDomain.CurrentDomain.GetAssemblies()
.Where(assembly => new[] { nameof(NitroxModel), "NitroxModel-Subnautica" }
.Contains(assembly.GetName().Name))
.SelectMany(assembly =>
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
}
});
}
static IEnumerable<Type> FindUnionBaseTypes() => FindTypesInModelAssemblies()
.Where(t => t.IsAbstract && !t.IsSealed && (!t.BaseType?.IsAbstract ?? true) && !t.ContainsGenericParameters);
lock (lockObject)
{
foreach (Type type in FindUnionBaseTypes())
{
BinaryConverter.RegisterUnion(type, FindTypesInModelAssemblies()
.Where(t => type.IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface)
.OrderByDescending(t =>
{
Type current = t;
int levels = 0;
while (current != type && current != null)
{
current = current.BaseType;
levels++;
}
return levels;
})
.ThenBy(t => t.FullName, StringComparer.Ordinal)
.ToArray());
}
// This will initialize the processor for Wrapper which will initialize all the others
_ = BinaryConverter.Serialize(new Wrapper());
}
}
[IgnoredMember]
public NitroxDeliveryMethod.DeliveryMethod DeliveryMethod { get; protected set; } = NitroxDeliveryMethod.DeliveryMethod.RELIABLE_ORDERED;
[IgnoredMember]
public UdpChannelId UdpChannel { get; protected set; } = UdpChannelId.DEFAULT;
public enum UdpChannelId : byte
{
DEFAULT = 0,
MOVEMENTS = 1,
}
public byte[] Serialize()
{
return BinaryConverter.Serialize(new Wrapper(this));
}
public static Packet Deserialize(byte[] data)
{
return BinaryConverter.Deserialize<Wrapper>(data).Packet;
}
public override string ToString()
{
Type packetType = GetType();
if (!cachedPropertiesByType.TryGetValue(packetType, out PropertyInfo[] properties))
{
properties = packetType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(x => x.Name is not nameof(DeliveryMethod) and not nameof(UdpChannel)).ToArray();
cachedPropertiesByType.Add(packetType, properties);
}
toStringBuilder.Clear();
toStringBuilder.Append($"[{packetType.Name}: ");
foreach (PropertyInfo property in properties)
{
object propertyValue = property.GetValue(this);
if (propertyValue is IList propertyList)
{
toStringBuilder.Append($"{property.Name}: {propertyList.Count}, ");
}
else
{
toStringBuilder.Append($"{property.Name}: {propertyValue}, ");
}
}
toStringBuilder.Remove(toStringBuilder.Length - 2, 2);
toStringBuilder.Append(']');
return toStringBuilder.ToString();
}
/// <summary>
/// Wrapper which is used to serialize packets in BinaryPack.
/// We cannot serialize Packets directly because
/// <p>
/// 1) We will not know what type to deserialize to and
/// 2) The root object must have a callable constructor so it can't be abstract
/// </p>
/// This type solves both problems and only adds a single byte to the data.
/// </summary>
public readonly struct Wrapper
{
public Packet Packet { get; init; } = null;
public Wrapper(Packet packet)
{
Packet = packet;
}
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets;
[Serializable]
public class PermsChanged : Packet
{
public Perms NewPerms;
public PermsChanged(Perms newPerms)
{
NewPerms = newPerms;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures.GameLogic.Entities;
namespace NitroxModel.Packets;
[Serializable]
public class PickupItem : Packet
{
public InventoryItemEntity Item { get; }
public PickupItem(InventoryItemEntity item)
{
Item = item;
}
}

View File

@@ -0,0 +1,25 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Bases;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public class PieceDeconstructed : OrderedBuildPacket
{
public NitroxId BaseId { get; }
public NitroxId PieceId { get; }
public BuildPieceIdentifier BuildPieceIdentifier { get; }
public GhostEntity ReplacerGhost { get; }
public BaseData BaseData { get; set; }
public PieceDeconstructed(NitroxId baseId, NitroxId pieceId, BuildPieceIdentifier buildPieceIdentifier, GhostEntity replacerGhost, BaseData baseData, int operationId) : base(operationId)
{
BaseId = baseId;
PieceId = pieceId;
BuildPieceIdentifier = buildPieceIdentifier;
ReplacerGhost = replacerGhost;
BaseData = baseData;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace NitroxModel.Packets;
[Serializable]
public class PinnedRecipeMoved : Packet
{
public List<int> RecipePins { get; }
public PinnedRecipeMoved(List<int> recipePins)
{
RecipePins = recipePins;
}
}

View File

@@ -0,0 +1,23 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class PlaceBase : Packet
{
public NitroxId FormerGhostId { get; }
public BuildEntity BuildEntity { get; set; }
public PlaceBase(NitroxId formerGhostId, BuildEntity buildEntity)
{
FormerGhostId = formerGhostId;
BuildEntity = buildEntity;
}
public void Deflate()
{
BuildEntity = null;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class PlaceGhost : Packet
{
public GhostEntity GhostEntity { get; }
public PlaceGhost(GhostEntity ghostEntity)
{
GhostEntity = ghostEntity;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures.GameLogic.Entities.Bases;
namespace NitroxModel.Packets;
[Serializable]
public sealed class PlaceModule : Packet
{
public ModuleEntity ModuleEntity { get; }
public PlaceModule(ModuleEntity moduleEntity)
{
ModuleEntity = moduleEntity;
}
}

View File

@@ -0,0 +1,33 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class PlaySunbeamEvent : Packet
{
public string EventKey { get; }
public PlaySunbeamEvent(string eventKey)
{
EventKey = eventKey;
}
/// <summary>
/// Associates an understandable event name and the associated goal from <see cref="SunbeamGoals" />.
/// </summary>
public static class SunbeamEvent
{
public const string STORYSTART = "RadioSunbeamStart";
public const string COUNTDOWN = "OnPlayRadioSunbeam4";
public const string GUNAIM = "PrecursorGunAimCheck";
}
/// <summary>
/// An ordered list of the goals forming part of the whole Sunbeam story.
/// </summary>
/// <remarks>
/// If you modify this list, make sure to accordingly modify <see cref="SunbeamEvent"/>.
/// </remarks>
[NonSerialized]
public static readonly string[] SunbeamGoals = new string[] { SunbeamEvent.STORYSTART, "OnPlayRadioSunbeamStart", "RadioSunbeam1", "OnPlayRadioSunbeam1", "RadioSunbeam2", "OnPlayRadioSunbeam2", "RadioSunbeam3", "OnPlayRadioSunbeam3", "RadioSunbeam4", SunbeamEvent.COUNTDOWN, SunbeamEvent.GUNAIM, "PrecursorGunAim", "SunbeamCheckPlayerRange", "PDASunbeamDestroyEventOutOfRange", "PDASunbeamDestroyEventInRange" };
}

View File

@@ -0,0 +1,23 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerCinematicControllerCall : Packet
{
public ushort PlayerId { get; }
public NitroxId ControllerID { get; }
public int ControllerNameHash { get; }
public string Key { get; }
public bool StartPlaying { get; }
public PlayerCinematicControllerCall(ushort playerId, NitroxId controllerID, int controllerNameHash, string key, bool startPlaying)
{
PlayerId = playerId;
ControllerID = controllerID;
ControllerNameHash = controllerNameHash;
Key = key;
StartPlaying = startPlaying;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerDeathEvent : Packet
{
public ushort PlayerId { get; }
public NitroxVector3 DeathPosition { get; }
public PlayerDeathEvent(ushort playerId, NitroxVector3 deathPosition)
{
PlayerId = playerId;
DeathPosition = deathPosition;
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerHeldItemChanged : Packet
{
public ushort PlayerId { get; }
public NitroxId ItemId { get; }
public ChangeType Type { get; }
public NitroxTechType IsFirstTime { get; } // If it's the first time the player used that item type it send the techType, if not null.
public PlayerHeldItemChanged(ushort playerId, NitroxId itemId, ChangeType type, NitroxTechType isFirstTime)
{
PlayerId = playerId;
ItemId = itemId;
Type = type;
IsFirstTime = isFirstTime;
}
public enum ChangeType
{
DRAW_AS_TOOL,
DRAW_AS_ITEM,
HOLSTER_AS_TOOL,
HOLSTER_AS_ITEM
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using NitroxModel.DataStructures.Unity;
using NitroxModel.Networking;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerInCyclopsMovement : Packet
{
public ushort PlayerId { get; }
public NitroxVector3 LocalPosition { get; }
public NitroxQuaternion LocalRotation { get; }
public PlayerInCyclopsMovement(ushort playerId, NitroxVector3 localPosition, NitroxQuaternion localRotation)
{
PlayerId = playerId;
LocalPosition = localPosition;
LocalRotation = localRotation;
DeliveryMethod = NitroxDeliveryMethod.DeliveryMethod.UNRELIABLE_SEQUENCED;
UdpChannel = UdpChannelId.MOVEMENTS;
}
}

View File

@@ -0,0 +1,22 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic.Entities;
using NitroxModel.DataStructures.Util;
using NitroxModel.MultiplayerSession;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerJoinedMultiplayerSession : Packet
{
public PlayerContext PlayerContext { get; }
public Optional<NitroxId> SubRootId { get; }
public PlayerWorldEntity PlayerWorldEntity { get; }
public PlayerJoinedMultiplayerSession(PlayerContext playerContext, Optional<NitroxId> subRootId, PlayerWorldEntity playerWorldEntity)
{
PlayerContext = playerContext;
SubRootId = subRootId;
PlayerWorldEntity = playerWorldEntity;
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerJoiningMultiplayerSession : CorrelatedPacket
{
public string ReservationKey { get; }
public PlayerJoiningMultiplayerSession(string correlationId, string reservationKey) : base(correlationId)
{
CorrelationId = correlationId;
ReservationKey = reservationKey;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerKicked : Packet
{
public string Reason { get; }
public PlayerKicked(string reason)
{
Reason = reason;
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using NitroxModel.DataStructures.Unity;
using NitroxModel.Networking;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerMovement : Movement
{
public override ushort PlayerId { get; }
public override NitroxVector3 Position { get; }
public override NitroxVector3 Velocity { get; }
public override NitroxQuaternion BodyRotation { get; }
public override NitroxQuaternion AimingRotation { get; }
public PlayerMovement(ushort playerId, NitroxVector3 position, NitroxVector3 velocity, NitroxQuaternion bodyRotation, NitroxQuaternion aimingRotation)
{
PlayerId = playerId;
Position = position;
Velocity = velocity;
BodyRotation = bodyRotation;
AimingRotation = aimingRotation;
DeliveryMethod = NitroxDeliveryMethod.DeliveryMethod.UNRELIABLE_SEQUENCED;
UdpChannel = UdpChannelId.MOVEMENTS;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Util;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerQuickSlotsBindingChanged : Packet
{
public Optional<NitroxId>[] SlotItemIds { get; }
public PlayerQuickSlotsBindingChanged(Optional<NitroxId>[] slotItemIds)
{
SlotItemIds = slotItemIds;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerSeeOutOfCellEntity : Packet
{
public NitroxId EntityId { get; set; }
public PlayerSeeOutOfCellEntity(NitroxId entityId)
{
EntityId = entityId;
}
}

View File

@@ -0,0 +1,29 @@
using System;
using NitroxModel.Networking;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerStats : Packet
{
public ushort PlayerId { get; set; }
public float Oxygen { get; }
public float MaxOxygen { get; }
public float Health { get; }
public float Food { get; }
public float Water { get; }
public float InfectionAmount { get; }
public PlayerStats(ushort playerId, float oxygen, float maxOxygen, float health, float food, float water, float infectionAmount)
{
PlayerId = playerId;
Oxygen = oxygen;
MaxOxygen = maxOxygen;
Health = health;
Food = food;
Water = water;
InfectionAmount = infectionAmount;
DeliveryMethod = NitroxDeliveryMethod.DeliveryMethod.RELIABLE_ORDERED_LAST;
}
}

View File

@@ -0,0 +1,13 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerSyncFinished : Packet
{
public PlayerSyncFinished()
{
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
using NitroxModel.DataStructures.Util;
namespace NitroxModel.Packets
{
[Serializable]
public class PlayerTeleported : Packet
{
public string PlayerName { get; }
public NitroxVector3 DestinationFrom { get; }
public NitroxVector3 DestinationTo { get; }
public Optional<NitroxId> SubRootID { get; }
public PlayerTeleported(string playerName, NitroxVector3 destinationFrom, NitroxVector3 destinationTo, Optional<NitroxId> subRootID)
{
PlayerName = playerName;
DestinationFrom = destinationFrom;
DestinationTo = destinationTo;
SubRootID = subRootID;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class PlayerUnseeOutOfCellEntity : Packet
{
public NitroxId EntityId { get; set; }
public PlayerUnseeOutOfCellEntity(NitroxId entityId)
{
EntityId = entityId;
}
}

View File

@@ -0,0 +1,6 @@
namespace NitroxModel.Packets.Processors.Abstract
{
public interface IProcessorContext
{
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace NitroxModel.Packets.Processors.Abstract
{
public abstract class PacketProcessor
{
public abstract void ProcessPacket(Packet packet, IProcessorContext context);
public static Dictionary<Type, PacketProcessor> GetProcessors(Dictionary<Type, object> processorArguments, Func<Type, bool> additionalConstraints)
{
return Assembly.GetCallingAssembly()
.GetTypes()
.Where(p => typeof(PacketProcessor).IsAssignableFrom(p) && p.IsClass && !p.IsAbstract)
.Where(additionalConstraints)
.ToDictionary(proc => proc.BaseType.GetGenericArguments()[0], proc =>
{
ConstructorInfo[] ctors = proc.GetConstructors();
if (ctors.Length > 1)
{
throw new NotSupportedException($"{proc.Name} has more than one constructor!");
}
ConstructorInfo ctor = ctors.First();
// Prepare arguments for constructor (if applicable):
object[] args = ctor.GetParameters().Select(pi =>
{
if (processorArguments.TryGetValue(pi.ParameterType, out object v))
{
return v;
}
throw new ArgumentException($"Argument value not defined for type {pi.ParameterType}! Used in {proc}");
}).ToArray();
return (PacketProcessor)ctor.Invoke(args);
});
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class PvPAttack : Packet
{
public ushort TargetPlayerId { get; }
public float Damage { get; set; }
public AttackType Type { get; }
public PvPAttack(ushort targetPlayerId, float damage, AttackType type)
{
TargetPlayerId = targetPlayerId;
Damage = damage;
Type = type;
}
public enum AttackType : byte
{
KnifeHit,
HeatbladeHit
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class RadioPlayPendingMessage : Packet
{
}
}

View File

@@ -0,0 +1,27 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class RangedAttackLastTargetUpdate : Packet
{
public NitroxId CreatureId { get; }
public NitroxId TargetId { get; }
public int AttackTypeIndex { get; }
public ActionState State { get; }
public RangedAttackLastTargetUpdate(NitroxId creatureId, NitroxId targetId, int attackTypeIndex, ActionState state)
{
CreatureId = creatureId;
TargetId = targetId;
AttackTypeIndex = attackTypeIndex;
State = state;
}
public enum ActionState
{
CHARGING,
CASTING
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class RecipePinned : Packet
{
public int TechType { get; }
public bool Pinned { get; }
public RecipePinned(int techType, bool pinned)
{
TechType = techType;
Pinned = pinned;
}
}

View File

@@ -0,0 +1,20 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public class RemoveCreatureCorpse : Packet
{
public NitroxId CreatureId { get; }
public NitroxVector3 DeathPosition { get; }
public NitroxQuaternion DeathRotation { get; }
public RemoveCreatureCorpse(NitroxId creatureId, NitroxVector3 deathPosition, NitroxQuaternion deathRotation)
{
CreatureId = creatureId;
DeathPosition = deathPosition;
DeathRotation = deathRotation;
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class Schedule : Packet
{
public float TimeExecute { get; }
public string Key { get; }
public int Type { get; }
public Schedule(float timeExecute, string key, int type)
{
TimeExecute = timeExecute;
Key = key;
Type = type;
}
}

View File

@@ -0,0 +1,19 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class SeaDragonAttackTarget : Packet
{
public NitroxId SeaDragonId { get; }
public NitroxId TargetId { get; }
public float Aggression { get; }
public SeaDragonAttackTarget(NitroxId seaDragonId, NitroxId targetId, float aggression)
{
SeaDragonId = seaDragonId;
TargetId = targetId;
Aggression = aggression;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class SeaDragonGrabExosuit : Packet
{
public NitroxId SeaDragonId { get; }
public NitroxId TargetId { get; }
public SeaDragonGrabExosuit(NitroxId seaDragonId, NitroxId targetId)
{
SeaDragonId = seaDragonId;
TargetId = targetId;
}
}

View File

@@ -0,0 +1,21 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class SeaDragonSwatAttack : Packet
{
public NitroxId SeaDragonId { get; }
public NitroxId TargetId { get; }
public bool IsRightHand { get; }
public float Aggression { get; }
public SeaDragonSwatAttack(NitroxId seaDragonId, NitroxId targetId, bool isRightHand, float aggression)
{
SeaDragonId = seaDragonId;
TargetId = targetId;
IsRightHand = isRightHand;
Aggression = aggression;
}
}

View File

@@ -0,0 +1,15 @@
using System;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets;
[Serializable]
public class SeaTreaderChunkPickedUp : Packet
{
public NitroxId ChunkId { get; }
public SeaTreaderChunkPickedUp(NitroxId chunkId)
{
ChunkId = chunkId;
}
}

View File

@@ -0,0 +1,22 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets;
[Serializable]
public class SeaTreaderSpawnedChunk : Packet
{
public NitroxId CreatureId { get; }
public NitroxId ChunkId { get; }
public NitroxVector3 Position { get; }
public NitroxQuaternion Rotation { get; }
public SeaTreaderSpawnedChunk(NitroxId creatureId, NitroxId chunkId, NitroxVector3 position, NitroxQuaternion rotation)
{
CreatureId = creatureId;
ChunkId = chunkId;
Position = position;
Rotation = rotation;
}
}

View File

@@ -0,0 +1,26 @@
using System;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic;
using NitroxModel.DataStructures.Unity;
namespace NitroxModel.Packets
{
[Serializable]
public class SeamothModulesAction : Packet
{
public NitroxTechType TechType { get; }
public int SlotID { get; }
public NitroxId Id { get; }
public NitroxVector3 Forward { get; }
public NitroxQuaternion Rotation { get; }
public SeamothModulesAction(NitroxTechType techType, int slotID, NitroxId id, NitroxVector3 forward, NitroxQuaternion rotation)
{
TechType = techType;
SlotID = slotID;
Id = id;
Forward = forward;
Rotation = rotation;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
namespace NitroxModel.Packets
{
[Serializable]
public class ServerCommand : Packet
{
public string Cmd { get; }
public ServerCommand(string cmd)
{
Cmd = cmd;
}
public ServerCommand(string[] cmdArgs)
{
Cmd = string.Join(" ", cmdArgs);
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class ServerStopped : Packet
{
}

View File

@@ -0,0 +1,26 @@
using System;
using NitroxModel.DataStructures.GameLogic;
namespace NitroxModel.Packets;
[Serializable]
public class SetIntroCinematicMode : Packet
{
public ushort PlayerId { get; }
public IntroCinematicMode Mode { get; }
public ushort? PartnerId { get; set; }
public SetIntroCinematicMode(ushort playerId, IntroCinematicMode mode)
{
PlayerId = playerId;
Mode = mode;
PartnerId = null;
}
public SetIntroCinematicMode(ushort playerId, IntroCinematicMode mode, ushort? partnerId)
{
PlayerId = playerId;
Mode = mode;
PartnerId = partnerId;
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace NitroxModel.Packets;
[Serializable]
public class SignalPingPreferenceChanged : Packet
{
public string PingKey { get; }
public bool Visible { get; }
public int Color { get; }
public SignalPingPreferenceChanged(string pingKey, bool visible, int color)
{
PingKey = pingKey;
Visible = visible;
Color = color;
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using NitroxModel.DataStructures;
namespace NitroxModel.Packets
{
[Serializable]
public class SimulationOwnershipChange : Packet
{
public List<SimulatedEntity> Entities { get; }
public SimulationOwnershipChange(NitroxId id, ushort owningPlayerId, SimulationLockType lockType, bool changesPosition = false)
{
Entities = new List<SimulatedEntity>
{
new(id, owningPlayerId, changesPosition, lockType)
};
}
public SimulationOwnershipChange(SimulatedEntity entity)
{
Entities = new List<SimulatedEntity>
{
entity
};
}
public SimulationOwnershipChange(List<SimulatedEntity> entities)
{
Entities = entities;
}
}
}

Some files were not shown because too many files have changed in this diff Show More