Hello guys!
Basically i need to find cupboard/s owned by given player, I got a solution:
void FindCupboardMapPos(BasePlayer target, out string outText, out int cpCount)
{
string formattedReturn = "";
var tc = Resources.FindObjectsOfTypeAll<BuildingPrivlidge>().Where(x => x.authorizedPlayers.Any((ProtoBuf.PlayerNameID z) => z.userid == target.userID)).ToList();
if (tc.Count > 0)
{
foreach (var cup in tc)
{
formattedReturn = formattedReturn + String.Format("{0} ", MapPosition(cup.transform.position));
}
}
outText = formattedReturn; // empty if 0 tc owned / shows map sqare seperate if found eg. - (L11 L22 K15)
cpCount = tc.Count; // 0 if no tc owned
}But it's heavy loads server when input are list of players, if I check one single guy all seems to be fine.Im using this function in loop where I got filtered bunch of players what Im looking for, its may be from 3 to 40+ players (depends on how much time passed from wipe) and this loop called on chat/console command.
So the question is, are there another way to find specifed player TC without going through all entities? (Afaik that function passes throug all TC's, wrong?)
Thanks in advance!