private void Init() { if (_initialized) { return; } controller = new DepartmentController(depBaseData.baseConsumablesNeed); _indicators = new DepartmentIndicators(_iParams); selectionGroup = GetComponent <RoomSelectionGroup>(); _display = GetComponent <DepartmentDisplay>(); _display.UpdateLabel(depBaseData.labelName); _display.UpdateWindowWithData(depBaseData); _display.AddIndicatorsToWindow(_indicators); controller.ResourcesChanged += _display.OnResourcesChanged; var rsg = GetComponent <RoomSelectionGroup>(); if (rsg != null) { rsg.AssignBaseData(new RoomSelectionData(_dep: this)); } _onInit?.Invoke(); _initialized = true; }
void Start() { foreach (Department dep in _departments) { DepartmentDisplay display = dep.gameObject.GetComponent <DepartmentDisplay>(); dep.AddResourcesChangedListener( (DepartmentResources res) => CheckChanges(display, res)); } }
private void CheckChanges(DepartmentDisplay dep, DepartmentResources resources) { if (resources.Type == _staffType) { int num = resources.Cards.Count; for (int i = 0; i < _cardsCountProgress.Count; i++) { if (num >= _cardsCountProgress[i]) { dep.ChangeHumanoidsCount(i + 1); } } } }