public void Initialize()
        {
            GameData = new EmbeddedData();

            //LootSerialization.PopulateLoot();

            Behaviors = new BehaviorDb(this);

            Player.HandleQuests(GameData);

            Merchant.HandleMerchant(GameData);

            AddWorld((int)WorldID.NEXUS_ID, Worlds[0] = new Nexus());
            AddWorld((int)WorldID.MARKET, new ClothBazaar());
            AddWorld((int)WorldID.TEST_ID, new Test());
            AddWorld((int)WorldID.TUT_ID, new Tutorial(true));
            AddWorld((int)WorldID.DAILY_QUEST_ID, new DailyQuestRoom());

            Monitor = new RealmPortalMonitor(this);

            Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default);

            InterServer = new ISManager(this);

            Chat = new ChatManager(this);

            Commands = new CommandManager(this);

            NPCs npcs = new NPCs();

            npcs.Initialize(this);

            Log.Info($"\t- {NPCs.Database.Count}\tNPC{(NPCs.Database.Count > 1 ? "s" : "")}.");
        }
Exemple #2
0
        public override bool AddChar(int code, int FallbackLevel)
        {
            bool Result = FTrueTypeData.HasGlyph(code);

            if (!Result)
            {
                TPdfFont Fallbk = FallbackFont(FallbackLevel);
                if (Fallbk != null)
                {
                    if (Fallbk.AddChar(code, FallbackLevel + 1))
                    {
                        return(true);
                    }
                }
            }

            if (Result || FallbackLevel == 0)
            {
                int ccode   = FTrueTypeData.Glyph(code, true);
                int newcode = EmbeddedData.GetNewGlyphFromOldGlyph(ccode);
                UsedChars.Add((char)newcode, FTrueTypeData.GlyphWidth(ccode));
                ToUnicodeData.Add(newcode, (int)code);
            }

            return(Result);
        }
Exemple #3
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("dat", "Sound",
                      () => soundData,
                      v => soundData = (EmbeddedData)v,
                      PropertyGUIs.EmbeddedData(EmbeddedDataType.Audio, SoundPlayer.Factory)),
         new Property("pmo", "Play mode",
                      () => playMode,
                      v => playMode = (PlayMode)v,
                      PropertyGUIs.Enum),
         new Property("vol", "Volume",
                      () => volume,
                      v => volume = (float)v,
                      PropertyGUIs.Float),
         new Property("fin", "Fade in",
                      () => fadeIn,
                      v => fadeIn = (float)v,
                      PropertyGUIs.Float),
         new Property("fou", "Fade out",
                      () => fadeOut,
                      v => fadeOut = (float)v,
                      PropertyGUIs.Float)
     }));
 }
Exemple #4
0
    public void ReadStream(Stream stream)
    {
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);

        string name   = null;
        int    slot   = SunVoxUtils.OpenUnusedSlot();
        int    result = SunVox.sv_load_from_memory(slot, bytes, bytes.Length);

        if (result == 0)
        {
            name = System.Runtime.InteropServices.Marshal.PtrToStringAuto(SunVox.sv_get_song_name(slot));
        }
        SunVoxUtils.CloseSlot(slot);
        if (name != null)
        {
            name = name.Trim();
        }
        if (name != null && name.Length > 32)
        {
            name = name.Substring(0, 32);
        }
        if (name == null || name == "")
        {
            name = "imported";
        }

        data = new EmbeddedData(name, bytes, EmbeddedDataType.SunVox);
    }
            public Ctor Init(string objType, State rootState, params ILootDef[] defs)
            {
                var d = new Dictionary <string, State>();

                rootState.Resolve(d);
                rootState.ResolveChildren(d);
                EmbeddedData dat = InitDb.Manager.GameData;

                try
                {
                    if (InitDb.Definitions.ContainsKey(dat.IdToObjectType[objType]))
                    {
                        Log.Warn($"Duplicated behavior for entity '{objType}'.");
                    }
                    else
                    {
                        if (defs.Length > 0)
                        {
                            var loot = new Loot(defs);
                            rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time);
                            InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple <State, Loot>(rootState, loot));
                        }
                        else
                        {
                            InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple <State, Loot>(rootState, null));
                        }
                    }
                }
                catch (KeyNotFoundException)
                { Log.Warn($"[State: {rootState.ToString()}] There is no definition for entity '{objType}' in game assets."); }

                return(this);
            }
Exemple #6
0
        public void Populate(
            Enemy enemy,
            Tuple <Player, int> playerDat,
            Random rand,
            string lootState,
            IList <LootDef> lootDefs
            )
        {
            Lootstate = lootState;

            if (playerDat != null)
            {
                return;
            }

            EmbeddedData dat = GameServer.Manager.GameData;

            try
            {
                lootDefs.Add(new LootDef(dat.Items[dat.IdToObjectType[item]], probability, lootState));
            }
            catch (KeyNotFoundException)
            {
                Log.Error($"Item '{item}', wasn't added in loot list of entity '{enemy.Name}', because doesn't contains in assets.");
            }
        }
        public void GZipBase32768()
        {
            string gzipBase32768 = "㘅桠ҠҠԀᆖ䏚⢃㹈䝗錛㽸㨇栂祯嵔傅患踑⛩柀炁㢡垀鞽瑜䬌睜翶ꚹ㺻許ᖝᯌ劑㿯喁姬▿粻䣋鲣珳ᯀ堽羉譁䔹纼㻳纍薬卟眵䯀ꈰ疩ឝ焐疏呁猕㽿䩻勁㹡歖傠冩憅椓觇瀌鞱ꑶ⭟ᅀ篕┆盐诪ᗊ檲葷䏑唱嬻亜䞨ꂙ嫽邍韆媞害䀀ꊠҠƟ";
            var    expected      = new EmbeddedData(
                "GZipBase32768",
                ImmutableArray.Create(
                    new SourceFileInfo(
                        "_SampleLibrary2>Put2.cs",
                        new[] { "SampleLibrary.Put2" },
                        Array.Empty <string>(),
                        new[] { "_SampleLibrary>Put.cs" },
                        "namespace SampleLibrary { public static class Put2 { public static void Write() => Put.WriteRandom(); } } "
                        )
                    ),
                new Version(3, 4, 0, 0),
                LanguageVersion.CSharp1,
                false
                );

            EmbeddedData.Create("GZipBase32768", ImmutableDictionary.Create <string, string>()
                                .Add("SourceExpander.EmbeddedSourceCode.GZipBase32768", gzipBase32768)
                                .Add("SourceExpander.EmbedderVersion", "3.4.0.0")
                                )
            .Should()
            .BeEquivalentTo((expected, ImmutableArray <(string Key, string Message)> .Empty));
            EmbeddedData.Create("GZipBase32768", ImmutableDictionary.Create <string, string>()
                                .Add("SourceExpander.EmbedderVersion", "3.4.0.0")
                                .Add("SourceExpander.EmbeddedLanguageVersion", "1")
                                .Add("SourceExpander.EmbeddedSourceCode.GZipBase32768", gzipBase32768)
                                )
            .Should()
            .BeEquivalentTo((expected, ImmutableArray <(string Key, string Message)> .Empty));
        }
        public void RawJsonError()
        {
            string json = "[{]}]";

            EmbeddedData.Create("RawJson",
                                ImmutableDictionary.Create <string, string>()
                                .Add("SourceExpander.EmbeddedSourceCode", json)
                                .Add("SourceExpander.EmbedderVersion", "3.4.0.0")
                                .Add("SourceExpander.EmbeddedLanguageVersion", "7.3"))
            .Should()
            .BeEquivalentTo((
                                new EmbeddedData("RawJson",
                                                 ImmutableArray <SourceFileInfo> .Empty,
                                                 new(3, 4, 0, 0),
                                                 LanguageVersion.CSharp7_3, false),
                                ImmutableArray.Create <(string Key, string Message)>(("SourceExpander.EmbeddedSourceCode",
                                                                                      "Invalid property identifier character: ]. Path '[0]', line 1, position 2."))));

            EmbeddedData.Create("RawJson",
                                ImmutableDictionary.Create <string, string>()
                                .Add("SourceExpander.EmbeddedLanguageVersion", "7.3")
                                .Add("SourceExpander.EmbedderVersion", "3.4.0.0")
                                .Add("SourceExpander.EmbeddedSourceCode", json))
            .Should()
            .BeEquivalentTo((
                                new EmbeddedData("RawJson",
                                                 ImmutableArray <SourceFileInfo> .Empty,
                                                 new(3, 4, 0, 0),
                                                 LanguageVersion.CSharp7_3, false),
                                ImmutableArray.Create <(string Key, string Message)>(("SourceExpander.EmbeddedSourceCode",
                                                                                      "Invalid property identifier character: ]. Path '[0]', line 1, position 2."))));
        }
Exemple #9
0
        public void Initialize()
        {
            log.Info("Initializing Realm Manager...");

            GameData  = new EmbeddedData();
            Behaviors = new BehaviorDb(this);
            Merchant.InitMerchatLists(GameData);

            AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus());
            AddWorld(World.MARKET, new ClothBazaar());
            AddWorld(World.TEST_ID, new Test());
            AddWorld(World.TUT_ID, new Tutorial(true));
            AddWorld(World.DAILY_QUEST_ID, new DailyQuestRoom());
            Monitor = new RealmPortalMonitor(this);

            Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default);

            InterServer = new ISManager(this);

            Chat = new ChatManager(this);

            Commands = new CommandManager(this);

            log.Info("Realm Manager initialized.");
        }
        public static byte[] Convert(EmbeddedData data, string json)
        {
            json_dat obj = JsonConvert.DeserializeObject <json_dat>(json);

            byte[] dat = ZlibStream.UncompressBuffer(obj.data);

            Dictionary <short, TerrainTile> tileDict = new Dictionary <short, TerrainTile>();

            for (int i = 0; i < obj.dict.Length; i++)
            {
                loc o = obj.dict[i];
                tileDict[(short)i] = new TerrainTile
                {
                    TileId  = o.ground == null ? (ushort)0xff : data.IdToTileType[o.ground],
                    TileObj = o.objs == null ? null : o.objs[0].id,
                    Name    = o.objs == null ? "" : o.objs[0].name ?? "",
                    Terrain = TerrainType.None,
                    Region  = o.regions == null ? TileRegion.None : (TileRegion)Enum.Parse(typeof(TileRegion), o.regions[0].id.Replace(' ', '_'))
                };
            }

            TerrainTile[,] tiles = new TerrainTile[obj.width, obj.height];
            using (NReader rdr = new NReader(new MemoryStream(dat)))
                for (int y = 0; y < obj.height; y++)
                {
                    for (int x = 0; x < obj.width; x++)
                    {
                        tiles[x, y] = tileDict[rdr.ReadInt16()];
                    }
                }
            return(WorldMapExporter.Export(tiles));
        }
        public async Task RemoveContract()
        {
            var embedded = await EmbeddedData.LoadFromAssembly(typeof(Mod1000000007));

            var codes = embedded.SourceFiles.Select(s => s.CodeBody);

            codes.Should().NotContain(code => code.Contains("Contract.Assert"));
        }
        public async Task LanguageVersion()
        {
            var embedded = await EmbeddedData.LoadFromAssembly(typeof(Global));

            embedded.AssemblyMetadatas
            .Should().ContainKey("SourceExpander.EmbeddedLanguageVersion")
            .WhoseValue.Should().Be("8.0");
        }
        public void create_expected_matrix()
        {
            var inputString = EmbeddedData.AsString("han_carlson.txt");

            var intMap = _mapFileParser.GetModulesTypeMap(inputString);

            IsMappedStructureCorrected(intMap).ShouldBe(true);
        }
Exemple #14
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            WanderStorage storage;

            if (state == null)
            {
                storage = new WanderStorage();
            }
            else
            {
                storage = (WanderStorage)state;
            }

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed))
            {
                return;
            }

            Status = CycleStatus.InProgress;
            if (storage.RemainingDistance <= 0)
            {
                storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                storage.Direction.Normalize();
                storage.RemainingDistance = period.Next(Random) / 1000f;
                Status = CycleStatus.Completed;
            }

            float dist = host.GetSpeed(speed, time);

            if (avoidGround)
            {
                EmbeddedData data = host.Manager.GameData;
                float        x    = host.X + storage.Direction.X * dist;
                float        y    = host.Y + storage.Direction.Y * dist;
                WmapTile     tile = host.Owner.Map[(int)x, (int)y];
                if (tile.TileId == data.IdToTileType[ground])
                {
                    host.UpdateCount++;
                    storage.RemainingDistance -= dist;
                    state = storage;
                    return;
                }
            }
            host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist);
            host.UpdateCount++;

            storage.RemainingDistance -= dist;

            state = storage;

            //if (debug)
            //{
            //    double TPS = time.TickCount / (time.TotalElapsedMs / 1000.0);
            //    log.Warn($"[{typeof(Wander).Name}] Speed: {speed} | Current Speed: {dist:n2} | TC: {time.TickCount:n2} | TEM: {(time.TotalElapsedMs / 1000.0):n2} | TPS: {TPS:n2}");
            //}
        }
        public void TestFromImage()
        {
            var image    = new Bitmap(EmbeddedData.Read("satellite.png"));
            var resource = CesiumResource.FromImage(image, CesiumImageFormat.Png);

            Assert.IsNotNull(resource);

            StringAssert.StartsWith("data:image/png;base64,", resource.Uri);
        }
Exemple #16
0
        public void TestGetWinnersArchives()
        {
            string  expectedArchive = EmbeddedData.AsString("archive.txt");
            dynamic expectedJson    = JObject.Parse(expectedArchive);

            string  actualArchive = _controller.GetWinnersArchives();
            dynamic actualJson    = JObject.Parse(actualArchive);

            Assert.AreEqual(expectedJson.Data, actualJson.Data);
        }
Exemple #17
0
 public static XElement ToXml(EmbeddedData data)
 {
     return
         (new XElement("MaxClassLevelList",
                       data.ObjectDescs.Values.Where(_ => _.Class == "Player").Select(_ =>
                                                                                      new XElement("MaxClassLevel",
                                                                                                   new XAttribute("classType", _.ObjectType),
                                                                                                   new XAttribute("maxLevel", 20))
                                                                                      )));
 }
Exemple #18
0
        public List <MatchRequest> GetSeasonMatches(SeasonRequest request)
        {
            IWebDriver driver = new ChromeDriver(Path.Combine(EmbeddedData.GetAssemblyDirectory(), "App_Data"));

            SeasonMatches seasonMatches = new SeasonMatches(request, driver);

            driver.Quit();

            return(seasonMatches.MatchRequests);
        }
 public static void HandleQuests(EmbeddedData data)
 {
     foreach (var i in data.ObjectDescs.Values)
     {
         if (i.Enemy && i.Quest)
         {
             RealmManager.QuestPortraits.Add(i.ObjectId, i.Level);
         }
     }
 }
Exemple #20
0
        public MatchDetails GetMatchDetails(string matchDate, int teamId)
        {
            IWebDriver driver = new ChromeDriver(Path.Combine(EmbeddedData.GetAssemblyDirectory(), "App_Data"));

            MatchDetails scrapedDetails = new MatchDetails(matchDate, teamId, driver);

            driver.Quit();

            return(scrapedDetails);
        }
Exemple #21
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            WanderStorage storage;

            if (state == null)
            {
                storage = new WanderStorage();
            }
            else
            {
                storage = (WanderStorage)state;
            }

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed))
            {
                return;
            }

            Status = CycleStatus.InProgress;

            if (storage.RemainingDistance <= 0)
            {
                storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                storage.Direction.Normalize();
                storage.RemainingDistance = period.Next(Random) / 1000f;
                Status = CycleStatus.Completed;
            }

            float dist = host.EntitySpeed(speed, time);

            if (avoidGround)
            {
                EmbeddedData data = GameServer.Manager.GameData;
                float        x    = host.X + storage.Direction.X * dist;
                float        y    = host.Y + storage.Direction.Y * dist;
                WmapTile     tile = host.Owner.Map[(int)x, (int)y];
                if (tile.TileId == data.IdToTileType[ground])
                {
                    host.UpdateCount++;
                    storage.RemainingDistance -= dist;
                    state = storage;
                    return;
                }
            }

            host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist);

            host.UpdateCount++;

            storage.RemainingDistance -= dist;

            state = storage;
        }
        public void TestFromImageFormats(CesiumImageFormat format)
        {
            var image = new Bitmap(EmbeddedData.Read("satellite.png"));

            var resource = CesiumResource.FromImage(image, format);

            Assert.IsNotNull(resource);

            StringAssert.StartsWith("data:", resource.Uri);
            StringAssert.Contains(";base64,", resource.Uri);
        }
Exemple #23
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[41, 41];

            for (int i = 0; i < 5; i++)
            {
                double angle = (360 / 5 * i) * (float)Math.PI / 180;
                int    x_    = (int)(Math.Cos(angle) * 15 + 20 - 3);
                int    y_    = (int)(Math.Sin(angle) * 15 + 20 - 3);

                for (int x = 0; x < 7; x++)
                {
                    for (int y = 0; y < 7; y++)
                    {
                        t[x_ + x, y_ + y] = Circle[x, y];
                    }
                }
                t[x_ + 3, y_ + 3] = 2;
            }
            t[20, 20] = 3;

            EmbeddedData data = world.Manager.GameData;

            for (int x = 0; x < 40; x++)
            {
                for (int y = 0; y < 40; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = data.IdToTileType[Floor];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 2)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = data.IdToTileType[Floor];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;

                        Entity penta = Entity.Resolve(world.Manager, 0x0d5e);
                        penta.Move(pos.X + x + .5f, pos.Y + y + .5f);
                        world.EnterWorld(penta);
                    }
                    else if (t[x, y] == 3)
                    {
                        Entity penta = Entity.Resolve(world.Manager, "Pentaract");
                        penta.Move(pos.X + x + .5f, pos.Y + y + .5f);
                        world.EnterWorld(penta);
                    }
                }
            }
        }
Exemple #24
0
        internal override byte[] EncodeString(string s)
        {
            byte[] Result = new byte[2 * s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                int gl = FTrueTypeData.Glyph((int)s[i], true);
                MotorolaSetWord(Result, i * 2, EmbeddedData.GetNewGlyphFromOldGlyph(gl));
            }

            return(Result);
        }
 public void Empty()
 {
     EmbeddedData.Create("Empty", ImmutableDictionary.Create <string, string>())
     .Should()
     .BeEquivalentTo((new EmbeddedData(
                          "Empty",
                          ImmutableArray.Create <SourceFileInfo>(),
                          new Version(1, 0, 0),
                          LanguageVersion.CSharp1
                          , false
                          ), ImmutableArray <(string Key, string Message)> .Empty));
 }
Exemple #26
0
        public void Populate(RealmManager manager, Enemy enemy, Tuple <Player, int> playerDat,
                             Random rand, string lootState, IList <LootDef> lootDefs)
        {
            Lootstate = lootState;
            if (playerDat != null)
            {
                return;
            }
            EmbeddedData dat = manager.GameData;

            lootDefs.Add(new LootDef(dat.Items[dat.IdToObjectType[item]], probability, lootState));
        }
        private const string SystemMapFilePath = "kogge-stone.txt";//

        public SystemTestForKoggeStone()
        {
            _outputProvider      = new SystemCalculator(new LogicalOperationCalculator());
            _inputDataTranslator = new InputDataTranslator();
            var mapFileContentProvider = Substitute.For <IProvideMapFileContent>();

            mapFileContentProvider.GetMapFileContent(SystemMapFilePath).Returns(EmbeddedData.AsString(SystemMapFilePath));

            var systemBuilder = new SystemBuilder(new MapFileParser(), mapFileContentProvider, new BuildSystemModulesMap());

            this._system = systemBuilder.Build(SystemMapFilePath);
        }
        public async Task EmbeddedNamespaces()
        {
            var embedded = await EmbeddedData.LoadFromAssembly(typeof(Mod1000000007));

            embedded.AssemblyMetadatas.Should().ContainKey("SourceExpander.EmbeddedNamespaces");
            embedded.EmbeddedNamespaces.Should()
            .Equal(
                "AtCoder",
                "AtCoder.Extension",
                "AtCoder.Internal",
                "AtCoder.Operators");
        }
Exemple #29
0
    private EmbeddedData StopPlayer()
    {
        if (playingAudio != null)
        {
            playingAudio.Stop();
        }
        playingAudio = null;
        var data = playingData;

        playingData = null;
        return(data);
    }
 private void FillList()
 {
     if (items == null)
     {
         items = new List <EventTeam>();
         Stream stream = EmbeddedData.XmlDataStoreEventTeams();
         using (var reader = new StreamReader(stream))
         {
             var serializer = new XmlSerializer(typeof(List <EventTeam>));
             items = (List <EventTeam>)serializer.Deserialize(reader);
         }
     }
 }