public override void Deploy(IZone zone, Player player) { zone.Configuration.IsAlpha.ThrowIfTrue(ErrorCodes.OnlyUnProtectedZonesAllowed); zone.IsUnitWithCategoryInRange(CategoryFlags.cf_gate, player.CurrentPosition, TypeExclusiveRange).ThrowIfTrue(ErrorCodes.GatesAround); CheckBlockingAndThrow(zone, player.CurrentPosition); PBSHelper.CheckWallPlantingAndThrow(zone, zone.Units.ToArray(), player.CurrentPosition, player.CorporationEid); var privateCorporation = player.Character.GetPrivateCorporationOrThrow(); var gate = (Gate)_entityServices.Factory.CreateWithRandomEID(ED.Config.TargetEntityDefault); gate.Owner = privateCorporation.Eid; var position = player.CurrentPosition.Center; zone.UnitService.AddUserUnit(gate, position); Transaction.Current.OnCommited(() => { var beamBuilder = Beam.NewBuilder() .WithType(BeamType.dock_in) .WithSource(player) .WithTarget(gate) .WithState(BeamState.Hit) .WithDuration(TimeSpan.FromSeconds(5)); gate.AddToZone(zone, position, ZoneEnterType.Deploy, beamBuilder); }); }
/// <summary> /// Checks variuos zone and plantrule conditions to plant /// </summary> /// <param name="zone"></param> /// <param name="player"></param> public override void Deploy(IZone zone, Player player) { //plant it under the player _targetPosition = player.CurrentPosition; //this item will plant this plant _targetPlantType = GetTargetPlantType(); _plantRule = zone.Configuration.PlantRules.GetPlantRule(_targetPlantType); if (_plantRule == null) { //the desired plantrule was not found on zone #if DEBUG Logger.Error("consistency error. no plantrule found for seed:" + Definition + " planttype:" + _targetPlantType); #endif //different errormessage for concrete placing _targetPlantType.ThrowIfEqual(PlantType.Devrinol, ErrorCodes.ZoneNotTerraformable); throw new PerpetuumException(ErrorCodes.PlantNotFertileOnThisZone); } //copy units to local for many iterations _currentUnits = zone.Units.ToArray(); //save the players corporationeid to check beta and gamma conditions _corporationEid = player.CorporationEid; if (!_plantRule.PlacesConcrete) { CheckNonConcreteAndThrow(zone); } //these plants can't be placed on alpha if (zone.Configuration.IsAlpha) { (_targetPlantType == PlantType.Devrinol).ThrowIfTrue(ErrorCodes.OnlyUnProtectedZonesAllowed); } else { //on beta and gamma we need corporationeid to match with stuff DefaultCorporationDataCache.IsCorporationDefault(_corporationEid).ThrowIfTrue(ErrorCodes.CharacterMustBeInPrivateCorporation); } if (_targetPlantType == PlantType.Wall) { PBSHelper.CheckWallPlantingAndThrow(zone, _currentUnits, _targetPosition, _corporationEid); } if (_plantRule.PlacesConcrete) { zone.Configuration.Terraformable.ThrowIfFalse(ErrorCodes.ZoneNotTerraformable); PlaceConcreteOrThrow(zone); } else { PutPlantOrThrow(zone, _targetPosition.intX, _targetPosition.intY); } var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.ItemDeploy).SetCharacter(player.Character).SetItem(Definition, 1); player.Character.LogTransaction(b); }