示例#1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            job.count = 1;
            this.FailOnIncapable(PawnCapacityDefOf.Manipulation);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, false, false));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch).FailOnDespawnedOrNull(TargetIndex.B));


            Toil toil = Toils_General.Wait(100);

            toil.WithProgressBarToilDelay(TargetIndex.B);
            toil.FailOnDespawnedNullOrForbidden(TargetIndex.B);
            toil.FailOnCannotTouch(TargetIndex.B, PathEndMode.Touch);
            if (job.targetB.IsValid)
            {
                toil.FailOnDespawnedOrNull(TargetIndex.B);
            }
            yield return(toil);

            Toil use = new Toil();

            use.initAction = delegate
            {
                Pawn pawn = job.targetA.Pawn;
                this.Map.GetComponent <ArchotechExtractableAnimals_MapComponent>().RemoveAnimalToCarry(pawn);

                float ParagonOrHybridFactor = 0.5f;

                if (pawn.kindDef.GetModExtension <DefExtension_Hybrid>()?.dominantGenome == pawn.kindDef.GetModExtension <DefExtension_Hybrid>()?.secondaryGenome)
                {
                    ParagonOrHybridFactor = 1f;
                }


                float DNAExtractionFactor = pawn.TryGetComp <CompHybrid>()?.GetDNAExtractionFactor() ?? 0f;

                Building_DNAStorageBank building = (Building_DNAStorageBank)job.targetB.Thing;

                float totalProgress = building.progress + (DNAExtractionFactor * ParagonOrHybridFactor);

                if (totalProgress >= 1)
                {
                    building.progress = 1;
                }
                else
                {
                    building.progress += DNAExtractionFactor * ParagonOrHybridFactor;
                }


                pawn.Destroy();
            };
            use.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(use);

            yield break;
        }
 public static Command_SetGenomeList SetGenomeListCommand(Building_DNAStorageBank building, Map map)
 {
     return(new Command_SetGenomeList()
     {
         defaultDesc = "GR_SelectGenomeToHarvestDesc".Translate(),
         defaultLabel = "GR_SelectGenomeToHarvest".Translate(),
         icon = ContentFinder <Texture2D> .Get("Things/Item/GR_geneticmaterialswhite", true),
         hotKey = KeyBindingDefOf.Misc1,
         map = map,
         building = building
     });
 }
 public static Command_SetAnimalList SetAnimalListCommand(Building_DNAStorageBank building, Map map, ThingDef selectedGenome)
 {
     return(new Command_SetAnimalList()
     {
         defaultDesc = "GR_SelectAnimalToHarvestDesc".Translate(),
         defaultLabel = "GR_SelectAnimalToHarvest".Translate(),
         icon = ContentFinder <Texture2D> .Get("ui/commands/GR_BringAnimal", true),
         hotKey = KeyBindingDefOf.Misc1,
         map = map,
         building = building,
         selectedGenome = selectedGenome
     });
 }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            if (this.Faction == Faction.OfPlayer)
            {
                Command_Action command_Action = new Command_Action();

                command_Action.defaultDesc  = "GR_BeginArchotechGrowthCellDesc".Translate();
                command_Action.defaultLabel = "GR_BeginArchotechGrowthCell".Translate();
                command_Action.icon         = ContentFinder <Texture2D> .Get("Things/Item/GR_ArchoGrowthcell", true);

                command_Action.hotKey = KeyBindingDefOf.Misc1;
                command_Action.action = delegate
                {
                    growthCellProgress = 0;
                    List <Thing> listBanks = this.TryGetComp <CompAffectedByFacilities>()?.LinkedFacilitiesListForReading;
                    foreach (Thing thing in listBanks)
                    {
                        Building_DNAStorageBank bank = thing as Building_DNAStorageBank;
                        bank.progress = 0;
                    }
                };
                if (gizmoDisabled())
                {
                    command_Action.Disable("GR_ArchoFormerDisabledReason".Translate());
                }
                yield return(command_Action);

                if (Prefs.DevMode && this.growthCellProgress != -1)
                {
                    Command_Action command_Action2 = new Command_Action();
                    command_Action2.defaultLabel = "DEBUG: Finish former work";
                    command_Action2.action       = delegate
                    {
                        this.growthCellProgress = 1;
                    };
                    yield return(command_Action);
                }
            }
        }
        public override void Tick()
        {
            base.Tick();

            if (this.IsHashIntervalTick(500))
            {
                List <Thing> listBanks = this.TryGetComp <CompAffectedByFacilities>()?.LinkedFacilitiesListForReading;
                foreach (Thing thing in listBanks)
                {
                    Building_DNAStorageBank bank = thing as Building_DNAStorageBank;
                    if (bank.selectedGenome != null)
                    {
                        if (!FacilitiesAndProgress.ContainsKey(bank.selectedGenome))
                        {
                            FacilitiesAndProgress.Add(bank.selectedGenome, bank.progress);
                        }
                        else
                        {
                            FacilitiesAndProgress[bank.selectedGenome] = bank.progress;
                        }
                    }
                }

                totalGenomeProgress = 0;
                foreach (KeyValuePair <ThingDef, float> entry in FacilitiesAndProgress)
                {
                    totalGenomeProgress += entry.Value;
                }
            }

            if (growthCellProgress != -1)
            {
                this.growthCellProgress += 1f / (GenDate.TicksPerHour * growthCellDuration);
                if (this.growthCellProgress > 1)
                {
                    GenSpawn.Spawn(InternalDefOf.GR_ArchoGrowthcell, this.InteractionCell, this.Map);
                    growthCellProgress = -1;
                }
            }
        }
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            HashSet <ThingDef>          listOfAllEndgameGenomes = new HashSet <ThingDef>();
            HashSet <EndgameGenomesDef> allLists = DefDatabase <EndgameGenomesDef> .AllDefsListForReading.ToHashSet();

            foreach (EndgameGenomesDef element in allLists)
            {
                listOfAllEndgameGenomes.AddRange(element.genomes);
            }



            foreach (ThingDef thing in listOfAllEndgameGenomes)
            {
                list.Add(new FloatMenuOption(thing.LabelCap, delegate
                {
                    bool duplicatedFlag = false;
                    foreach (Thing item in building.Map.listerBuldingOfDefInProximity.GetForCell(building.Position, 30, InternalDefOf.GR_DNAStorageBank))
                    {
                        Building_DNAStorageBank otherBuilding = item as Building_DNAStorageBank;

                        if (otherBuilding.selectedGenome == thing)
                        {
                            duplicatedFlag = true;
                            break;
                        }
                    }

                    if (duplicatedFlag)
                    {
                        Messages.Message("GR_DuplicatedGenomeSelection".Translate(), building, MessageTypeDefOf.NeutralEvent);
                    }
                    else
                    {
                        if (building.selectedGenome != thing)
                        {
                            building.progress = 0f;
                        }
                        building.selectedGenome = thing;
                        building.hasAsked       = false;
                    }
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }



            if (list.Count > 0)
            {
                list = list.OrderBy(item => item.Label).ToList();
            }
            else
            {
                list.Add(new FloatMenuOption("GR_NoEndgameGenomes".Translate(), delegate
                {
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }