-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent grabbing another player with propulsion cannon, fix teleporta…
…tion to another player, fix wrong cyclops detection by leviathans (too short), persist leash position of leviathans so they don't derive away from their original spawn position indefinitely, fix leviathans not spawning when they get close to a player who has them in range
- Loading branch information
1 parent
80dcff9
commit 6d08896
Showing
22 changed files
with
448 additions
and
51 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
NitroxClient/Communication/Packets/Processors/DropSimulationOwnershipProcessor.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,20 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.GameLogic; | ||
using NitroxModel.Packets; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class DropSimulationOwnershipProcessor : ClientPacketProcessor<DropSimulationOwnership> | ||
{ | ||
private readonly SimulationOwnership simulationOwnershipManager; | ||
|
||
public DropSimulationOwnershipProcessor(SimulationOwnership simulationOwnershipManager) | ||
{ | ||
this.simulationOwnershipManager = simulationOwnershipManager; | ||
} | ||
|
||
public override void Process(DropSimulationOwnership packet) | ||
{ | ||
simulationOwnershipManager.DropSimulationFrom(packet.EntityId); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
NitroxClient/GameLogic/Spawning/Metadata/Processor/StayAtLeashPositionMetadataProcessor.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,26 @@ | ||
using NitroxClient.GameLogic.Spawning.Metadata.Processor.Abstract; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Metadata.Processor; | ||
|
||
public class StayAtLeashPositionMetadataProcessor : EntityMetadataProcessor<StayAtLeashPositionMetadata> | ||
{ | ||
public override void ProcessMetadata(GameObject gameObject, StayAtLeashPositionMetadata metadata) | ||
{ | ||
if (!gameObject.TryGetComponent(out Creature creature)) | ||
{ | ||
Log.Error($"Could not find {nameof(Creature)} on {gameObject.name}"); | ||
return; | ||
} | ||
|
||
if (!creature.isInitialized) | ||
{ | ||
// TODO: When #2137 is merged, only a MetadataHolder to the creature and postfix patch creature.Start to consume it | ||
creature.InitializeOnce(); | ||
creature.isInitialized = true; | ||
} | ||
creature.leashPosition = metadata.LeashPosition.ToUnity(); | ||
} | ||
} |
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,59 @@ | ||
using NitroxClient.Communication.Abstract; | ||
using NitroxClient.GameLogic; | ||
using NitroxModel.DataStructures; | ||
using NitroxModel.Packets; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.MonoBehaviours; | ||
|
||
/// <summary> | ||
/// Entities might move slightly out of the loaded zone, in which case the server thinks that they're in another cell | ||
/// (because the cell is only determined by the entity's position). Thus we need to be able to know when this entity is unloaded | ||
/// and broadcast this event so the server can switch the ownership from it. | ||
/// </summary> | ||
public class OutOfCellEntity : MonoBehaviour | ||
{ | ||
private bool manuallyDestroyed; | ||
private NitroxId nitroxId; | ||
|
||
private SimulationOwnership SimulationOwnership => this.Resolve<SimulationOwnership>(); | ||
|
||
public void Init(NitroxId nitroxId) | ||
{ | ||
this.nitroxId = nitroxId; | ||
} | ||
|
||
/// <remarks> | ||
/// Once an entity out of cell is "free" from simulation ownership, we need to ask the server to lock it since we don't have | ||
/// it's actual cell loaded (from position) | ||
/// </remarks> | ||
public void TryClaim() | ||
{ | ||
SimulationOwnership.RequestSimulationLock(nitroxId, SimulationLockType.TRANSIENT); | ||
} | ||
|
||
/// <summary> | ||
/// Remove the component without triggering the entity unload broadcast | ||
/// </summary> | ||
public void ManuallyDestroy() | ||
{ | ||
manuallyDestroyed = true; | ||
Destroy(this); | ||
} | ||
|
||
public void OnDestroy() | ||
{ | ||
if (manuallyDestroyed) | ||
{ | ||
return; | ||
} | ||
|
||
// We check for IsAlive because we don't want to broadcast this when the entity was killed (it's managed in another way) | ||
if (TryGetComponent(out LiveMixin liveMixin) && liveMixin.IsAlive() && SimulationOwnership.HasAnyLockType(nitroxId)) | ||
{ | ||
SimulationOwnership.StopSimulatingEntity(nitroxId); | ||
EntityPositionBroadcaster.StopWatchingEntity(nitroxId); | ||
this.Resolve<IPacketSender>().Send(new DropSimulationOwnership(nitroxId)); | ||
} | ||
} | ||
} |
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,23 +1,27 @@ | ||
using NitroxClient.GameLogic; | ||
using NitroxClient.GameLogic; | ||
using NitroxModel.Core; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.MonoBehaviours | ||
namespace NitroxClient.MonoBehaviours; | ||
|
||
public class PlayerDeathBroadcaster : MonoBehaviour | ||
{ | ||
public class PlayerDeathBroadcaster : MonoBehaviour | ||
private LocalPlayer localPlayer; | ||
|
||
public void Awake() | ||
{ | ||
private LocalPlayer localPlayer; | ||
localPlayer = NitroxServiceLocator.LocateService<LocalPlayer>(); | ||
|
||
public void Awake() | ||
{ | ||
localPlayer = NitroxServiceLocator.LocateService<LocalPlayer>(); | ||
Player.main.playerDeathEvent.AddHandler(this, PlayerDeath); | ||
} | ||
|
||
Player.main.playerDeathEvent.AddHandler(this, PlayerDeath); | ||
} | ||
private void PlayerDeath(Player player) | ||
{ | ||
localPlayer.BroadcastDeath(player.transform.position); | ||
} | ||
|
||
private void PlayerDeath(Player player) | ||
{ | ||
localPlayer.BroadcastDeath(player.transform.position); | ||
} | ||
public void OnDestroy() | ||
{ | ||
Player.main.playerDeathEvent.RemoveHandler(this, PlayerDeath); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
NitroxModel/DataStructures/GameLogic/Entities/Metadata/StayAtLeashPositionMetadata.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,29 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using BinaryPack.Attributes; | ||
using NitroxModel.DataStructures.Unity; | ||
|
||
namespace NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
|
||
[Serializable, DataContract] | ||
public class StayAtLeashPositionMetadata : EntityMetadata | ||
{ | ||
[DataMember(Order = 1)] | ||
public NitroxVector3 LeashPosition { get; } | ||
|
||
[IgnoreConstructor] | ||
protected StayAtLeashPositionMetadata() | ||
{ | ||
// Constructor for serialization. Has to be "protected" for json serialization. | ||
} | ||
|
||
public StayAtLeashPositionMetadata(NitroxVector3 leashPosition) | ||
{ | ||
LeashPosition = leashPosition; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"[{nameof(StayAtLeashPositionMetadata)} LeashPosition: {LeashPosition}]"; | ||
} | ||
} |
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,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; | ||
} | ||
} |
Oops, something went wrong.