-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Death markers setting #2253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Death markers setting #2253
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
4f8d334
Added boilerplate for DeathMarkers setting
OhmV-IR 9c528c4
Create beacons on all clients
OhmV-IR aa32a3d
Fix syntax error
OhmV-IR bc433fe
Shift to using the existing PlayerDeathEvent packet to trigger the be…
OhmV-IR 46618e4
Make death beacons player exclusive(only spawns for the player that t…
OhmV-IR 887fc59
Disconnecting also despawns all active death beacons
OhmV-IR c309ada
Fix death beacons getting synced to other players and not disappearin…
OhmV-IR 68a3130
Remove unnecessary logging
OhmV-IR 90822ec
Remove unnecessary method, various semantic updates to prep for PR
OhmV-IR b12d092
Fixed a random import that was accidentally added
OhmV-IR c6ad6ef
Update NitroxServer/ConsoleCommands/SetDeathMarkersCommand.cs
OhmV-IR 54596ac
Fixed deathbeacons on land
OhmV-IR 30ab97a
Switch to using blank gameobjects instead of actual beacons
OhmV-IR c20ea8c
Added missing using
OhmV-IR e231019
Removed unneeded changes
OhmV-IR 481dc6a
Moved DeathBeacon class to its own file
OhmV-IR d631a82
changed field to const and named deathbeacon GO
OhmV-IR 48e7a6d
Use InvokeRepeating and sqrMagnitude to check distances for better pe…
OhmV-IR afaf90f
Add translation string for death beacon label
OhmV-IR 4968b3e
implement various code review requsted changes
OhmV-IR 0ccbe3f
Fix error in building
OhmV-IR f20e5e0
Add beacon fade out
OhmV-IR 47c5829
Fixed add and sort usings, as well as added a whitespace
OhmV-IR 3b4f648
set DeathMarkers setting to true by default
OhmV-IR 4f9fa44
Fix DeathMarkers for NitroxLauncher(tested in-game for this commit)
OhmV-IR 74beffe
Added missing namespace declaration
OhmV-IR 99d9ce4
Moved spawning of death beacon to PlayerDeath in PlayerDeathBroadcaster
OhmV-IR 870f6a6
Update NitroxModel/Packets/DeathMarkersChanged.cs
OhmV-IR a03e883
Update NitroxServer/ConsoleCommands/SetDeathMarkersCommand.cs
OhmV-IR 120fa35
Add newline between namespace and class
OhmV-IR a52d626
Merge branch 'DeathMarkers' of https://github.com/OhmV-IR/NitroxModde…
OhmV-IR 5262c91
Fix missing import
OhmV-IR b63420f
change setdeathmarkers to deathmarkers cmd name
OhmV-IR 04bb00a
merge master
a3d305c
Merge branch 'master' into DeathMarkers
74a6a63
make it build
d38172b
Merge master
OhmV-IR ce46f89
Adapt to refactors (make it compile)
OhmV-IR d49e0d2
fix logic error
OhmV-IR 915dfa6
DeathBeacon code cleanup
Measurity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 Nitrox.Model.Packets; | ||
|
|
||
| namespace NitroxModel.Packets; | ||
|
|
||
| [Serializable] | ||
| public class DeathMarkersChanged : Packet | ||
| { | ||
| public bool MarkDeathPointsWithBeacon { get; } | ||
|
|
||
| public DeathMarkersChanged(bool markDeathPointsWithBeacon) | ||
| { | ||
| MarkDeathPointsWithBeacon = markDeathPointsWithBeacon; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
Nitrox.Server.Subnautica/Models/Commands/DeathMarkerCommand.cs
This file contains hidden or 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,25 @@ | ||
| using System.ComponentModel; | ||
| using Nitrox.Model.DataStructures.GameLogic; | ||
| using Nitrox.Server.Subnautica.Models.Commands.Core; | ||
| using NitroxModel.Packets; | ||
|
|
||
| namespace Nitrox.Server.Subnautica.Models.Commands; | ||
|
|
||
| [RequiresPermission(Perms.ADMIN)] | ||
| internal sealed class DeathMarkerCommand(IOptions<SubnauticaServerOptions> options) : ICommandHandler<bool> | ||
| { | ||
| private readonly IOptions<SubnauticaServerOptions> options = options; | ||
|
|
||
| [Description("Sets \"death markers\" setting to on/off. If \"on\", a beacon will be placed when a player dies at the location of the death.")] | ||
| public async Task Execute(ICommandContext context, [Description("The true/false state to set the death markers setting to")] bool newState) | ||
| { | ||
| if (options.Value.MarkDeathPointsWithBeacon == newState) | ||
| { | ||
| await context.ReplyAsync($"{nameof(options.Value.MarkDeathPointsWithBeacon)} already set to {newState}"); | ||
| return; | ||
| } | ||
| options.Value.MarkDeathPointsWithBeacon = newState; | ||
| await context.SendToAllAsync(new DeathMarkersChanged(newState)); | ||
| await context.SendToAllAsync($"{nameof(options.Value.MarkDeathPointsWithBeacon)} changed to \"{newState}\" by {context}"); | ||
| } | ||
| } |
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
NitroxClient/Communication/MultiplayerSession/ConnectionState/CommunicatingState.cs
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
NitroxClient/Communication/Packets/Processors/DeathMarkersChangedProcessor.cs
This file contains hidden or 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,16 @@ | ||
| using NitroxClient.Communication.Packets.Processors.Core; | ||
| using NitroxClient.GameLogic; | ||
| using NitroxModel.Packets; | ||
|
|
||
| namespace NitroxClient.Communication.Packets.Processors; | ||
|
|
||
| internal sealed class DeathMarkersChangedProcessor(LocalPlayer localPlayer) : IClientPacketProcessor<DeathMarkersChanged> | ||
| { | ||
| private readonly LocalPlayer localPlayer = localPlayer; | ||
|
|
||
| public Task Process(ClientProcessorContext context, DeathMarkersChanged packet) | ||
| { | ||
| localPlayer.MarkDeathPointsWithBeacon = packet.MarkDeathPointsWithBeacon; | ||
| return Task.CompletedTask; | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
NitroxClient/Communication/Packets/Processors/PlayerDeathProcessor.cs
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
| namespace NitroxClient.Extensions; | ||
|
|
||
| internal static class PingInstanceExtensions | ||
| { | ||
| extension(PingInstance self) | ||
| { | ||
| /// <summary> | ||
| /// If true, ping instance should not be synchronized to remote players. | ||
| /// </summary> | ||
| public bool IsLocalOnly | ||
| { | ||
| set => self._id = "local"; | ||
| get => self._id == "local"; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| using Nitrox.Model.DataStructures.Unity; | ||
| using UnityEngine; | ||
|
|
||
| namespace NitroxClient.MonoBehaviours.Gui.InGame; | ||
|
|
||
| /// <summary> | ||
| /// Related to DeathMarker server setting. | ||
| /// </summary> | ||
| internal sealed class DeathBeacon : MonoBehaviour | ||
| { | ||
| private const float DESPAWN_DISTANCE = 20f; | ||
|
|
||
| private void OnTriggerEnter(Collider collider) | ||
| { | ||
| if (!collider.gameObject.IsLocalPlayer) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| Log.Debug($"{nameof(DeathBeacon)} '{name}' despawn trigger entered by {collider.name}"); | ||
| Destroy(gameObject); | ||
| } | ||
|
|
||
| public static void SpawnDeathBeacon(NitroxVector3 location, string playerName) | ||
| { | ||
| GameObject beacon = new($"{playerName}{nameof(DeathBeacon)}"); | ||
|
dartasen marked this conversation as resolved.
|
||
| beacon.transform.position = location.ToUnity(); | ||
| beacon.layer = LayerID.Trigger | LayerID.OnlyVehicle; | ||
| beacon.AddComponent<DeathBeacon>(); | ||
| PingInstance signal = beacon.AddComponent<PingInstance>(); | ||
| signal.IsLocalOnly = true; | ||
| signal.pingType = PingType.Signal; | ||
| signal.origin = beacon.transform; | ||
|
OhmV-IR marked this conversation as resolved.
|
||
| signal.minDist = DESPAWN_DISTANCE + 15f; | ||
| signal._label = Language.main.Get("Nitrox_PlayerDeathBeaconLabel").Replace("{PLAYER}", playerName); | ||
| signal.displayPingInManager = true; | ||
| signal.Initialize(); | ||
| SphereCollider collider = beacon.AddComponent<SphereCollider>(); | ||
| collider.radius = DESPAWN_DISTANCE; | ||
| collider.isTrigger = true; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.