Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }