Exemplo n.º 1
0
        public void CheckDefinitionRelatedConditionsOrThrow(IZone zone, Position spawnPosition, long owner)
        {
            //the egg WILL build this pbsNode after activation
            var pbsNodeEntityDefault = TargetPBSNodeDefault;

            if (pbsNodeEntityDefault == EntityDefault.None)
            {
                Logger.Error("pbsNodeDefinition was not found:" + pbsNodeEntityDefault + " in egg:" + Definition + " " + ED.Name);
                throw new PerpetuumException(ErrorCodes.ConsistencyError);
            }


            if (pbsNodeEntityDefault.CategoryFlags.IsCategory(CategoryFlags.cf_pbs_docking_base))
            {
                //check deploying of bases
                PBSHelper.ValidatePBSDockingBasePlacement(zone, spawnPosition, owner, pbsNodeEntityDefault).ThrowIfError();
                return;
            }

            //kiveve amiket lehet kivulre pakolni
            if (!PBSHelper.IsPlaceableOutsideOfBase(pbsNodeEntityDefault.CategoryFlags))
            {
                //checks for corporation's docking base in range
                PBSHelper.ValidatePBSNodePlacing(zone, spawnPosition, owner, pbsNodeEntityDefault).ThrowIfError();
            }

            //itt meg lehet mast is megnezni egyelore nem kellett
        }
        private PBSConnection[] ReadConnectionsFromSql()
        {
            var connections = PBSHelper.LoadConnectionsFromSql(_pbsObject.Zone, _pbsObject.Eid).ToArray();

            WriteLog("sql read connections " + _pbsObject.ED.Name + " " + connections.Length);
            return(connections);
        }
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var sourceEid = request.Data.GetOrDefault <long>(k.source);
                var targetEid = request.Data.GetOrDefault <long>(k.target);
                var character = request.Session.Character;

                var sourceUnit = request.Zone.GetUnitOrThrow(sourceEid);
                var targetUnit = request.Zone.GetUnitOrThrow(targetEid);

                var sourceNode = sourceUnit.ThrowIfNotType <IPBSObject>(ErrorCodes.DefinitionNotSupported);
                sourceNode.ConnectionHandler.NetworkNodes.Any(n => n.IsReinforced()).ThrowIfTrue(ErrorCodes.NetworkHasReinforcedNode);

                var targetNode = targetUnit.ThrowIfNotType <IPBSObject>(ErrorCodes.DefinitionNotSupported);
                sourceNode.ConnectionHandler.BreakConnection(targetNode, character);

                Transaction.Current.OnCommited(() =>
                {
                    sourceNode.SendNodeUpdate();
                    PBSHelper.WritePBSLog(PBSLogType.disconnected, sourceUnit.Eid, sourceUnit.Definition, sourceUnit.Owner, character.Id, otherNodeEid: targetUnit.Eid, otherNodeDefinition: targetUnit.Definition, zoneId: request.Zone.Id);
                });

                Message.Builder.FromRequest(request).WithOk().Send();
                scope.Complete();
            }
        }
Exemplo n.º 4
0
        //ellenorizz per request %%% nem kellenek ezek a boolok
        public void SetOnlineStatus(bool state, bool checkNofBase, bool forcedByServer = false)
        {
            if (OnlineStatus == state)
            {
                return;
            }

            if (!forcedByServer)
            {
                if (!state)
                {
                    if (PBSHelper.IsOfflineOnReinforce(_pbsUnit))
                    {
                        _pbsUnit.IsReinforced().ThrowIfTrue(ErrorCodes.NotPossibleDuringReinforce);
                    }
                }
            }

            if (checkNofBase)
            {
                _pbsUnit.ConnectionHandler.NetworkNodes.Any(n => n is PBSDockingBase).ThrowIfFalse(ErrorCodes.NoBaseInNetwork);
            }

            OnlineStatus = state;
        }
        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);
            });
        }
 private void GoOfflineOnReinforce(T pbsUnitObject)
 {
     if (PBSHelper.IsOfflineOnReinforce(pbsUnitObject))
     {
         //go offline if the node is in reinforce
         pbsUnitObject.SetOnlineStatus(false, false, true);
     }
 }
        public void DoTerraform(IZone zone)
        {
            var x = FastRandom.NextInt(_workArea.Width - 1);
            var y = FastRandom.NextInt(_workArea.Height - 1);
            var p = new Position(x, y);

            PBSHelper.DegradeTowardsOriginal(zone, p);
        }
