Exemplo n.º 1
0
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            if ((character.Stats[StatIds.externaldoorinstance].Value == 0)
                || (character.Stats[StatIds.externalplayfieldinstance].Value == 0))
            {
                ChatTextMessageHandler.Default.Create(character, "Please enter a proxyfied playfield first.");
            }

            Coordinate tempCoordinate = character.Coordinates();
            PlayfieldData pfData = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
            StatelData o = null;
            foreach (StatelData s in pfData.Statels)
            {
                if (o == null)
                {
                    o = s;
                }
                else
                {
                    if (Coordinate.Distance2D(tempCoordinate, s.Coord())
                        < Coordinate.Distance2D(tempCoordinate, o.Coord()))
                    {
                        o = s;
                    }
                }
            }
            if (o == null)
            {

                ChatTextMessageHandler.Default.Create(
                    character,
                    "No statel on this playfield... Very odd, where exactly are you???");

            }
            else
            {
                DBTeleport tel = new DBTeleport();
                tel.playfield = character.Stats[StatIds.externalplayfieldinstance].Value;
                tel.statelType = 0xc748; // Door only for now
                tel.statelInstance = character.Stats[StatIds.externaldoorinstance].BaseValue;
                tel.destinationPlayfield = o.PlayfieldId;
                tel.destinationType = (int)o.Identity.Type;
                tel.destinationInstance = BitConverter.ToUInt32(BitConverter.GetBytes(o.Identity.Instance), 0);

                var temp = TeleportDao.Instance.GetWhere(new { tel.playfield, tel.statelType, tel.statelInstance });
                foreach (var t in temp)
                {
                    TeleportDao.Instance.Delete(t.Id);
                }
                TeleportDao.Instance.Add(tel);
                character.Playfield.Publish(
            ChatTextMessageHandler.Default.CreateIM(character, "Proxy saved"));

            }
        }
Exemplo n.º 2
0
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            var proxies = TeleportDao.Instance.GetAll();
            List<StatelData> statels = new List<StatelData>();
            Function lastFound = null;
            foreach (PlayfieldData pf in PlayfieldLoader.PFData.Values)
            {
                bool isProxy = false;
                foreach (StatelData sd in pf.Statels)
                {
                    lastFound = null;
                    isProxy = false;
                    if (sd.Events.Count > 0)
                    {
                        foreach (Event e in sd.Events)
                        {
                            foreach (Function f in e.Functions)
                            {
                                if (f.FunctionType == (int)FunctionType.TeleportProxy)
                                {
                                    isProxy = true;
                                    lastFound = f;
                                    if (f.Arguments.Values[1].AsInt32() < 0)
                                    {
                                        lastFound = null;
                                        isProxy = false;
                                    }
                                    break;
                                }
                            }
                            if (isProxy)
                            {
                                break;
                            }
                        }
                    }
                    if (isProxy)
                    {
                        if (
                            !proxies.Any(
                                x =>
                                    (x.statelType == (int)sd.Identity.Type)
                                    && (x.statelInstance == (uint)sd.Identity.Instance)
                                    && (x.playfield == sd.PlayfieldId)))
                        {

                            PlayfieldData dest = PlayfieldLoader.PFData[lastFound.Arguments.Values[1].AsInt32()];
                            if (dest.Statels.Count(x => x.Identity.Type == IdentityType.Door) == 1)
                            {
                                StatelData sddest = dest.Statels.First(x => x.Identity.Type == IdentityType.Door);
                                DBTeleport tel = new DBTeleport();
                                tel.playfield = sd.PlayfieldId;
                                tel.statelType = 0xc748; // Door only for now
                                tel.statelInstance = (uint)sd.Identity.Instance;
                                tel.destinationPlayfield = sddest.PlayfieldId;
                                tel.destinationType = (int)sddest.Identity.Type;
                                tel.destinationInstance = BitConverter.ToUInt32(BitConverter.GetBytes(sddest.Identity.Instance), 0);
                                var temp = TeleportDao.Instance.GetWhere(new { tel.playfield, tel.statelType, tel.statelInstance });
                                foreach (var t in temp)
                                {
                                    TeleportDao.Instance.Delete(t.Id);
                                }
                                TeleportDao.Instance.Add(tel);
                                isProxy = false;
                            }
                        }

                    }

                    if (isProxy)
                    {
                        // Check against proxies already found
                        if (
                            !proxies.Any(
                                x =>
                                    (x.statelType == (int)sd.Identity.Type)
                                    && (x.statelInstance == (uint)sd.Identity.Instance) && (x.playfield == sd.PlayfieldId)))
                        {
                            PlayfieldData dest = PlayfieldLoader.PFData[lastFound.Arguments.Values[1].AsInt32()];
                            StatelData door1 = null;
                            if (dest.Statels.Count(x => x.Identity.Type == IdentityType.Door) > 0)
                            {
                                 door1 = dest.Statels.First(x => x.Identity.Type == IdentityType.Door);
                                 LogUtil.Debug(DebugInfoDetail.Error, sd.PlayfieldId + " " + sd.Identity.ToString(true));
                                 character.Stats[StatIds.externaldoorinstance].BaseValue = (uint)sd.Identity.Instance;
                                 character.Stats[StatIds.externalplayfieldinstance].BaseValue = (uint)sd.PlayfieldId;
                                 character.Playfield.Teleport(
                                     (Dynel)character,
                                     new Coordinate(door1.X, door1.Y+1.0f, door1.Z),
                                     character.Heading,
                                     new Identity() { Type = (IdentityType)lastFound.Arguments.Values[0].AsInt32() , Instance = door1.PlayfieldId });
                                return;
                            }
                            LogUtil.Debug(DebugInfoDetail.Error, sd.PlayfieldId + " " + sd.Identity.ToString(true));
                            character.Stats[StatIds.externaldoorinstance].BaseValue = 0;
                            character.Stats[StatIds.externalplayfieldinstance].BaseValue = 0;
                            character.Playfield.Teleport(
                                (Dynel)character,
                                new Coordinate(sd.X, sd.Y, sd.Z),
                                character.Heading,
                                new Identity() { Type = IdentityType.Playfield, Instance = sd.PlayfieldId });
                            return;
                        }
                    }
                }
            }
        }