Carly.TeamSail
Carly.TeamSail
CC#
Created by hurikan on 10/25/2023 in #help
❔ Finding the right algorithm for this task 🤔
I guess you could use AABB but its more for 3d i think
97 replies
CC#
Created by hurikan on 10/25/2023 in #help
❔ Finding the right algorithm for this task 🤔
Search intersecting lines algo
97 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
Thanks and get well soon!
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
i will make a new method that only checks if its there and doesnt request again
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
yes you are correct
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
yes
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
also UniTask == Task, its literally the same, only it works within Uity, which normal Tasks do not
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
i mean i wrote it once without any errors in console but it turned out to be useless for that use case anyway and that was a few months ago
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
Or is this wetarded, i have no idea, i never used async await before tbh
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
async UniTaskVoid OnMessageReceived(long ID, byte channel, long senderID, string message)
{
string senderName = ClientNamingSystem.GetOrRequestName(NamingSystemType.CharacterName, senderID);

if (string.IsNullOrEmpty(senderName)) senderName = await WaitForName(senderID);
async UniTaskVoid OnMessageReceived(long ID, byte channel, long senderID, string message)
{
string senderName = ClientNamingSystem.GetOrRequestName(NamingSystemType.CharacterName, senderID);

if (string.IsNullOrEmpty(senderName)) senderName = await WaitForName(senderID);
async UniTask<string> WaitForName(long id)
{
string awaitedName;

// Wait 30 seconds max
for (int i = 0; i < 600; i++)
{
awaitedName = ClientNamingSystem.TryGetName(NamingSystemType.CharacterName, id);
if (string.IsNullOrEmpty(awaitedName)) await UniTask.Delay(50);
else return awaitedName;
}
return "";
}
async UniTask<string> WaitForName(long id)
{
string awaitedName;

// Wait 30 seconds max
for (int i = 0; i < 600; i++)
{
awaitedName = ClientNamingSystem.TryGetName(NamingSystemType.CharacterName, id);
if (string.IsNullOrEmpty(awaitedName)) await UniTask.Delay(50);
else return awaitedName;
}
return "";
}
This all happens inside the UI_Chat class, which is a Client-only class for displaying chat messages. EDIT: Changed to TryGetName - new method which doesnt request from server the name 600 times lol, it just checks if its arrived
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
thanks again!
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
ok ok ill try
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
Task.Delay(10) or something?
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
Hmm I can use async await for that?
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
So I need to store ID, and when name is received, check for stored IDs that were waiting and then return the name somehow
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
Is this possible @Pobiega ? (sorry for ping)
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
public static string GetName(NamingSystemType type, long id, Action<string> callback)
{
if (names.TryGetValue(type, out Dictionary<long, string> dict))
{
if (dict.TryGetValue(id, out string name)) return name;
else
{
// callback when ready somehow?
CommsManager.Instance.CMD_RequestName(id);
return "";
}
}
else return "";
}
public static string GetName(NamingSystemType type, long id, Action<string> callback)
{
if (names.TryGetValue(type, out Dictionary<long, string> dict))
{
if (dict.TryGetValue(id, out string name)) return name;
else
{
// callback when ready somehow?
CommsManager.Instance.CMD_RequestName(id);
return "";
}
}
else return "";
}
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
thanks for your time
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
I guess ill add another gnarly callback so it just works
56 replies
CC#
Created by Carly.TeamSail on 10/25/2023 in #help
❔ async await nooob trying to do the simplest of simple await for a string to be returned?
so probably for a good reason
56 replies