Ejemplo n.º 1
0
 public void BeginSpreadingTransition(GasCloud parentCloud, IntVec3 targetPosition)
 {
     interpolatedOffsetX.value = parentCloud.Position.x - targetPosition.x;
     interpolatedOffsetY.value = parentCloud.Position.z - targetPosition.z;
     interpolatedOffsetX.StartInterpolation(0, SpreadingAnimationDuration, CurveType.QuinticOut);
     interpolatedOffsetY.StartInterpolation(0, SpreadingAnimationDuration, CurveType.QuinticOut);
 }
Ejemplo n.º 2
0
        private bool TileIsGasTraversible(IntVec3 pos, Map map, GasCloud sourceCloud)
        {
            if (!pos.InBounds(map) || !map.pathGrid.WalkableFast(pos))
            {
                return(false);
            }
            var thingList = map.thingGrid.ThingsListAtFast(pos);

            for (var i = 0; i < thingList.Count; i++)
            {
                var thing = thingList[i];
                // check for conditionally traversable buildings
                var building = thing as Building;
                if (building != null)
                {
                    TraversibilityTest travTest;
                    TraversibleBuildings.TryGetValue(building.GetType(), out travTest);
                    if (travTest != null && !travTest(building, sourceCloud))
                    {
                        return(false);
                    }
                }
                // check for more concentrated gases of a different def
                var cloud = thing as GasCloud;
                if (cloud != null && cloud.def != sourceCloud.def && sourceCloud.concentration < cloud.concentration)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public new bool TryDoSpawn()
        {
            if (!this.parent.Spawned)
            {
                return(false);
            }
            if (this.PropsSpawner.spawnMaxAdjacent >= 0)
            {
                int num = 0;
                for (int i = 0; i < 9; i++)
                {
                    IntVec3 c = this.parent.Position + GenAdj.AdjacentCellsAndInside[i];
                    if (c.InBounds(this.parent.Map))
                    {
                        List <Thing> thingList = c.GetThingList(this.parent.Map);
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            if (thingList[j].def == this.PropsSpawner.thingToSpawn)
                            {
                                num += thingList[j].stackCount;
                                if (num >= this.PropsSpawner.spawnMaxAdjacent)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            IntVec3 center;

            if (CompSpawner.TryFindSpawnCell(this.parent, this.PropsSpawner.thingToSpawn, this.PropsSpawner.spawnCount, out center))
            {
                Thing thing = ThingMaker.MakeThing(this.PropsSpawner.thingToSpawn, null);
                thing.stackCount = this.PropsSpawner.spawnCount;
                if (thing == null)
                {
                    Log.Error("Could not spawn anything for " + this.parent, false);
                }
                if (this.PropsSpawner.inheritFaction && thing.Faction != this.parent.Faction)
                {
                    thing.SetFaction(this.parent.Faction, null);
                }
                Thing t;
                GenPlace.TryPlaceThing(thing, center, this.parent.Map, ThingPlaceMode.Direct, out t, null, null, default(Rot4));
                if (this.PropsSpawner.spawnForbidden)
                {
                    t.SetForbidden(true, true);
                }
                if (this.PropsSpawner.showMessageIfOwned && this.parent.Faction == Faction.OfPlayer)
                {
                    Messages.Message("MessageCompSpawnerSpawnedItem".Translate(this.PropsSpawner.thingToSpawn.LabelCap), thing, MessageTypeDefOf.PositiveEvent, true);
                }
                GasCloud cloud = t as GasCloud;
                if (cloud != null)
                {
                    cloud.ReceiveConcentration(this.PropsSpawner.spawnConcentration);
                }
                return(true);
            }
            return(false);
        }