Exemple #1
0
        /// <summary> Minifies the package</summary>
        public virtual void Minify()
        {
            Map           map     = parent.Map;
            MinifiedThing package = MinifyUtility.MakeMinified(parent);

            GenPlace.TryPlaceThing(package, parent.Position, map, ThingPlaceMode.Near);
            SoundDef.Named("ThingUninstalled").PlayOneShot(new TargetInfo(parent.Position, map));
        }
Exemple #2
0
 public virtual void MinifyOrDestroy()
 {
     if (base.parent.def.Minifiable)
     {
         Map           map     = parent.Map;
         MinifiedThing package = MinifyUtility.MakeMinified(parent);
         GenPlace.TryPlaceThing(package, parent.Position, map, ThingPlaceMode.Near);
         SoundDef.Named("ThingUninstalled").PlayOneShot(new TargetInfo(parent.Position, map));
     }
     else
     {
         base.parent.Destroy(DestroyMode.KillFinalize);
     }
 }
        protected override void ScatterAt(IntVec3 loc, Map map, int stackCount = 1)
        {
            if (!TryGetRandomValidRotation(loc, map, out Rot4 rot))
            {
                Log.Warning("Could not find any valid rotation for " + thingDef);
                return;
            }
            if (clearSpaceSize > 0)
            {
                using (IEnumerator <IntVec3> enumerator = GridShapeMaker.IrregularLump(loc, map, clearSpaceSize).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Building edifice = GridsUtility.GetEdifice(enumerator.Current, map);
                        if (edifice != null)
                        {
                            edifice.Destroy(0);
                        }
                    }
                }
            }
            Thing thing = ThingMaker.MakeThing(thingDef, stuff);

            if (thingDef.Minifiable)
            {
                thing = MinifyUtility.MakeMinified(thing);
            }
            if (thing.def.category == ThingCategory.Item)
            {
                thing.stackCount = stackCount;
                ForbidUtility.SetForbidden(thing, true, false);
                GenPlace.TryPlaceThing(thing, loc, map, ThingPlaceMode.Near, out Thing thing2, null);
                if (nearPlayerStart && thing2 != null && thing2.def.category == ThingCategory.Item && TutorSystem.TutorialMode)
                {
                    Find.TutorialState.AddStartingItem(thing2);
                    return;
                }
            }
            else
            {
                GenSpawn.Spawn(thing, loc, map, rot, false);
            }
        }
Exemple #4
0
        /// <summary>
        /// Create the produced AI Pawn
        /// </summary>
        private void Create_Building_AIPawn_Inactive()
        {
            ThingDef thingDef = ThingDef.Named(buildingDefName);
            Thing    thing    = ThingMaker.MakeThing(thingDef);

            thing.SetFaction(this.Faction);

            IntVec3 spawnPos = InteractionCell;

            if (thing.def.Minifiable)
            {
                Thing minified = MinifyUtility.MakeMinified(thing);
                thing = minified;
            }

            if (Rotation == Rot4.North)
            {
                // Create the inactive mai R/H of the interaction square
                spawnPos = spawnPos + new IntVec3(1, 0, 0);     // RH 1cell from the interaction cell
                GenSpawn.Spawn(thing, spawnPos, Map, Rot4.East);
            }
            if (Rotation == Rot4.East)
            {
                spawnPos = spawnPos + new IntVec3(0, 0, -1);     // bottom 1cell from the interaction cell
                GenSpawn.Spawn(thing, spawnPos, Map, Rot4.South);
            }
            if (Rotation == Rot4.South)
            {
                spawnPos = spawnPos + new IntVec3(-1, 0, 0);     // LH 1cell from the interaction cell
                GenSpawn.Spawn(thing, spawnPos, Map, Rot4.West);
            }
            if (Rotation == Rot4.West)
            {
                spawnPos = spawnPos + new IntVec3(0, 0, 1);     // top 1cell from the interaction cell
                GenSpawn.Spawn(thing, spawnPos, Map, Rot4.North);
            }
        }