Ejemplo n.º 1
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (t.Faction != pawn.Faction)
            {
                return(null);
            }
            Frame frame = t as Frame;

            if (frame == null)
            {
                return(null);
            }
            if (frame.MaterialsNeeded().Count > 0)
            {
                return(null);
            }
            if (GenConstruct.FirstBlockingThing(frame, pawn) != null)
            {
                return(GenConstruct.HandleBlockingThingJob(frame, pawn, forced));
            }
            if (!GenConstruct.CanConstruct(frame, pawn, forced))
            {
                return(null);
            }
            return(new Job(JobDefOf.FinishFrame, frame));
        }
Ejemplo n.º 2
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Job result;

            if (t.Faction != pawn.Faction)
            {
                result = null;
            }
            else
            {
                Frame frame = t as Frame;
                if (frame == null)
                {
                    result = null;
                }
                else if (GenConstruct.FirstBlockingThing(frame, pawn) != null)
                {
                    result = GenConstruct.HandleBlockingThingJob(frame, pawn, forced);
                }
                else
                {
                    bool checkConstructionSkill = this.def.workType == WorkTypeDefOf.Construction;
                    if (!GenConstruct.CanConstruct(frame, pawn, checkConstructionSkill, forced))
                    {
                        result = null;
                    }
                    else
                    {
                        result = base.ResourceDeliverJobFor(pawn, frame, true);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedNullOrForbidden(TargetIndex.A));

            Toil build = new Toil();

            build.initAction = delegate()
            {
                GenClamor.DoClamor(build.actor, 15f, ClamorDefOf.Construction);
            };
            build.tickAction = delegate()
            {
                Pawn  actor = build.actor;
                Frame frame = this.Frame;
                if (frame.resourceContainer.Count > 0)
                {
                    actor.skills.Learn(SkillDefOf.Construction, 0.25f, false);
                }
                float num = actor.GetStatValue(StatDefOf.ConstructionSpeed, true);
                if (frame.Stuff != null)
                {
                    num *= frame.Stuff.GetStatValueAbstract(StatDefOf.ConstructionSpeedFactor, null);
                }
                float workToBuild = frame.WorkToBuild;
                if (actor.Faction == Faction.OfPlayer)
                {
                    float statValue = actor.GetStatValue(StatDefOf.ConstructSuccessChance, true);
                    if (Rand.Value < 1f - Mathf.Pow(statValue, num / workToBuild))
                    {
                        frame.FailConstruction(actor);
                        this.ReadyForNextToil();
                        return;
                    }
                }
                if (frame.def.entityDefToBuild is TerrainDef)
                {
                    this.Map.snowGrid.SetDepth(frame.Position, 0f);
                }
                frame.workDone += num;
                if (frame.workDone >= workToBuild)
                {
                    frame.CompleteConstruction(actor);
                    this.ReadyForNextToil();
                    return;
                }
            };
            build.WithEffect(() => ((Frame)build.actor.jobs.curJob.GetTarget(TargetIndex.A).Thing).ConstructionEffect, TargetIndex.A);
            build.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            build.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            build.FailOn(() => !GenConstruct.CanConstruct(this.Frame, this.pawn, true, false));
            build.defaultCompleteMode = ToilCompleteMode.Delay;
            build.defaultDuration     = 5000;
            build.activeSkill         = (() => SkillDefOf.Construction);
            yield return(build);

            yield break;
        }
Ejemplo n.º 4
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (t.Faction != pawn.Faction)
            {
                return(null);
            }
            Blueprint blueprint = t as Blueprint;

            if (blueprint == null)
            {
                return(null);
            }
            if (GenConstruct.FirstBlockingThing(blueprint, pawn) != null)
            {
                return(GenConstruct.HandleBlockingThingJob(blueprint, pawn, forced));
            }
            bool flag = def.workType == WorkTypeDefOf.Construction;

            if (!GenConstruct.CanConstruct(blueprint, pawn, flag, forced))
            {
                return(null);
            }
            if (!flag && WorkGiver_ConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blueprint))
            {
                return(null);
            }
            Job job = RemoveExistingFloorJob(pawn, blueprint);

            if (job != null)
            {
                return(job);
            }
            Job job2 = ResourceDeliverJobFor(pawn, blueprint);

            if (job2 != null)
            {
                return(job2);
            }
            if (def.workType != WorkTypeDefOf.Hauling)
            {
                Job job3 = NoCostFrameMakeJobFor(pawn, blueprint);
                if (job3 != null)
                {
                    return(job3);
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (t.Faction != pawn.Faction)
            {
                return(null);
            }
            Blueprint blueprint = t as Blueprint;

            if (blueprint == null)
            {
                return(null);
            }
            if (GenConstruct.FirstBlockingThing(blueprint, pawn) != null)
            {
                return(GenConstruct.HandleBlockingThingJob(blueprint, pawn, forced));
            }
            if (!GenConstruct.CanConstruct(blueprint, pawn, forced))
            {
                return(null);
            }
            Job job = base.RemoveExistingFloorJob(pawn, blueprint);

            if (job != null)
            {
                return(job);
            }
            Job job2 = base.ResourceDeliverJobFor(pawn, blueprint, true);

            if (job2 != null)
            {
                return(job2);
            }
            Job job3 = this.NoCostFrameMakeJobFor(pawn, blueprint);

            if (job3 != null)
            {
                return(job3);
            }
            return(null);
        }
Ejemplo n.º 6
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (t.Faction != pawn.Faction)
            {
                return(null);
            }
            Frame frame = t as Frame;

            if (frame == null)
            {
                return(null);
            }
            if (GenConstruct.FirstBlockingThing(frame, pawn) != null)
            {
                return(GenConstruct.HandleBlockingThingJob(frame, pawn, forced));
            }
            if (!GenConstruct.CanConstruct(frame, pawn, forced))
            {
                return(null);
            }
            return(base.ResourceDeliverJobFor(pawn, frame, true));
        }
		public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
		{
			if (t.Faction != pawn.Faction)
			{
				return null;
			}
			Frame frame = t as Frame;
			if (frame == null)
			{
				return null;
			}
			if (GenConstruct.FirstBlockingThing(frame, pawn) != null)
			{
				return GenConstruct.HandleBlockingThingJob(frame, pawn, forced);
			}
			bool checkConstructionSkill = def.workType == WorkTypeDefOf.Construction;
			if (!GenConstruct.CanConstruct(frame, pawn, checkConstructionSkill, forced))
			{
				return null;
			}
			return ResourceDeliverJobFor(pawn, frame);
		}
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Job result;

            if (t.Faction != pawn.Faction)
            {
                result = null;
            }
            else
            {
                Frame frame = t as Frame;
                if (frame == null)
                {
                    result = null;
                }
                else if (frame.MaterialsNeeded().Count > 0)
                {
                    result = null;
                }
                else if (GenConstruct.FirstBlockingThing(frame, pawn) != null)
                {
                    result = GenConstruct.HandleBlockingThingJob(frame, pawn, forced);
                }
                else
                {
                    Frame t2 = frame;
                    if (!GenConstruct.CanConstruct(t2, pawn, true, forced))
                    {
                        result = null;
                    }
                    else
                    {
                        result = new Job(JobDefOf.FinishFrame, frame);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
 private bool IsNewValidNearbyNeeder(Thing t, HashSet <Thing> nearbyNeeders, IConstructible constructible, Pawn pawn)
 {
     return(t is IConstructible && t != constructible && !(t is Blueprint_Install) && t.Faction == pawn.Faction && !t.IsForbidden(pawn) && !nearbyNeeders.Contains(t) && GenConstruct.CanConstruct(t, pawn, false, false));
 }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Job result;

            if (t.Faction != pawn.Faction)
            {
                result = null;
            }
            else
            {
                Blueprint blueprint = t as Blueprint;
                if (blueprint == null)
                {
                    result = null;
                }
                else if (GenConstruct.FirstBlockingThing(blueprint, pawn) != null)
                {
                    result = GenConstruct.HandleBlockingThingJob(blueprint, pawn, forced);
                }
                else
                {
                    bool flag = this.def.workType == WorkTypeDefOf.Construction;
                    if (!GenConstruct.CanConstruct(blueprint, pawn, flag, forced))
                    {
                        result = null;
                    }
                    else if (!flag && WorkGiver_ConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blueprint))
                    {
                        result = null;
                    }
                    else
                    {
                        Job job = base.RemoveExistingFloorJob(pawn, blueprint);
                        if (job != null)
                        {
                            result = job;
                        }
                        else
                        {
                            Job job2 = base.ResourceDeliverJobFor(pawn, blueprint, true);
                            if (job2 != null)
                            {
                                result = job2;
                            }
                            else
                            {
                                Job job3 = this.NoCostFrameMakeJobFor(pawn, blueprint);
                                if (job3 != null)
                                {
                                    result = job3;
                                }
                                else
                                {
                                    result = null;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
 private bool IsNewValidNearbyNeeder(Thing t, HashSet <Thing> nearbyNeeders, IConstructible constructible, Pawn pawn)
 {
     if (!(t is IConstructible) || t == constructible || t is Blueprint_Install || t.Faction != pawn.Faction || t.IsForbidden(pawn) || nearbyNeeders.Contains(t) || !GenConstruct.CanConstruct(t, pawn, checkConstructionSkill: false))
     {
         return(false);
     }
     return(true);
 }