Example #1
0
 public static bool PlayerCanSell(this Tradeability tradeability)
 {
     if (tradeability != Tradeability.All)
     {
         return(tradeability == Tradeability.Sellable);
     }
     return(true);
 }
Example #2
0
 public static bool TraderCanSell(this Tradeability tradeability)
 {
     return(tradeability == Tradeability.All || tradeability == Tradeability.Buyable);
 }
Example #3
0
        public ThingDefStats(ThingDef d) : base(d)
        {
            this.version = 2;
            Util.Populate(out this.VerbStats, Def.Verbs, (v) =>
            {
                try
                {
                    if (v != null)
                    {
                        return(new VerbStats(v));
                    }
                }
                catch (Exception e) { Log.Warning(e.GetType().Name + " -- " + e.Message); }
                Log.Warning("Poorly formatted VerbProperties in " + this.Def.defName);
                return(null);
            });
            Util.Populate(out this.Tools, Def.tools, (v) => new ToolStats(v));
            Util.Populate(out this.EquippedStatOffsets, Def.equippedStatOffsets, (v) => new FloatValueDefStat <StatDef>(v.stat, v.value));

            this.destroyable                   = d.destroyable;
            this.rotatable                     = d.rotatable;
            this.smallVolume                   = d.smallVolume;
            this.useHitPoints                  = d.useHitPoints;
            this.receivesSignals               = d.receivesSignals;
            this.smeltable                     = d.smeltable;
            this.randomizeRotationOnSpawn      = d.randomizeRotationOnSpawn;
            this.isTechHediff                  = d.isTechHediff;
            this.isUnfinishedThing             = d.isUnfinishedThing;
            this.leaveResourcesWhenKilled      = d.leaveResourcesWhenKilled;
            this.isFrameInt                    = d.isFrameInt;
            this.hasInteractionCell            = d.hasInteractionCell;
            this.interactionCellIconReverse    = d.interactionCellIconReverse;
            this.forceDebugSpawnable           = d.forceDebugSpawnable;
            this.intricate                     = d.intricate;
            this.scatterableOnMapGen           = d.scatterableOnMapGen;
            this.deepCommonality               = d.deepCommonality;
            this.deepCountPerCell              = d.deepCountPerCell;
            this.deepCountPerPortion           = d.deepCountPerPortion;
            this.generateCommonality           = d.generateCommonality;
            this.generateAllowChance           = d.generateAllowChance;
            this.canOverlapZones               = GetCanOverlapZones(d);
            this.alwaysFlee                    = d.alwaysFlee;
            this.drawOffscreen                 = d.drawOffscreen;
            this.hideAtSnowDepth               = d.hideAtSnowDepth;
            this.drawDamagedOverlay            = d.drawDamagedOverlay;
            this.castEdgeShadows               = d.castEdgeShadows;
            this.staticSunShadowHeight         = d.staticSunShadowHeight;
            this.selectable                    = d.selectable;
            this.neverMultiSelect              = d.neverMultiSelect;
            this.isAutoAttackableMapObject     = d.isAutoAttackableMapObject;
            this.hasTooltip                    = d.hasTooltip;
            this.seeThroughFog                 = d.seeThroughFog;
            this.drawGUIOverlay                = d.drawGUIOverlay;
            this.resourceReadoutPriority       = d.resourceReadoutPriority;
            this.resourceReadoutAlwaysShow     = d.resourceReadoutAlwaysShow;
            this.drawPlaceWorkersWhileSelected = d.drawPlaceWorkersWhileSelected;
            this.uiIconScale                   = d.uiIconScale;
            this.alwaysHaulable                = d.alwaysHaulable;
            this.designateHaulable             = d.designateHaulable;
            this.mineable = d.mineable;
            this.socialPropernessMatters = d.socialPropernessMatters;
            this.stealable           = d.stealable;
            this.saveCompressible    = d.saveCompressible;
            this.isSaveable          = d.isSaveable;
            this.holdsRoof           = d.holdsRoof;
            this.fillPercent         = d.fillPercent;
            this.coversFloor         = d.coversFloor;
            this.neverOverlapFloors  = d.neverOverlapFloors;
            this.surfaceType         = d.surfaceType;
            this.blockPlants         = d.blockPlants;
            this.blockLight          = d.blockLight;
            this.blockWind           = d.blockWind;
            this.tradeability        = d.tradeability;
            this.tradeNeverStack     = d.tradeNeverStack;
            this.equippedAngleOffset = d.equippedAngleOffset;
            this.equipmentType       = d.equipmentType;
            this.techLevel           = d.techLevel;
            this.destroyOnDrop       = d.destroyOnDrop;
            this.drawerType          = d.drawerType;

            Util.AssignDefStat(d.slagDef, out this.slagDef);
            Util.AssignDefStat(d.interactionCellIcon, out this.interactionCellIcon);
            Util.AssignDefStat(d.filthLeaving, out this.filthLeaving);
            Util.AssignDefStat(d.minifiedDef, out this.minifiedDef);
            Util.AssignDefStat(d.soundDrop, out this.soundDrop);
            Util.AssignDefStat(d.soundPickup, out this.soundPickup);
            Util.AssignDefStat(d.soundInteract, out this.soundInteract);
            Util.AssignDefStat(d.soundImpactDefault, out this.soundImpactDefault);
            Util.AssignDefStat(d.entityDefToBuild, out this.entityDefToBuild);

            if (d.apparel != null)
            {
                this.apparel = new ApparelPropertiesStats(Def.apparel);
            }
            if (d.deepLumpSizeRange != null)
            {
                this.deepLumpSizeRange = new MinMaxIntStats(Def.deepLumpSizeRange);
            }
            if (d.interactionCellOffset != null)
            {
                this.interactionCellOffset = new IntVec3Stats(Def.interactionCellOffset);
            }
            if (d.startingHpRange != null)
            {
                this.startingHpRange = new MinMaxFloatStats(Def.startingHpRange);
            }
            if (d.graphicData != null)
            {
                this.graphicData = new GraphicDataStats(Def.graphicData);
            }
            if (d.ingestible != null)
            {
                this.ingestible = new IngestiblePropertiesStats(Def.ingestible);
            }
            if (d.filth != null)
            {
                this.filth = new FilthPropertiesStats(Def.filth);
            }
            if (d.gas != null)
            {
                this.gas = new GasPropertiesStats(Def.gas);
            }
            if (d.building != null)
            {
                this.building = new BuildingPropertiesStats(Def.building);
            }
            if (d.race != null)
            {
                this.race = new RacePropertiesStats(Def.race);
            }
            if (d.mote != null)
            {
                this.mote = new MotePropertiesStats(Def.mote);
            }
            if (d.plant != null)
            {
                this.plant = new PlantPropertiesStats(Def.plant);
            }
            if (d.stuffProps != null)
            {
                this.stuffProps = new StuffPropertiesStats(Def.stuffProps);
            }
            if (d.skyfaller != null)
            {
                this.skyfaller = new SkyfallerPropertiesStats(Def.skyfaller);
            }

            Util.Populate(out this.thingCategories, Def.thingCategories, (v) => new DefStat <ThingCategoryDef>(v));
            Util.Populate(out this.killedLeavings, Def.killedLeavings, (v) => new IntValueDefStat <ThingDef>(v.thingDef, v.count));
            Util.Populate(out this.butcherProducts, Def.butcherProducts, (v) => new IntValueDefStat <ThingDef>(v.thingDef, v.count));
            Util.Populate(out this.smeltProducts, Def.smeltProducts, (v) => new IntValueDefStat <ThingDef>(v.thingDef, v.count));
            Util.Populate(out this.damageMultipliers, Def.damageMultipliers, (v) => new FloatValueDefStat <DamageDef>(v.damageDef, v.multiplier));
            Util.Populate(out this.thingSetMakers, Def.thingSetMakerTags);
            Util.Populate(out this.comps, Def.comps, (v) => v.compClass.FullName);
            Util.Populate(out this.tradeTags, Def.tradeTags);
            Util.Populate(out this.weaponTags, Def.weaponTags);
            Util.Populate(out this.techHediffsTags, Def.techHediffsTags);
        }