Exemplo n.º 8
0
        protected override void OnDead(Unit killer)
        {
            var zone = Zone;

            PBSHelper.OnPBSEggRemoved(zone, this);

            base.OnDead(killer);
        }
        private void LogWrite(PBSLogType logType)
        {
            var zone = _pbsUnit.Zone;

            if (zone != null)
            {
                PBSHelper.WritePBSLog(logType, _pbsUnit.Eid, _pbsUnit.Definition, _pbsUnit.Owner, zoneId: zone.Id);
            }
        }
Exemplo n.º 10
0
        protected override void OnEnterZone(IZone zone, ZoneEnterType enterType)
        {
            if (enterType == ZoneEnterType.Deploy)
            {
                PBSHelper.OnPBSEggDeployed(Zone, this);
            }

            base.OnEnterZone(zone, enterType);
        }
Exemplo n.º 11
0
        protected override void OnRemovedFromZone(IZone zone)
        {
            if (!_successfulSummon)
            {
                PBSHelper.OnPBSEggRemoved(zone, this);
            }

            base.OnRemovedFromZone(zone);
        }
Exemplo n.º 12
0
        private void OnConstructionLevelChanged()
        {
            var zone = _pbsUnit.Zone;

            if (zone == null)
            {
                return;
            }

            var currentLevel = ConstructionLevelCurrent;

            if (currentLevel <= 0)
            {
                //object got deconstructed, remove from zone, add capsule to loot

                if (_contructionLootDropped)
                {
                    return;
                }

                _contructionLootDropped = true;

                using (var scope = Db.CreateTransaction())
                {
                    LootContainer.Create()
                    .AddLoot(PBSHelper.GetCapsuleDefinitionByPBSObject(_pbsUnit), 1)
                    .AddLoot(PBSHelper.GetConstructionAmmoLootOnDeconstruct(_pbsUnit))
                    .BuildAndAddToZone(zone, _pbsUnit.CurrentPosition);

                    var dockingBase = _pbsUnit as PBSDockingBase;
                    if (dockingBase != null)
                    {
                        Logger.DebugInfo("dropping loot from base");
                        PBSHelper.DropLootToZoneFromBaseItems(zone, dockingBase, false);
                    }
                    _pbsUnit.RemoveFromZone();

                    Logger.Info("pbs node got deconstructed. " + _pbsUnit.Eid + " " + _pbsUnit.ED.Name + " owner:" + _pbsUnit.Owner);
                    PBSHelper.WritePBSLog(PBSLogType.deconstructed, _pbsUnit.Eid, _pbsUnit.Definition, _pbsUnit.Owner, zoneId: zone.Id);

                    scope.Complete();
                }

                return;
            }

            if (!IsFullyConstructed)
            {
                return;
            }

            SetToDeconstruct(); //felepult, mostmar lehet lebontani is vagy barmi

            PBSHelper.WritePBSLog(PBSLogType.constructed, _pbsUnit.Eid, _pbsUnit.Definition, _pbsUnit.Owner, zoneId: zone.Id);
            SendNodeUpdate();
        }
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var sourceEid = request.Data.GetOrDefault <long>(k.eid);
                var character = request.Session.Character;
                var state     = request.Data.GetOrDefault <int>(k.state) == 1;

                var sourceUnit = request.Zone.GetUnitOrThrow(sourceEid);
                var sourceNode = (sourceUnit as IPBSObject).ThrowIfNull(ErrorCodes.DefinitionNotSupported);

                sourceNode.IsFullyConstructed().ThrowIfFalse(ErrorCodes.ObjectNotFullyConstructed);
                sourceNode.CheckAccessAndThrowIfFailed(character);

                if (PBSHelper.IsOfflineOnReinforce(sourceUnit))
                {
                    //ezeket nem lehet kapcsolgatni ha reinforceban vannak
                    sourceNode.ReinforceHandler.CurrentState.IsReinforced.ThrowIfTrue(ErrorCodes.NotPossibleDuringReinforce);
                }

                if (sourceNode.OnlineStatus != state)
                {
                    if (state)
                    {
                        //be akarunk valamit kapcsolni
                        //ez a node akkor mehet csak onlineba ha nem rothadt ki alatta a mineral mar 1x
                        var energyWell = sourceUnit as PBSEnergyWell;
                        energyWell?.IsDepleted.ThrowIfTrue(ErrorCodes.EnergyWellDepleted);
                    }

                    sourceNode.SetOnlineStatus(state, true);
                    sourceUnit.Save();

                    Transaction.Current.OnCommited(() =>
                    {
                        sourceNode.SendNodeUpdate();
                        var logType = state ? PBSLogType.online : PBSLogType.offline;
                        PBSHelper.WritePBSLog(logType, sourceEid, sourceUnit.Definition, sourceUnit.Owner, character.Id, background: false, zoneId: request.Zone.Id);
                    });
                }

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
            public override void Exit()
            {
                ReinforceHandler._pbsUnit.OrphanedStateChanged -= OnOrphanedStateChanged;
                ReinforceHandler._pbsUnit.DynamicProperties.Update(k.isReinforced, 0);
                ReinforceHandler._pbsUnit.DynamicProperties.Update(k.reinforceEnd, default(DateTime));
                ReinforceHandler._pbsUnit.States.Reinforced = false;

                ReinforceHandler.StartAsyncLog(PBSLogType.reinforceEnd);
                ReinforceHandler.SetNextReinforceCounterIncreaseFromNow(VULNERABLE_LENGTH_MINUTES);

                if (PBSHelper.IsOfflineOnReinforce(ReinforceHandler._pbsUnit))
                {
                    //go online if the node is leaving reinforce
                    ReinforceHandler._pbsUnit.SetOnlineStatus(true, false, true);
                }

                base.Exit();
            }
        private bool IsAnyNodeOutsideOfNetworkRange(IEnumerable <IPBSObject> pbsObjects, PBSDockingBase pbsDockingBase)
        {
            foreach (var pbsObject in pbsObjects)
            {
                var unit = (Unit)pbsObject;

                if (PBSHelper.IsPlaceableOutsideOfBase((unit.ED.CategoryFlags)))
                {
                    continue;
                }

                if (!unit.CurrentPosition.IsInRangeOf2D(pbsDockingBase.CurrentPosition, pbsDockingBase.GetNetworkNodeRange()))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 16
0
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var sourceEid = request.Data.GetOrDefault <long>(k.source);
                var targetEid = request.Data.GetOrDefault <long>(k.target);
                var character = request.Session.Character;

                var sourceUnit = request.Zone.GetUnitOrThrow(sourceEid);
                var targetUnit = request.Zone.GetUnitOrThrow(targetEid);;

                if (sourceUnit is IPBSObject sourceNode && targetUnit is IPBSObject targetNode)
                {
                    try
                    {
                        sourceNode.ConnectionHandler.MakeConnection(targetNode, character);
                        PBSHelper.WritePBSLog(PBSLogType.connected, sourceUnit.Eid, sourceUnit.Definition,
                                              sourceUnit.Owner, character.Id, otherNodeEid: targetUnit.Eid,
                                              otherNodeDefinition: targetUnit.Definition, zoneId: request.Zone.Id, background: false);

                        Transaction.Current.OnCommited(() => sourceNode.SendNodeUpdate());
                    }
                    catch (PerpetuumException gex)
                    {
                        if (gex.error != ErrorCodes.DockingBaseExistsInNetwork)
                        {
                            throw;
                        }

                        foreach (var node in targetNode.ConnectionHandler.NetworkNodes.OfType <Unit>())
                        {
                            node.Owner = targetUnit.Owner;
                        }

                        throw;
                    }
                }

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
Exemplo n.º 17
0
        public void HandleRequest(IRequest request)
        {
            var offsetInDays = request.Data.GetOrDefault <int>(k.offset);
            var zoneId       = request.Data.GetOrDefault <int>(k.zoneID);

            var corporationEid = request.Session.Character.CorporationEid;

            DefaultCorporationDataCache.IsCorporationDefault(corporationEid).ThrowIfTrue(ErrorCodes.CharacterMustBeInPrivateCorporation);

            var role = Corporation.GetRoleFromSql(request.Session.Character);

            role.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO, CorporationRole.viewPBS).ThrowIfFalse(ErrorCodes.InsufficientPrivileges);

            var history = PBSHelper.GetPBSLog(offsetInDays, corporationEid, zoneId);

            Message.Builder.FromRequest(request).WithData(new Dictionary <string, object> {
                { k.history, history }
            }).WrapToResult().Send();
        }
        private void AreaTestProgramCodeSourceMethod(int cx, int cy, IZoneRequest request)
        {
            var testArea = Area.FromRadius(cx, cy, 300);

            testArea = testArea.Clamp(request.Zone.Size);

            var counter = 0;

            testArea.ForEachXY((x, y) =>
            {
                if (counter++ % 2 == 0)
                {
                    PBSHelper.DegradeTowardsOriginal(request.Zone, new Position(x, y));
                }
            });

            var info = new Dictionary <string, object> {
                { k.message, "Thread finished. Time to fetch altitude!" }
            };

            Message.Builder.FromRequest(request).WithData(info).Send();
        }
Exemplo n.º 19
0
        protected override Unit CreateDeployableItem(IZone zone, Position spawnPosition, Player player)
        {
            var corporationEid = player.CorporationEid;

            DefaultCorporationDataCache.IsCorporationDefault(corporationEid).ThrowIfTrue(ErrorCodes.CharacterMustBeInPrivateCorporation);

            var pbsEgg = (PBSEgg)base.CreateDeployableItem(zone, spawnPosition, player);

            //let the egg check the conditions by type
            pbsEgg.CheckDefinitionRelatedConditionsOrThrow(zone, spawnPosition, corporationEid);

            var pbsObjectDefinition = PBSHelper.GetPBSObjectDefinitionFromCapsule(ED);

            var pbsEd = EntityDefault.Get(pbsObjectDefinition);

            //check zone for conditions
            PBSHelper.CheckZoneForDeployment(zone, spawnPosition, pbsEd).ThrowIfError();

            //pass owner
            pbsEgg.DeployerPlayer = player;

            //all conditions match return the egg and continue placing it to the zone
            return(pbsEgg);
        }
Exemplo n.º 20
0
        private void DamageWallOnTile(ref PlantInfo plantInfo, ref BlockingInfo blockInfo, int x, int y)
        {
            if (plantInfo.type == PlantType.NotDefined)
            {
                return;
            }

            var plantRule = _zone.Configuration.PlantRules.GetPlantRule(plantInfo.type);

            if (plantRule == null)
            {
                return;
            }

            //is it wall?
            if (!plantRule.AllowedOnNonNatural)
            {
                return;
            }

            //only degrades in the last few phases
            if (!plantInfo.IsWallInLastFewStates(plantRule))
            {
                return;
            }

            var globalX = x + _area.X1;
            var globalY = y + _area.Y1;

            //pbs might save it
            if (_pbsPositions != null && _pbsPositions.Count > 0)
            {
                if (PBSHelper.IsPBSInRange(_wallDistanceFromPBS, _pbsPositions, globalX, globalY))
                {
                    var closestPBSDistance = PBSHelper.GetMinimalDistance(_pbsPositions, globalX, globalY);

                    if (closestPBSDistance <= _intactDistance)
                    {
                        //pbs object in intact distance, wall is protected
                        return;
                    }

                    //in fading range

                    //near 1 .. far 0
                    var chanceToSurvive = 1 - ((closestPBSDistance - _intactDistance) / _gradientRange);

                    var random = FastRandom.NextDouble();

                    if (random < chanceToSurvive)
                    {
                        //it will happen inwards more often

                        //so the plant wont get unhealed as it is closer to a pbs but within the range
                        return;
                    }
                }
            }



            plantInfo.UnHealPlant();

            if (plantInfo.health > 0)
            {
                return;
            }

            blockInfo.Plant  = false;
            blockInfo.Height = 0;

            plantInfo.Clear();
            plantInfo.state = 1;
        }
        /// <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);
        }
 public static bool IsPlaceableOutsideOfDockingbaseRange(this Unit unit)
 {
     return(PBSHelper.IsPlaceableOutsideOfBase(unit.ED.CategoryFlags));
 }
 protected virtual int CollectProductionLevel()
 {
     return(PBSHelper.CollectFacilityNodeLevelFromInComingConnections(this));
 }
 public virtual int GetFacilityLevelBase()
 {
     return(PBSHelper.LazyInitProductionLevelBase(this, ref _productionLevelBase));
 }
