-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Open
OhmV-IR
wants to merge
36
commits into
SubnauticaNitrox:master
Choose a base branch
from
OhmV-IR:DeathMarkers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Death markers setting #2253
Changes from 33 commits
Commits
Show all changes
36 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
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
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
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
| using NitroxClient.Communication.Packets.Processors.Abstract; | ||
| using NitroxClient.GameLogic; | ||
| using NitroxModel.Packets; | ||
|
|
||
| namespace NitroxClient.Communication.Packets.Processors; | ||
|
|
||
| public class DeathMarkersChangedProcessor : ClientPacketProcessor<DeathMarkersChanged> | ||
| { | ||
| private readonly LocalPlayer localPlayer; | ||
|
|
||
| public DeathMarkersChangedProcessor(LocalPlayer localPlayer) | ||
| { | ||
| this.localPlayer = localPlayer; | ||
| } | ||
|
|
||
| public override void Process(DeathMarkersChanged packet) | ||
| { | ||
| localPlayer.MarkDeathPointsWithBeacon = packet.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
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||||
| using NitroxModel.DataStructures.Unity; | ||||||||||||
| using NitroxModel_Subnautica.DataStructures; | ||||||||||||
| using UnityEngine; | ||||||||||||
|
|
||||||||||||
| namespace NitroxClient.MonoBehaviours.Gui.InGame; | ||||||||||||
|
|
||||||||||||
| public class DeathBeacon : MonoBehaviour | ||||||||||||
OhmV-IR marked this conversation as resolved.
Show resolved
Hide resolved
OhmV-IR marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
| { | ||||||||||||
| private const float DESPAWN_DISTANCE = 20f; | ||||||||||||
| private const float DESPAWN_DISTANCE_SQUARED = DESPAWN_DISTANCE * DESPAWN_DISTANCE; | ||||||||||||
| private const float CHECK_RATE = 1.5f; // in seconds | ||||||||||||
|
|
||||||||||||
| public static void SpawnDeathBeacon(NitroxVector3 location, string playerName) | ||||||||||||
| { | ||||||||||||
| GameObject beacon = new($"{playerName}DeathBeacon"); | ||||||||||||
| beacon.transform.position = location.ToUnity(); | ||||||||||||
| PingInstance signal = beacon.AddComponent<PingInstance>(); | ||||||||||||
| signal.pingType = PingType.Signal; | ||||||||||||
| signal.origin = beacon.transform; | ||||||||||||
OhmV-IR marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
| signal.minDist = DESPAWN_DISTANCE + 15f; | ||||||||||||
| signal._label = Language.main.Get("Nitrox_PlayerDeathBeaconLabel").Replace("{PLAYER}", playerName); | ||||||||||||
| beacon.AddComponent<DeathBeacon>(); | ||||||||||||
| signal.displayPingInManager = true; | ||||||||||||
| signal.Initialize(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private void Start() | ||||||||||||
| { | ||||||||||||
| InvokeRepeating(nameof(CheckPlayerDistance), 0, CHECK_RATE); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private void CheckPlayerDistance() | ||||||||||||
|
Comment on lines
+29
to
+31
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still open |
||||||||||||
| { | ||||||||||||
| if ((Player.main.transform.position - transform.position).sqrMagnitude <= DESPAWN_DISTANCE_SQUARED) | ||||||||||||
| { | ||||||||||||
| Destroy(gameObject); | ||||||||||||
OhmV-IR marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
| } | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
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,14 @@ | ||
| using System; | ||
|
|
||
| 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
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 System.IO; | ||
| using NitroxModel.DataStructures.GameLogic; | ||
| using NitroxModel.Packets; | ||
| using NitroxModel.Serialization; | ||
| using NitroxServer.ConsoleCommands.Abstract; | ||
| using NitroxServer.ConsoleCommands.Abstract.Type; | ||
| using NitroxServer.GameLogic; | ||
|
|
||
| namespace NitroxServer.ConsoleCommands; | ||
|
|
||
| internal class SetDeathMarkersCommand : Command | ||
| { | ||
| private readonly PlayerManager playerManager; | ||
| private readonly SubnauticaServerConfig serverConfig; | ||
| private readonly Server server; | ||
|
|
||
| public SetDeathMarkersCommand(PlayerManager playerManager, SubnauticaServerConfig serverConfig, Server server) : base("deathmarkers", Perms.ADMIN, "Sets \"Death Markers\" setting to on/off. If \"on\", a beacon will appear at the location where a player dies.") | ||
| { | ||
| this.playerManager = playerManager; | ||
| this.serverConfig = serverConfig; | ||
| this.server = server; | ||
| AddParameter(new TypeBoolean("state", true, "on/off to enable/disable death markers")); | ||
| } | ||
|
|
||
| protected override void Execute(CallArgs args) | ||
| { | ||
| bool newDeathMarkersState = args.Get<bool>(0); | ||
| using (serverConfig.Update(Path.Combine(KeyValueStore.Instance.GetSavesFolderDir(), server.Name))) | ||
| { | ||
| if (serverConfig.MarkDeathPointsWithBeacon != newDeathMarkersState) | ||
| { | ||
| serverConfig.MarkDeathPointsWithBeacon = newDeathMarkersState; | ||
| playerManager.SendPacketToAllPlayers(new DeathMarkersChanged(newDeathMarkersState)); | ||
| SendMessageToAllPlayers($"MarkDeathPointsWithBeacon changed to \"{newDeathMarkersState}\" by {args.SenderName}"); | ||
| } | ||
| else | ||
| { | ||
| SendMessage(args.Sender, $"MarkDeathPointsWithBeacon already set to {newDeathMarkersState}"); | ||
| } | ||
| } | ||
| } | ||
| } |
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.