UnpathableTiles() public static method

public static UnpathableTiles ( string name, BuildingInfo buildingInfo, CPos position ) : IEnumerable
name string
buildingInfo BuildingInfo
position CPos
return IEnumerable
Esempio n. 1
0
        public IReadOnlyDictionary <CPos, SubCell> OccupiedCells(ActorInfo info, CPos topLeft, SubCell subCell = SubCell.Any)
        {
            var occupied = FootprintUtils.UnpathableTiles(info.Name, this, topLeft)
                           .ToDictionary(c => c, c => SubCell.FullCell);

            return(new ReadOnlyDictionary <CPos, SubCell>(occupied));
        }
Esempio n. 2
0
        public Building(ActorInitializer init, BuildingInfo info)
        {
            this.self    = init.Self;
            this.topLeft = init.Get <LocationInit, CPos>();
            this.Info    = info;

            occupiedCells = FootprintUtils.UnpathableTiles(self.Info.Name, Info, TopLeft)
                            .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();

            CenterPosition    = init.World.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.World, Info);
            SkipMakeAnimation = init.Contains <SkipMakeAnimsInit>();
        }
Esempio n. 3
0
        public void Killed(Actor self, AttackInfo e)
        {
            var cells = FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location);

            if (info.Delay > 0)
            {
                self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.Delay, () => SpawnExplosions(self.World, cells))));
            }
            else
            {
                SpawnExplosions(self.World, cells);
            }
        }
Esempio n. 4
0
        void INotifyKilled.Killed(Actor self, AttackInfo e)
        {
            if (!self.IsInWorld)
            {
                return;
            }

            if (self.World.SharedRandom.Next(100) > info.Chance)
            {
                return;
            }

            if (info.DeathTypes.Count > 0 && !e.Damage.DamageTypes.Overlaps(info.DeathTypes))
            {
                return;
            }

            var weapon = ChooseWeaponForExplosion(self);

            if (weapon == null)
            {
                return;
            }

            if (weapon.Report != null && weapon.Report.Any())
            {
                Game.Sound.Play(SoundType.World, weapon.Report.Random(e.Attacker.World.SharedRandom), self.CenterPosition);
            }

            if (info.Type == ExplosionType.Footprint && buildingInfo != null)
            {
                var cells = FootprintUtils.UnpathableTiles(self.Info.Name, buildingInfo, self.Location);
                foreach (var c in cells)
                {
                    weapon.Impact(Target.FromPos(self.World.Map.CenterOfCell(c)), e.Attacker, Enumerable.Empty <int>());
                }

                return;
            }

            // Use .FromPos since this actor is killed. Cannot use Target.FromActor
            weapon.Impact(Target.FromPos(self.CenterPosition), e.Attacker, Enumerable.Empty <int>());
        }