public static IconGroupReusable GetResourcesIconGroupReusable(BlueprintDesign blueprintDesign, bool alwaysUseTextNumbers) { StructureInfo structureInfo = new StructureInfo(blueprintDesign.thingType); IconGroupReusable igr = new IconGroupReusable(alwaysUseTextNumbers); foreach (ResourceTypes resourceType in System.Enum.GetValues(typeof(ResourceTypes))) { //consume or produce resources int iconCount = structureInfo.GetInfoIconCount(resourceType, StructureInfo.InfoTypes.optimum); IconBackgroundTypes ibt = iconCount < 0 ? IconBackgroundTypes.bar : IconBackgroundTypes.circle; if (iconCount != 0) { Texture backgroundTexture = IconGroupReusable.GetIconBackgroundTexture(ibt); Texture texture = ResourceReusable.GetResourceTextureFromResourceType(resourceType); igr.AddIcons(texture, backgroundTexture, Mathf.Abs(iconCount)); } //capacity resources iconCount = structureInfo.GetInfoIconCount(resourceType, StructureInfo.InfoTypes.capacity); if (iconCount > 0) { Texture backgroundTexture = IconGroupReusable.GetIconBackgroundTexture(IconBackgroundTypes.square); Texture texture = ResourceReusable.GetResourceTextureFromResourceType(resourceType); igr.AddIcons(texture, backgroundTexture, iconCount); } } return(igr); }
private void BuildIGRList() { //create resource exchange icon group labels.Add("Resources:"); IconGroupReusable igr = IconGroupReusable.GetResourcesIconGroupReusable(blueprintDesign, false); igrList.Add(igr); //create materials needed icon group igr = new IconGroupReusable(true); igrList.Add(igr); labels.Add("Materials needed:"); foreach (ThingTypes tt in blueprintDesign.GetThingTotal().Keys) { Texture texture = ThingFactory.MakeThing(tt).iconTexture; int count = blueprintDesign.GetThingTotal()[tt]; igr.AddIcons(texture, null, count); } //create work needed icon group igr = new IconGroupReusable(true); igrList.Add(igr); labels.Add("Tools needed:"); foreach (ThingTypes tt in blueprintDesign.GetToolTotal().Keys) { Texture texture = ThingFactory.MakeThing(tt).iconTexture; float amount = blueprintDesign.GetToolTotal()[tt]; igr.AddIcons(texture, null, Mathf.CeilToInt(amount)); } }
public void RecalculateIconGroup() { //this icon group is the production, consumption, storage, etc for each resource. //building an IconGroupReusable is too costly for all structures to do every frame. //RecalculateIconGroup is used on initialization and sparingly after that. igr = IconGroupReusable.GetResourcesIconGroupReusable(matchingThing.GetBlueprintDesign(), false); }
public void Draw(Rect drawRect, bool drawBackgroundColor) { iconRect.x = drawRect.x + GUIFunctions.margin; titleRect.x = drawRect.x + GUIFunctions.margin; listRect.x = drawRect.x + iconRect.width + GUIFunctions.margin * 2; iconRect.y = drawRect.y + titleHeight; titleRect.y = drawRect.y; listRect.y = drawRect.y + titleHeight; if (drawBackgroundColor) { GUI.DrawTexture(drawRect, background); } GUI.DrawTexture(iconRect, iconTexture); GUI.Label(titleRect, title, titleStyle); IconGroupReusable.DrawLabelledIGRList(labels, igrList, listRect, labelStyle); }
private void DrawStructureRow(StructureController structureController, float yPosition) { bigCellRect.y = yPosition; cellRect.y = yPosition; tinyCellRect.y = yPosition; float x = 0; cellRect.x = x; PicNameStatusReusable pnr = new PicNameStatusReusable(structureController.matchingThing.name, structureController.matchingThing.iconTexture); pnr.Draw(cellRect, structureController.GetStatusTexture()); x += cellRect.width; tinyCellRect.x = x; pnr = new PicNameStatusReusable(structureController.GetStatusLabel(), structureController.GetStatusTexture()); pnr.Draw(tinyCellRect); x += tinyCellRect.width; cellRect.x = x; IconGroupReusable igr = structureController.GetIconGroup(); igr.Draw(cellRect); }