Exemplo n.º 25
0
        protected override void PBSActiveObjectAction(IZone zone)
        {
            if (IsDepleted)
            {
                return; //kifogyott alola a mineral
            }
            _lastCoreUsed = 0;

            // van-e reaktor a networkbe akinek hianyzik egy toltes
            var reactors = ConnectionHandler.NetworkNodes.OfType <PBSReactor>().Where(r => (r.CoreMax - r.Core) > CoreTransferred && r.OnlineStatus).ToList();

            if (reactors.Count == 0)
            {
                return; //no reactor to feed
            }
            var mineralLayer = zone.Terrain.GetMaterialLayer(MaterialType.EnergyMineral) as MineralLayer;

            if (mineralLayer == null)
            {
                Logger.Error("mineral not found on zone " + MaterialType.EnergyMineral + " zoneID:" + zone.Configuration.Id);
                return;
            }

            //egy ciklusra mennyit banyaszik ebbol a fajtabol
            //ennyit akar maximum kiszedni a sok csempebol
            var extractedMaterials = ExtractWithinRange(mineralLayer, CurrentPosition, WorkRange, (uint)CoreTransferred);

            if (extractedMaterials.Count <= 0)
            {
                //nemtom, barmi, le is kapcsolhatja magat
                _wasMineralCollected = false;

                IsDepleted = true;
                //mineral got depleted
                Logger.Info("energy well got depleted " + this);
                SetOnlineStatus(false, false);
                PBSHelper.WritePBSLog(PBSLogType.wellDepleted, Eid, Definition, Owner, zoneId: zone.Configuration.Id);
                return;
            }

            //juhe volt mineral, pakoljunk coret a network reactorjaiba
            var sumCollected = extractedMaterials.Sum(i => (double)i.Quantity);

            Logger.Info(sumCollected + " mineral was drilled by " + ED.Name);

            sumCollected *= TransferEfficiency;
            Logger.Info(sumCollected + " core will be distributed ");

            var amountPerReactor = sumCollected / reactors.Count;

            Logger.Info(reactors.Count + " reactors. per node amount: " + amountPerReactor);

            foreach (var pbsReactor in reactors)
            {
                pbsReactor.CoreFromEnergyWell((int)amountPerReactor);
            }

            //output
            _lastCoreUsed        = sumCollected;
            _wasMineralCollected = true;
        }
        public void HandleRequest(IZoneRequest request)
        {
            var ec         = ErrorCodes.NoError;
            var character  = request.Session.Character;
            var definition = request.Data.GetOrDefault <int>(k.definition);
            var x          = request.Data.GetOrDefault <int>(k.x);
            var y          = request.Data.GetOrDefault <int>(k.y);
            var info       = request.Data.GetOrDefault(k.info, new Dictionary <string, object>());

            var dc = EntityDefault.Get(definition).Config;

            if (dc.constructionRadius == null || dc.blockingradius == null)
            {
                Logger.Error("consistency error. no constructionradius or blockingradius is defined for definition:" + definition);
                throw PerpetuumException.Create(ErrorCodes.ConsistencyError).SetData(info);
            }

            character.GetPrivateCorporationOrThrow()
            .GetMemberRole(character)
            .IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO, CorporationRole.editPBS)
            .ThrowIfFalse(ErrorCodes.InsufficientPrivileges, gex => gex.SetData(info));

            var position = new Position(x, y).Center;

            var ed = EntityDefault.Get(definition);


            List <Position> badSlopes;
            List <Position> badBlocks;

            if ((ec = PBSHelper.CheckZoneForDeployment(request.Zone, position, ed, out badSlopes, out badBlocks, true)) != ErrorCodes.NoError)
            {
                info.Add(k.zoneID, request.Zone.Id);

                if (badBlocks.Count > 0)
                {
                    var array = badBlocks.SelectMany(p => new[] { p.intX, p.intY }).ToArray();
                    info.Add(k.blocks, array);
                }

                if (badSlopes.Count > 0)
                {
                    var array = badSlopes.SelectMany(p => new[] { p.intX, p.intY }).ToArray();
                    info.Add(k.slope, array);
                }

                throw PerpetuumException.Create(ec).SetData(info);
            }

            request.Zone.CreateBeam(BeamType.artifact_found, builder => builder.WithPosition(position).WithVisibility(200).WithDuration(1337));

            var result = new Dictionary <string, object>
            {
                { k.message, k.oke }
            };

            if (info.Count > 0)
            {
                result.Add(k.info, info);
            }

            Message.Builder.FromRequest(request).WithData(result).Send();
        }
 public int GetLevelIncrease()
 {
     return(PBSHelper.LazyInitProductionLevelIncrease(this, ref _levelIncrease));
 }
