コード例 #1
0
        public override void PreAbsorbStack(Thing otherStack, int count)
        {
            float       t    = (float)count / (float)(this.parent.stackCount + count);
            CompHatcher comp = ((ThingWithComps)otherStack).GetComp <CompHatcher>();
            float       b    = comp.gestateProgress;

            this.gestateProgress = Mathf.Lerp(this.gestateProgress, b, t);
        }
コード例 #2
0
        public override void PostSplitOff(Thing piece)
        {
            CompHatcher comp = ((ThingWithComps)piece).GetComp <CompHatcher>();

            comp.gestateProgress = gestateProgress;
            comp.hatcheeParent   = hatcheeParent;
            comp.otherParent     = otherParent;
            comp.hatcheeFaction  = hatcheeFaction;
        }
コード例 #3
0
        public virtual Thing ProduceEgg()
        {
            if (!this.Active)
            {
                Log.Error("LayEgg while not Active: " + this.parent, false);
            }
            this.eggProgress = 0f;
            int   randomInRange = this.Props.eggCountRange.RandomInRange;
            Thing result;

            if (randomInRange == 0)
            {
                result = null;
            }
            else
            {
                Thing thing;
                if (this.fertilizationCount > 0)
                {
                    thing = ThingMaker.MakeThing(this.Props.eggFertilizedDef, null);
                    this.fertilizationCount = Mathf.Max(0, this.fertilizationCount - randomInRange);
                }
                else
                {
                    thing = ThingMaker.MakeThing(this.Props.eggUnfertilizedDef, null);
                }
                thing.stackCount = randomInRange;
                CompHatcher compHatcher = thing.TryGetComp <CompHatcher>();
                if (compHatcher != null)
                {
                    compHatcher.hatcheeFaction = this.parent.Faction;
                    Pawn pawn = this.parent as Pawn;
                    if (pawn != null)
                    {
                        compHatcher.hatcheeParent = pawn;
                    }
                    if (this.fertilizedBy != null)
                    {
                        compHatcher.otherParent = this.fertilizedBy;
                    }
                }
                result = thing;
            }
            return(result);
        }
コード例 #4
0
ファイル: CompEggLayer.cs プロジェクト: potsh/RimWorld
        public virtual Thing ProduceEgg()
        {
            if (!Active)
            {
                Log.Error("LayEgg while not Active: " + parent);
            }
            eggProgress = 0f;
            int randomInRange = Props.eggCountRange.RandomInRange;

            if (randomInRange == 0)
            {
                return(null);
            }
            Thing thing;

            if (fertilizationCount > 0)
            {
                thing = ThingMaker.MakeThing(Props.eggFertilizedDef);
                fertilizationCount = Mathf.Max(0, fertilizationCount - randomInRange);
            }
            else
            {
                thing = ThingMaker.MakeThing(Props.eggUnfertilizedDef);
            }
            thing.stackCount = randomInRange;
            CompHatcher compHatcher = thing.TryGetComp <CompHatcher>();

            if (compHatcher != null)
            {
                compHatcher.hatcheeFaction = parent.Faction;
                Pawn pawn = parent as Pawn;
                if (pawn != null)
                {
                    compHatcher.hatcheeParent = pawn;
                }
                if (fertilizedBy != null)
                {
                    compHatcher.otherParent = fertilizedBy;
                }
            }
            return(thing);
        }