public Building(ActorInitializer init, BuildingInfo info) { self = init.Self; topLeft = init.Get <LocationInit, CPos>(); Info = info; occupiedCells = Info.UnpathableTiles(TopLeft) .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied) .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World); SkipMakeAnimation = init.Contains <SkipMakeAnimsInit>(); }
void INotifyKilled.Killed(Actor self, AttackInfo e) { if (IsTraitDisabled || !self.IsInWorld) { return; } if (self.World.SharedRandom.Next(100) > Info.Chance) { return; } if (!Info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes)) { return; } var weapon = ChooseWeaponForExplosion(self); if (weapon == null) { return; } var source = Info.DamageSource == DamageSource.Self ? self : e.Attacker; if (weapon.Report != null && weapon.Report.Any()) { Game.Sound.Play(SoundType.World, weapon.Report.Random(source.World.SharedRandom), self.CenterPosition); } if (Info.Type == ExplosionType.Footprint && buildingInfo != null) { var cells = buildingInfo.UnpathableTiles(self.Location); foreach (var c in cells) { weapon.Impact(Target.FromPos(self.World.Map.CenterOfCell(c)), source, Enumerable.Empty <int>()); } return; } // Use .FromPos since this actor is killed. Cannot use Target.FromActor weapon.Impact(Target.FromPos(self.CenterPosition), source, Enumerable.Empty <int>()); }