private void onPooledObjectAdded(RectTransform item, int index) { if (index >= filteredDefinitions.Count) { return; } StaticGameDataDefinition staticGameDataDefinition = filteredDefinitions[index]; IglooCatalogItem component = item.GetComponent <IglooCatalogItem>(); IglooCatalogItemData iglooCatalogItemData = null; if (staticGameDataDefinition.GetType() == typeof(DecorationDefinition)) { DecorationDefinition decorationDefinition = (DecorationDefinition)staticGameDataDefinition; if (!decorationProgressionStatus.TryGetValue(decorationDefinition.Id, out var value)) { value = new ProgressionUtils.ParsedProgression <DecorationDefinition>(decorationDefinition, -1, null, levelLocked: false, progressionLocked: false, decorationDefinition.IsMemberOnly); } iglooCatalogItemData = new IglooCatalogItemData(decorationDefinition, value); component.SetItem(iglooCatalogItemData, this); try { Content.LoadAsync(component.SetImageFromTexture2D, decorationDefinition.Icon); } catch (Exception ex) { Log.LogException(this, ex); } } else if (staticGameDataDefinition.GetType() == typeof(StructureDefinition)) { StructureDefinition structureDefinition = (StructureDefinition)staticGameDataDefinition; if (!structureProgressionStatus.TryGetValue(structureDefinition.Id, out var value2)) { value2 = new ProgressionUtils.ParsedProgression <StructureDefinition>(structureDefinition, -1, null, levelLocked: false, progressionLocked: false, structureDefinition.IsMemberOnly); } iglooCatalogItemData = new IglooCatalogItemData(structureDefinition, value2); component.SetItem(iglooCatalogItemData, this); try { Content.LoadAsync(component.SetImageFromTexture2D, structureDefinition.Icon); } catch (Exception ex) { Log.LogException(this, ex); } } else { Log.LogErrorFormatted(this, "Definition was not a Decoration or a Structure!"); } }
public IglooCatalogItemData(DecorationDefinition definition, ProgressionUtils.ParsedProgression <DecorationDefinition> progressData) { ItemType = DecorationType.Decoration; ID = definition.Id; TitleToken = definition.Name; DescriptionToken = definition.Description; Cost = definition.Cost; IsMemberOnly = progressData.MemberLocked; Level = progressData.Level; ProgressionLocked = progressData.ProgressionLocked; MascotName = progressData.MascotName; LevelLocked = progressData.LevelLocked; StructureSize = -1; }
protected override bool SetLockableButtonLockedStatus(ILockableButton button, StructureDefinition definition, ProgressionUtils.ParsedProgression <StructureDefinition> progressData) { bool result; if (definition.SizeUnits > Service.Get <ObjectManipulationService>().StructurePlotManager.LargestPlotSize) { result = true; (button as IglooCustomizationButton).SetSizeLocked(); } else { result = base.SetLockableButtonLockedStatus(button, definition, progressData); } return(result); }
protected virtual bool SetLockableButtonLockedStatus(ILockableButton button, DecorationDefinitionType definition, ProgressionUtils.ParsedProgression <DecorationDefinitionType> progressData) { bool result = true; if (progressData != null) { if (progressData.MemberLocked && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember()) { button.SetMemberLocked(); } else if (progressData.LevelLocked) { button.SetLevelLocked(progressData.Level); } else if (progressData.ProgressionLocked) { button.SetProgressionLocked(progressData.MascotName); } else { button.SetUnlocked(); result = false; } } else if (definition.IsMemberOnly && !Service.Get <CPDataEntityCollection>().IsLocalPlayerMember()) { button.SetMemberLocked(); } else { button.SetUnlocked(); result = false; } return(result); }