Exemplo n.º 28
0
 public int GetChargeAmount()
 {
     return(PBSHelper.LazyInitChargeAmount(this, ref _chargeAmount));
 }
Exemplo n.º 29
0
 public void FeedWithItems(Player player, IEnumerable <long> eids)
 {
     PBSHelper.FeedWithItems(this, player, eids);
 }
            private void DoEnter()
            {
                var pbsUnitObject = ReinforceHandler._pbsUnit;

                var zone = pbsUnitObject.Zone;

                if (zone == null)
                {
                    return;
                }

                //ettol van rajta a grafikai effekt
                pbsUnitObject.States.Reinforced = true;

                pbsUnitObject.DynamicProperties.Set(k.isReinforced, 1);

                //if already set by the init, then we skip this part
                if (_reinforceEnd.Equals(default(DateTime)))
                {
                    Logger.Info(" fresh reinforce start for " + pbsUnitObject);

                    var killer = _reinforceStartedBy?.Id;

                    //sql log
                    PBSHelper.WritePBSLog(PBSLogType.reinforceStart, pbsUnitObject.Eid, pbsUnitObject.Definition, pbsUnitObject.Owner, zoneId: zone.Configuration.Id, killerCharacterId: killer);


                    var oldCounter = ReinforceHandler.ReinforceCounter;
                    //elveszunk egy lehetoseget
                    ReinforceHandler.DecreaseReinforceCounter();
                    var newCounter = ReinforceHandler.ReinforceCounter;

                    //kozoljuk, h mikor lesz a kovetkezo reinforce increase
                    ReinforceHandler.SetNextReinforceCounterIncreaseFromNow(VULNERABLE_LENGTH_MINUTES + REINFORCE_LENGTH_MINUTES);

                    Logger.Info("reinforce counter from:" + oldCounter + " to:" + newCounter + " " + pbsUnitObject.ED.Name);

                    var networkNodes = pbsUnitObject.ConnectionHandler.NetworkNodes.ToArray();

                    if (networkNodes.Length > 1)
                    {
                        //ez egy networkben levo node

                        //ez a bazis a networkben
                        var pbsDockingBase = networkNodes.FirstOrDefault(o => o is PBSDockingBase);

                        if (pbsDockingBase != null)
                        {
                            //van bazis a networkben
                            //abban van a napi offset beallitva

                            if (!pbsDockingBase.Equals(pbsUnitObject))
                            {
                                //not myself
                                ReinforceHandler._offsetHoursWithinDay = pbsDockingBase.ReinforceHandler.ReinforceOffsetHours; //transfer the daily offset from the base

                                Logger.Info("daily offset was transferred from base to:" + pbsUnitObject.ED.Name + " " + pbsUnitObject.Name);
                            }


                            //search for the first reinforced node
                            foreach (var networkNode in networkNodes)
                            {
                                if (networkNode.Equals(pbsUnitObject))
                                {
                                    continue;
                                }

                                if (!networkNode.ReinforceHandler.CurrentState.IsReinforced)
                                {
                                    continue;
                                }

                                //ebben a nodeban van, hogy mikor lesz vege a reinforcenak
                                var tmpEnd = networkNode.ReinforceHandler.GetReinforceDetails();


                                if (!tmpEnd.Equals(default(DateTime)) && DateTime.Now < tmpEnd)
                                {
                                    _reinforceEnd = tmpEnd;

                                    Logger.Info(" ");
                                    Logger.Info(" reinforceEnd:" + _reinforceEnd);
                                    Logger.Info("reinforce timer transferred to:" + pbsUnitObject);

                                    GoOfflineOnReinforce(pbsUnitObject);

                                    return;
                                }
                            }
                        }
                    }

                    //ez az ag amikor egyedul van a networkben a node amit megtamadtak
                    //vagy nem volt node ami meghatarozta volna az ertekeket


                    _reinforceEnd = CalculateReinforceEnd();

                    Logger.Info("reinforceEnd:" + _reinforceEnd);
                    Logger.Info("node switches to reinforced: " + pbsUnitObject.Name + " " + pbsUnitObject.Eid + " " + pbsUnitObject.ED.Name);
                }
                else
                {
                    Logger.Info("ACTIVE REINFORCE STATE: skipping inital round, this is a server restart " + pbsUnitObject.Eid + " " + pbsUnitObject.Name);
                }

                GoOfflineOnReinforce(pbsUnitObject);
            }