.NET Format Style Fixes

This commit is contained in:
refringe
2025-06-18 17:09:20 +00:00
committed by Format Bot
parent ca0a7d6345
commit 6e01428b2b
774 changed files with 23507 additions and 40003 deletions
@@ -37,13 +37,17 @@ public class DialogueController(
{
if (_dialogueChatBots.Any(cb => cb.GetChatBot().Id == chatBot.GetChatBot().Id))
{
_logger.Error(_localisationService.GetText("dialog-chatbot_id_already_exists", chatBot.GetChatBot().Id));
_logger.Error(
_localisationService.GetText(
"dialog-chatbot_id_already_exists",
chatBot.GetChatBot().Id
)
);
}
_dialogueChatBots.Add(chatBot);
}
/// <summary>
/// Handle onUpdate spt event
/// </summary>
@@ -80,7 +84,7 @@ public class DialogueController(
{
Id = friendProfile.Id,
Aid = friendProfile.Aid,
Info = friendProfile.Info
Info = friendProfile.Info,
}
);
}
@@ -91,7 +95,7 @@ public class DialogueController(
{
Friends = friends,
Ignore = [],
InIgnoreList = []
InIgnoreList = [],
};
}
@@ -144,9 +148,7 @@ public class DialogueController(
/// <param name="dialogueId">Dialog id</param>
/// <param name="sessionId">Session Id</param>
/// <returns>DialogueInfo</returns>
public virtual DialogueInfo? GetDialogueInfo(
string? dialogueId,
string sessionId)
public virtual DialogueInfo? GetDialogueInfo(string? dialogueId, string sessionId)
{
var dialogs = _dialogueHelper.GetDialogsForProfile(sessionId);
var dialogue = dialogs!.GetValueOrDefault(dialogueId);
@@ -164,7 +166,7 @@ public class DialogueController(
New = dialogue?.New,
AttachmentsNew = dialogue?.AttachmentsNew,
Pinned = dialogue?.Pinned,
Users = GetDialogueUsers(dialogue, dialogue?.Type, sessionId)
Users = GetDialogueUsers(dialogue, dialogue?.Type, sessionId),
};
return result;
@@ -180,14 +182,19 @@ public class DialogueController(
public virtual List<UserDialogInfo> GetDialogueUsers(
Dialogue? dialog,
MessageType? messageType,
string sessionId)
string sessionId
)
{
var profile = _saveServer.GetProfile(sessionId);
// User to user messages are special in that they need the player to exist in them, add if they don't
if (messageType == MessageType.UserMessage &&
dialog?.Users is not null &&
dialog.Users.All(userDialog => userDialog.Id != profile.CharacterData?.PmcData?.SessionId))
if (
messageType == MessageType.UserMessage
&& dialog?.Users is not null
&& dialog.Users.All(userDialog =>
userDialog.Id != profile.CharacterData?.PmcData?.SessionId
)
)
{
dialog.Users.Add(
new UserDialogInfo
@@ -200,8 +207,12 @@ public class DialogueController(
Nickname = profile.CharacterData?.PmcData?.Info?.Nickname,
Side = profile.CharacterData?.PmcData?.Info?.Side,
MemberCategory = profile.CharacterData?.PmcData?.Info?.MemberCategory,
SelectedMemberCategory = profile.CharacterData?.PmcData?.Info?.SelectedMemberCategory
}
SelectedMemberCategory = profile
.CharacterData
?.PmcData
?.Info
?.SelectedMemberCategory,
},
}
);
}
@@ -220,7 +231,8 @@ public class DialogueController(
/// <returns>GetMailDialogViewResponseData object</returns>
public virtual GetMailDialogViewResponseData GenerateDialogueView(
GetMailDialogViewRequestData request,
string sessionId)
string sessionId
)
{
var dialogueId = request.DialogId;
var fullProfile = _saveServer.GetProfile(sessionId);
@@ -232,7 +244,7 @@ public class DialogueController(
{
Messages = [],
Profiles = [],
HasMessagesWithRewards = false
HasMessagesWithRewards = false,
};
}
@@ -246,7 +258,7 @@ public class DialogueController(
{
Messages = dialogue.Messages,
Profiles = GetProfilesForMail(fullProfile, dialogue.Users),
HasMessagesWithRewards = MessagesHaveUncollectedRewards(dialogue.Messages!)
HasMessagesWithRewards = MessagesHaveUncollectedRewards(dialogue.Messages!),
};
}
@@ -258,11 +270,16 @@ public class DialogueController(
/// <returns>Dialogue</returns>
protected Dialogue GetDialogByIdFromProfile(
SptProfile profile,
GetMailDialogViewRequestData request)
GetMailDialogViewRequestData request
)
{
if (profile.DialogueRecords is null || profile.DialogueRecords.ContainsKey(request.DialogId!))
if (
profile.DialogueRecords is null
|| profile.DialogueRecords.ContainsKey(request.DialogId!)
)
{
return profile.DialogueRecords?[request.DialogId!] ?? throw new NullReferenceException();
return profile.DialogueRecords?[request.DialogId!]
?? throw new NullReferenceException();
}
profile.DialogueRecords[request.DialogId!] = new Dialogue
@@ -272,7 +289,7 @@ public class DialogueController(
Pinned = false,
Messages = [],
New = 0,
Type = request.Type
Type = request.Type,
};
if (request.Type != MessageType.UserMessage)
@@ -282,7 +299,9 @@ public class DialogueController(
var dialogue = profile.DialogueRecords[request.DialogId!];
dialogue.Users = [];
var chatBot = _dialogueChatBots.FirstOrDefault(cb => cb.GetChatBot().Id == request.DialogId);
var chatBot = _dialogueChatBots.FirstOrDefault(cb =>
cb.GetChatBot().Id == request.DialogId
);
if (chatBot is null)
{
@@ -301,11 +320,14 @@ public class DialogueController(
/// <param name="fullProfile">Player profile</param>
/// <param name="userDialogs">The participants of the mail</param>
/// <returns>UserDialogInfo list</returns>
protected List<UserDialogInfo> GetProfilesForMail(SptProfile fullProfile, List<UserDialogInfo>? userDialogs)
protected List<UserDialogInfo> GetProfilesForMail(
SptProfile fullProfile,
List<UserDialogInfo>? userDialogs
)
{
List<UserDialogInfo> result = [];
if (userDialogs is null)
// Nothing to add
// Nothing to add
{
return result;
}
@@ -330,8 +352,8 @@ public class DialogueController(
Side = pmcProfile?.Info?.Side,
Level = pmcProfile?.Info?.Level,
MemberCategory = pmcProfile?.Info?.MemberCategory,
SelectedMemberCategory = pmcProfile?.Info?.SelectedMemberCategory
}
SelectedMemberCategory = pmcProfile?.Info?.SelectedMemberCategory,
},
}
);
@@ -344,15 +366,16 @@ public class DialogueController(
/// <param name="sessionId">Session id</param>
/// <param name="dialogueId">Dialog id</param>
/// <returns>Count of messages with attachments</returns>
protected int GetUnreadMessagesWithAttachmentsCount(
string sessionId,
string dialogueId)
protected int GetUnreadMessagesWithAttachmentsCount(string sessionId, string dialogueId)
{
var newAttachmentCount = 0;
var activeMessages = GetActiveMessagesFromDialog(sessionId, dialogueId);
foreach (var message in activeMessages)
{
if (message.HasRewards.GetValueOrDefault(false) && !message.RewardCollected.GetValueOrDefault(false))
if (
message.HasRewards.GetValueOrDefault(false)
&& !message.RewardCollected.GetValueOrDefault(false)
)
{
newAttachmentCount++;
}
@@ -372,11 +395,13 @@ public class DialogueController(
var timeNow = _timeUtil.GetTimeStamp();
var dialogs = _dialogueHelper.GetDialogsForProfile(sessionId);
return dialogs[dialogueId].Messages?.Where(message =>
{
var checkTime = message.DateTime + (message.MaxStorageTime ?? 0);
return timeNow < checkTime;
}).ToList() ?? [];
return dialogs[dialogueId]
.Messages?.Where(message =>
{
var checkTime = message.DateTime + (message.MaxStorageTime ?? 0);
return timeNow < checkTime;
})
.ToList() ?? [];
}
/// <summary>
@@ -395,9 +420,7 @@ public class DialogueController(
/// </summary>
/// <param name="dialogueId">id of the dialog to remove</param>
/// <param name="sessionId">Player id</param>
public virtual void RemoveDialogue(
string? dialogueId,
string sessionId)
public virtual void RemoveDialogue(string? dialogueId, string sessionId)
{
var profile = _saveServer.GetProfile(sessionId);
if (!profile.DialogueRecords.ContainsKey(dialogueId))
@@ -405,11 +428,7 @@ public class DialogueController(
_logger.Error(
_localisationService.GetText(
"dialogue-unable_to_find_in_profile",
new
{
sessionId,
dialogueId
}
new { sessionId, dialogueId }
)
);
@@ -433,11 +452,7 @@ public class DialogueController(
_logger.Error(
_localisationService.GetText(
"dialogue-unable_to_find_in_profile",
new
{
sessionId,
dialogueId
}
new { sessionId, dialogueId }
)
);
@@ -461,10 +476,7 @@ public class DialogueController(
_logger.Error(
_localisationService.GetText(
"dialogue-unable_to_find_dialogs_in_profile",
new
{
sessionId
}
new { sessionId }
)
);
@@ -491,9 +503,7 @@ public class DialogueController(
var dialog = dialogs.TryGetValue(dialogueId, out var dialogInfo);
if (!dialog)
{
_logger.Error(
_localisationService.GetText("dialogue-unable_to_find_in_profile")
);
_logger.Error(_localisationService.GetText("dialogue-unable_to_find_in_profile"));
return null;
}
@@ -508,7 +518,7 @@ public class DialogueController(
{
Messages = messagesWithAttachments,
Profiles = [],
HasMessagesWithRewards = MessagesHaveUncollectedRewards(messagesWithAttachments)
HasMessagesWithRewards = MessagesHaveUncollectedRewards(messagesWithAttachments),
};
}
@@ -518,18 +528,15 @@ public class DialogueController(
/// <param name="sessionId">Session/Player id</param>
/// <param name="request"></param>
/// <returns></returns>
public virtual string SendMessage(
string sessionId,
SendMessageRequest request)
public virtual string SendMessage(string sessionId, SendMessageRequest request)
{
_mailSendService.SendPlayerMessageToNpc(sessionId, request.DialogId!, request.Text!);
return (_dialogueChatBots.FirstOrDefault(cb =>
cb.GetChatBot().Id == request.DialogId
)
?.HandleMessage(sessionId, request) ??
request.DialogId) ??
string.Empty;
return (
_dialogueChatBots
.FirstOrDefault(cb => cb.GetChatBot().Id == request.DialogId)
?.HandleMessage(sessionId, request) ?? request.DialogId
) ?? string.Empty;
}
/// <summary>
@@ -592,7 +599,10 @@ public class DialogueController(
/// <param name="sessionID">Session/player id</param>
/// <param name="request">Sent friend request</param>
/// <returns></returns>
public virtual FriendRequestSendResponse SendFriendRequest(string sessionID, FriendRequestData request)
public virtual FriendRequestSendResponse SendFriendRequest(
string sessionID,
FriendRequestData request
)
{
// To avoid needing to jump between profiles, auto-accept all friend requests
var friendProfile = _profileHelper.GetFullProfile(request.To);
@@ -602,7 +612,7 @@ public class DialogueController(
{
Status = BackendErrorCodes.PlayerProfileNotFound,
RequestId = "", // Unused in an error state
RetryAfter = 600
RetryAfter = 600,
};
}
@@ -620,7 +630,9 @@ public class DialogueController(
var notification = new WsFriendsListAccept
{
EventType = NotificationEventType.friendListRequestAccept,
Profile = _profileHelper.GetChatRoomMemberFromPmcProfile(friendProfile.CharacterData.PmcData)
Profile = _profileHelper.GetChatRoomMemberFromPmcProfile(
friendProfile.CharacterData.PmcData
),
};
_notificationSendHelper.SendMessage(sessionID, notification);
},
@@ -633,7 +645,7 @@ public class DialogueController(
{
Status = BackendErrorCodes.None,
RequestId = friendProfile.ProfileInfo.Aid.ToString(),
RetryAfter = 600
RetryAfter = 600,
};
}
@@ -662,7 +674,9 @@ public class DialogueController(
var profile = _saveServer.GetProfile(sessionId);
if (!profile.DialogueRecords.TryGetValue(request.DialogId, out var dialogToClear))
{
_logger.Warning($"unable to clear messages from dialog: {request.DialogId} as it cannot be found in profile: {sessionId}");
_logger.Warning(
$"unable to clear messages from dialog: {request.DialogId} as it cannot be found in profile: {sessionId}"
);
return;
}