generated from goatcorp/SamplePlugin
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many fixes and improvements to get it finally working
- Loading branch information
1 parent
793a04b
commit 294dea3
Showing
15 changed files
with
470 additions
and
187 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
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
235 changes: 149 additions & 86 deletions
235
Echosync-Server/Behaviours/EchosyncChannelBehaviour.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Echosync_Server | ||
{ | ||
public class UserState | ||
{ | ||
public string WebSocketId { get; set; } = ""; | ||
public string NetworkId { get; set; } = ""; | ||
public string IpAdress { get; set; } = ""; | ||
public string UserName { get; set; } = ""; | ||
public string NpcId { get; set; } = ""; | ||
public string Channel { get; set; } = ""; | ||
public int DialogueCount { get; set; } = 0; | ||
public bool Ready { get; set; } = false; | ||
|
||
public UserState(string webSocketId, string networkId, string ipAdress, string userName, string channel) | ||
{ | ||
this.WebSocketId = webSocketId; | ||
this.NetworkId = networkId; | ||
this.IpAdress = ipAdress; | ||
this.UserName = userName; | ||
this.Channel = channel; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,14 +1,57 @@ | ||
using Dalamud.Interface.Textures.TextureWraps; | ||
using Lumina.Data.Files; | ||
using Dalamud.Plugin.Services; | ||
using Dalamud.Utility; | ||
using Echosync.DataClasses; | ||
using FFXIVClientStructs.FFXIV.Client.Game.Object; | ||
using FFXIVClientStructs.FFXIV.Client.Game.UI; | ||
using FFXIVClientStructs.FFXIV.Client.System.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using System.Numerics; | ||
namespace Echosync.Helper | ||
{ | ||
public static class DalamudHelper | ||
{ | ||
private static IObjectTable ObjectTable; | ||
private static IClientState ClientState; | ||
private static IFramework Framework; | ||
|
||
public static void Setup(IObjectTable objectTable, IClientState clientState, IFramework framework) | ||
{ | ||
ObjectTable = objectTable; | ||
ClientState = clientState; | ||
Framework = framework; | ||
} | ||
|
||
public static int GetClosePlayers(List<uint> connectedUsers, float maxPlayerDistance) | ||
{ | ||
var result = 0; | ||
Framework.RunOnFrameworkThread(() => { result = GetClosePlayersMainThread(connectedUsers, maxPlayerDistance); }); | ||
|
||
return result; | ||
} | ||
private static int GetClosePlayersMainThread(List<uint> connectedUsers, float maxPlayerDistance) | ||
{ | ||
var closePlayers = 0; | ||
foreach (var connectedUser in connectedUsers) | ||
{ | ||
if (!SyncClientHelper.ConnectedPlayersNpc.Contains(connectedUser)) | ||
{ | ||
var playerObject = ObjectTable.SearchByEntityId(connectedUser); | ||
|
||
if (playerObject != null) | ||
{ | ||
var distance = ClientState.LocalPlayer.Position - playerObject.Position; | ||
var combinedDistance = Math.Abs(distance.X) + Math.Abs(distance.Y) + Math.Abs(distance.Z); | ||
if (combinedDistance < maxPlayerDistance) | ||
{ | ||
closePlayers++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return closePlayers; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.