예제 #1
0
    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);
    }
예제 #2
0
    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));
        }
    }