public Building(ActorInitializer init, BuildingInfo info) { self = init.Self; topLeft = init.Get <LocationInit, CPos>(); Info = info; influence = self.World.WorldActor.Trait <BuildingInfluence>(); 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 attackInfo) { if (IsTraitDisabled || !self.IsInWorld) { return; } if (self.World.SharedRandom.Next(100) > Info.Chance) { return; } if (Info.DeathTypes.Count > 0 && !attackInfo.Damage.DamageTypes.Overlaps(Info.DeathTypes)) { return; } var weapon = ChooseWeaponForExplosion(self); if (weapon == null) { return; } if (weapon.Report != null && weapon.Report.Any()) { WarGame.Sound.Play(SoundType.World, weapon.Report.Random(attackInfo.Attacker.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)), attackInfo.Attacker, Enumerable.Empty <int>()); } return; } //Use .FromPos since this actor is killed,Cannot use Target.FromActor. weapon.Impact(Target.FromPos(self.CenterPosition), attackInfo.Attacker, Enumerable.Empty <int>()); }