Esempio n. 1
0
        public static ThingTrade CreateTrade(Thing thing, int count)
        {
            var that = new ThingTrade();

            that.SetBaseInfo(thing, count); //Data заполняется!
            that.DataThing = thing;
            that.Concrete  = true;

            that.DefName      = thing.def.defName;
            that.StuffName    = thing.Stuff == null ? null : thing.Stuff.defName;
            that.HitPoints    = thing.HitPoints;
            that.MaxHitPoints = thing.MaxHitPoints;

            QualityCategory qq;

            if (QualityUtility.TryGetQuality(thing, out qq))
            {
                that.Quality = (int)qq;
            }

            Apparel thingA = thing as Apparel;

            if (thingA != null)
            {
                that.WornByCorpse = thingA.WornByCorpse;
            }

            return(that);
        }
Esempio n. 2
0
        public static ThingTrade CreateTrade(Thing thing, int count, bool withData = true)
        {
            var that = new ThingTrade();

            that.SetBaseInfo(thing, count);
            if (withData)
            {
                that.SetData(thing);
            }
            that.DataThing = thing;
            that.Concrete  = true;

            that.DefName   = thing.def.defName;
            that.StuffName = thing.Stuff == null ? null : thing.Stuff.defName;

            var pawn = thing as Pawn;

            if (pawn == null)
            {
                that.HitPoints    = thing.HitPoints;
                that.MaxHitPoints = thing.MaxHitPoints;
            }
            else
            {
                that.HitPoints    = (int)(pawn.health.summaryHealth.SummaryHealthPercent * 100f);
                that.MaxHitPoints = 100;
            }

            QualityCategory qq;

            if (QualityUtility.TryGetQuality(thing, out qq))
            {
                that.Quality = (int)qq;
            }

            Apparel thingA = thing as Apparel;

            if (thingA != null)
            {
                that.WornByCorpse = thingA.WornByCorpse;
            }

            that.Rotation = thing.Rotation.AsInt;

            Plant thingP = thing as Plant;

            if (thingP != null)
            {
                that.Growth = thingP.Growth;
            }

            that.Position = new IntVec3S(thing.Position);

            return(that);
        }
Esempio n. 3
0
        public static ThingTrade CreateTrade(Thing thing, int count, bool withData = true)
        {
            var that = new ThingTrade();

            that.SetBaseInfo(thing, count);
            if (withData)
            {
                that.SetData(thing);
            }
            that.DataThing = thing;
            that.Concrete  = true;

            that.DefName      = thing.def.defName;
            that.StuffName    = thing.Stuff == null ? null : thing.Stuff.defName;
            that.HitPoints    = thing.HitPoints;
            that.MaxHitPoints = thing.MaxHitPoints;

            QualityCategory qq;

            if (QualityUtility.TryGetQuality(thing, out qq))
            {
                that.Quality = (int)qq;
            }

            Apparel thingA = thing as Apparel;

            if (thingA != null)
            {
                that.WornByCorpse = thingA.WornByCorpse;
            }

            that.Rotation = thing.Rotation.AsInt;

            Plant thingP = thing as Plant;

            if (thingP != null)
            {
                that.Growth = thingP.Growth;
            }

            return(that);
        }
Esempio n. 4
0
        public static ThingTrade CreateTrade(ThingDef thingDef, float minHitPointsPercents, QualityCategory minQualities, int count)
        {
            var that = new ThingTrade();

            that.Name  = thingDef.LabelCap;
            that.Count = count;

            that.DefName      = thingDef.defName;
            that.HitPoints    = (int)(minHitPointsPercents * 100);
            that.MaxHitPoints = 100;

            that.Quality = (int)minQualities;

            // Не заполняются:
            //Data
            //OriginalID
            //StuffName
            //WornByCorpse

            return(that);
        }