Beispiel #1
0
        public bool TryActivate(RiftNpcGroupInfo info)
        {
            var zone = Zone;

            if (zone == null)
            {
                return(false);
            }

            if (Interlocked.CompareExchange(ref _activated, 1, 0) == 1)
            {
                return(false);
            }

            zone.CreateBeam(BeamType.npc_egg_beam, builder => builder.WithPosition(CurrentPosition).WithDuration(6000));

            Task.Delay(6000).ContinueWith(t =>
            {
                var presence             = (DynamicPoolPresence)zone.PresenceManager.CreatePresence(info.presenceID);
                presence.DynamicPosition = CurrentPosition;
                presence.LifeTime        = info.presenceLifeTime;
                presence.Summoner        = info.ownerPlayer.Character;
                presence.Init(info.wavesCount);

                zone.PresenceManager.AddPresence(presence);
                RemoveFromZone();
            });

            Logger.Info("Rift activated.");
            return(true);
        }
Beispiel #2
0
        public override void Deploy(IZone zone, Player player)
        {
            var rift = player.GetUnitsWithinRange <Rift>(5).FirstOrDefault();

            if (rift == null)
            {
                throw new PerpetuumException(ErrorCodes.RiftOutOfRange);
            }

            var maxRiftLevel = 1;

            if (zone.Configuration.IsAlpha)
            {
                maxRiftLevel = 1;
            }
            else if (zone.Configuration.IsBeta)
            {
                maxRiftLevel = 2;
                if (zone.Configuration.Id > 8 && zone.Configuration.Id < 12)
                {
                    maxRiftLevel = 3; //TODO fixme move to DB!
                    Logger.Info("LEVEL 3 RIFT ON BETA!");
                }
            }
            else if (zone.Configuration.IsGamma)
            {
                maxRiftLevel = 3;
            }


            if (ED.Tier.level > maxRiftLevel)
            {
                throw new PerpetuumException(ErrorCodes.RiftLevelMismatch);
            }

            var info = new RiftNpcGroupInfo();

            Debug.Assert(DeployableItemEntityDefault.Config.npcPresenceId != null, "DeployableItemEntityDefault.Config.npcPresenceId != null");
            info.presenceID = (int)DeployableItemEntityDefault.Config.npcPresenceId;
            Debug.Assert(DeployableItemEntityDefault.Config.lifeTime != null, "DeployableItemEntityDefault.Config.lifeTime != null");
            info.presenceLifeTime = TimeSpan.FromMilliseconds((double)DeployableItemEntityDefault.Config.lifeTime);
            Debug.Assert(DeployableItemEntityDefault.Config.waves != null, "DeployableItemEntityDefault.Config.waves != null");
            info.wavesCount  = (int)DeployableItemEntityDefault.Config.waves;
            info.ownerPlayer = player;

            if (!rift.TryActivate(info))
            {
                throw new PerpetuumException(ErrorCodes.WTFErrorMedicalAttentionSuggested);
            }

            LogTransaction(player, this);

            var seei = new SummonEggEventInfo(player, DeployableItemEntityDefault.Definition, player.CurrentPosition);

            player.MissionHandler.EnqueueMissionEventInfo(seei);
        }