Ejemplo n.º 1
0
        internal static void LogGenerationData()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Qualities for trader items");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(new Func <QualityCategory>(QualityUtility.RandomTraderItemQuality)));
            foreach (PawnKindDef pk in DefDatabase <PawnKindDef> .AllDefs)
            {
                if (pk.RaceProps.Humanlike)
                {
                    stringBuilder.AppendLine("Qualities for items generated for pawn kind " + pk.defName);
                    stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.RandomGeneratedGearQuality(pk)));
                    stringBuilder.AppendLine();
                }
            }
            int level;

            for (level = 0; level <= 20; level++)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("Creation qualities for worker at level " + level);
                stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.RandomCreationQuality(level)));
            }
            Log.Message(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        public void CompleteConstruction(Pawn worker)
        {
            this.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            if (this.GetStatValue(StatDefOf.WorkToBuild, true) > 150.0 && base.def.entityDefToBuild is ThingDef && ((ThingDef)base.def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.BuildingComplete.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            ThingDef thingDef = base.def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    int level = worker.skills.GetSkill(SkillDefOf.Construction).Level;
                    compQuality.SetQuality(QualityUtility.RandomCreationQuality(level), ArtGenerationContext.Colony);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)this.HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, false);
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)base.def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            if (thingDef != null && (thingDef.passability == Traversability.Impassable || thingDef.Fillage == FillCategory.Full) && (thing == null || !(thing is Building_Door)))
            {
                foreach (IntVec3 item in GenAdj.CellsOccupiedBy(base.Position, base.Rotation, base.def.Size))
                {
                    foreach (Thing item2 in map.thingGrid.ThingsAt(item).ToList())
                    {
                        if (item2 is Plant)
                        {
                            item2.Destroy(DestroyMode.KillFinalize);
                        }
                        else if (item2.def.category == ThingCategory.Item || item2 is Pawn)
                        {
                            GenPlace.TryMoveThing(item2, item2.Position, item2.Map);
                        }
                    }
                }
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild, true) >= 10000.0)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }