private void UpdateUserInterface(UplinkComponent component) { var ui = component.Owner.GetUIOrNull(UplinkUiKey.Key); if (ui == null) { return; } var listings = _listing.GetListings().Values.ToArray(); var acc = component.UplinkAccount; UplinkAccountData accData; if (acc != null) { accData = new UplinkAccountData(acc.AccountHolder, acc.Balance); } else { accData = new UplinkAccountData(null, 0); } ui.SetState(new UplinkUpdateState(accData, listings)); }
private void UpdatePDAUserInterface() { var ownerInfo = new PDAIdInfoText { ActualOwnerName = OwnerMob?.Name, IdOwner = ContainedID?.FullName, JobTitle = ContainedID?.JobTitle }; //Do we have an account? If so provide the info. if (_syndicateUplinkAccount != null) { var accData = new UplinkAccountData(_syndicateUplinkAccount.AccountHolder, _syndicateUplinkAccount.Balance); var listings = _uplinkManager.FetchListings.ToArray(); _interface.SetState(new PDAUpdateState(_lightOn, ownerInfo, accData, listings)); } else { _interface.SetState(new PDAUpdateState(_lightOn, ownerInfo)); } UpdatePDAAppearance(); }
private void UpdateUserInterface(UplinkComponent component) { var ui = component.Owner.GetUIOrNull(UplinkUiKey.Key); if (ui == null) { return; } var listings = _listing.GetListings().Values.ToList(); var acc = component.UplinkAccount; UplinkAccountData accData; if (acc != null) { // if we don't have a jobwhitelist stored, get a new one if (component.JobWhitelist == null && acc.AccountHolder != null && TryComp <MindComponent>(acc.AccountHolder, out var mind) && mind.Mind != null) { HashSet <string>?jobList = new(); foreach (var role in mind.Mind.AllRoles.ToList()) { if (role.GetType() == typeof(Job)) { var job = (Job)role; jobList.Add(job.Prototype.ID); } } component.JobWhitelist = jobList; } // filter out items not on the whitelist for (var i = 0; i < listings.Count; i++) { var entry = listings[i]; if (entry.JobWhitelist != null) { var found = false; if (component.JobWhitelist != null) { foreach (var job in component.JobWhitelist) { if (entry.JobWhitelist.Contains(job)) { found = true; break; } } } if (!found) { listings.Remove(entry); i--; } } } accData = new UplinkAccountData(acc.AccountHolder, acc.Balance); } else { accData = new UplinkAccountData(null, 0); } ui.SetState(new UplinkUpdateState(accData, listings.ToArray())); }