Ejemplo n.º 1
0
        public void VerifyHashType()
        {
            LightConfig lightConfig;

            XAssert.IsTrue(LightConfig.TryParse(new[] { $"/c:fake", "/hashtype:murmur" }, out lightConfig));
            XAssert.AreEqual("murmur", lightConfig.HashType);
        }
Ejemplo n.º 2
0
        public LightsFrame(Window wnd, LevelFrame levelFrame, List <Light> lights, LightConfig lightConfig) : base(wnd)
        {
            this.levelFrame  = levelFrame;
            this.lights      = lights;
            this.lightConfig = lightConfig;

            lightsProperties = new List <Tuple <Light, Dictionary <string, Dictionary <string, PropertyInfo> > > >();

            RecomputeProperties();
        }
Ejemplo n.º 3
0
 public LightConfigRule(
     string name,
     LightType type,
     LightConfig approvedConfig
     ) : base(name)
 {
     this.type = type;
     this.approvedLightmapBakeTypes = approvedConfig.bakeTypes;
     this.minRange           = approvedConfig.minRange;
     this.maxRange           = approvedConfig.maxRange;
     this.minIntensity       = approvedConfig.minIntensity;
     this.maxIntensity       = approvedConfig.maxIntensity;
     this.minBounceIntensity = approvedConfig.minBounceIntensity;
     this.maxBounceIntensity = approvedConfig.maxBounceIntensity;
 }
Ejemplo n.º 4
0
        private void RunCongruentTest(string[] args, bool passParse = true)
        {
            ICommandLineConfiguration config;
            PathTable pt = new PathTable();
            bool      fullConfigSuccess = Args.TryParseArguments(args, pt, null, out config);

            LightConfig lightConfig;
            bool        lightConfigSuccess = LightConfig.TryParse(args, out lightConfig);

            XAssert.AreEqual(passParse, fullConfigSuccess);
            XAssert.AreEqual(passParse, lightConfigSuccess);

            if (passParse)
            {
                AssertCongruent(pt, config, lightConfig);
            }
        }
Ejemplo n.º 5
0
 private void AssertCongruent(PathTable pathTable, ICommandLineConfiguration commandLineConfig, LightConfig lightConfig)
 {
     XAssert.AreEqual(lightConfig.AnimateTaskbar, commandLineConfig.Logging.AnimateTaskbar);
     XAssert.AreEqual(lightConfig.Color, commandLineConfig.Logging.Color);
     AssertPathCongruent(pathTable, lightConfig.Config, commandLineConfig.Startup.ConfigFile);
     XAssert.AreEqual(lightConfig.FancyConsole, commandLineConfig.Logging.FancyConsole);
     XAssert.AreEqual(lightConfig.Help, commandLineConfig.Help);
     XAssert.AreEqual(lightConfig.NoLogo, commandLineConfig.NoLogo);
     XAssert.AreEqual(lightConfig.Server, commandLineConfig.Server);
     XAssert.AreEqual(lightConfig.DisablePathTranslation, commandLineConfig.Logging.DisableLoggedPathTranslation);
     AssertPathCongruent(pathTable, lightConfig.ServerDeploymentDirectory, commandLineConfig.ServerDeploymentDirectory);
     AssertPathCongruent(pathTable, lightConfig.SubstSource, commandLineConfig.Logging.SubstSource);
     AssertPathCongruent(pathTable, lightConfig.SubstTarget, commandLineConfig.Logging.SubstTarget);
     XAssert.AreEqual(lightConfig.RunInSubst, commandLineConfig.RunInSubst);
 }
Ejemplo n.º 6
0
        //Engine file constructor
        public Level(string enginePath)
        {
            path = Path.GetDirectoryName(enginePath);

            // Engine elements
            using (EngineParser engineParser = new EngineParser(enginePath))
            {
                game = engineParser.GetGameType();

                //REMOVE THESE ASAP!!!!!111
                renderDefBytes   = engineParser.GetRenderDefBytes();
                collBytesEngine  = engineParser.GetCollisionBytes();
                billboardBytes   = engineParser.GetBillboardBytes();
                soundConfigBytes = engineParser.GetSoundConfigBytes();

                LOGGER.Debug("Parsing skybox...");
                skybox = engineParser.GetSkyboxModel();
                LOGGER.Debug("Success");

                LOGGER.Debug("Parsing moby models...");
                mobyModels = engineParser.GetMobyModels();
                LOGGER.Debug("Added {0} moby models", mobyModels.Count);

                LOGGER.Debug("Parsing tie models...");
                tieModels = engineParser.GetTieModels();
                LOGGER.Debug("Added {0} tie models", tieModels.Count);

                LOGGER.Debug("Parsing shrub models...");
                shrubModels = engineParser.GetShrubModels();
                LOGGER.Debug("Added {0} shrub models", shrubModels.Count);

                LOGGER.Debug("Parsing weapons...");
                gadgetModels = engineParser.GetGadgets();
                LOGGER.Debug("Added {0} weapons", gadgetModels.Count);

                LOGGER.Debug("Parsing textures...");
                textures = engineParser.GetTextures();
                LOGGER.Debug("Added {0} textures", textures.Count);

                LOGGER.Debug("Parsing ties...");
                ties = engineParser.GetTies(tieModels);
                LOGGER.Debug("Added {0} ties", ties.Count);

                LOGGER.Debug("Parsing Shrubs...");
                shrubs = engineParser.GetShrubs(shrubModels);
                LOGGER.Debug("Added {0} shrubs", shrubs.Count);

                LOGGER.Debug("Parsing Lights...");
                lights = engineParser.GetLights();
                LOGGER.Debug("Added {0} lights", lights.Count);

                LOGGER.Debug("Parsing terrain elements...");
                terrainEngine = engineParser.GetTerrainModel();
                LOGGER.Debug("Added {0} terrain elements", terrainEngine.fragments.Count);

                LOGGER.Debug("Parsing player animations...");
                playerAnimations = engineParser.GetPlayerAnimations((MobyModel)mobyModels[0]);
                LOGGER.Debug("Added {0} player animations", playerAnimations.Count);

                uiElements = engineParser.GetUiElements();
                LOGGER.Debug("Added {0} ui elements", uiElements.Count);

                lightConfig        = engineParser.GetLightConfig();
                textureConfigMenus = engineParser.GetTextureConfigMenu();

                collisionEngine = engineParser.GetCollisionModel();

                unk3 = engineParser.GetUnk3Bytes();
                unk4 = engineParser.GetUnk4Bytes();
                unk5 = engineParser.GetUnk5Bytes();
                unk8 = engineParser.GetUnk8Bytes();
                unk9 = engineParser.GetUnk9Bytes();
            }


            // Gameplay elements
            using (GameplayParser gameplayParser = new GameplayParser(game, path + @"/gameplay_ntsc"))
            {
                LOGGER.Debug("Parsing Level variables...");
                levelVariables = gameplayParser.GetLevelVariables();

                LOGGER.Debug("Parsing mobs...");
                mobs = gameplayParser.GetMobies(mobyModels);
                LOGGER.Debug("Added {0} mobs", mobs.Count);

                LOGGER.Debug("Parsing splines...");
                splines = gameplayParser.GetSplines();
                LOGGER.Debug("Added {0} splines", splines.Count);

                LOGGER.Debug("Parsing languages...");
                english   = gameplayParser.GetEnglish();
                ukenglish = gameplayParser.GetUkEnglish();
                french    = gameplayParser.GetFrench();
                german    = gameplayParser.GetGerman();
                spanish   = gameplayParser.GetSpanish();
                italian   = gameplayParser.GetItalian();
                japanese  = gameplayParser.GetJapanese();
                korean    = gameplayParser.GetKorean();

                LOGGER.Debug("Parsing other gameplay assets...");
                unk6  = gameplayParser.GetUnk6();
                unk7  = gameplayParser.GetUnk7();
                unk12 = gameplayParser.GetUnk12();
                unk13 = gameplayParser.GetUnk13();
                unk14 = gameplayParser.GetUnk14();
                unk16 = gameplayParser.GetUnk16();
                unk17 = gameplayParser.GetUnk17();
                unk18 = gameplayParser.GetUnk18();

                tieData   = gameplayParser.GetTieData(ties.Count);
                shrubData = gameplayParser.GetShrubData(shrubs.Count);

                tieGroupData   = gameplayParser.GetTieGroups();
                shrubGroupData = gameplayParser.GetShrubGroups();

                areasData = gameplayParser.GetAreasData();

                directionalLights = gameplayParser.GetDirectionalLights();
                type0Cs           = gameplayParser.GetType0Cs();
                spheres           = gameplayParser.GetSpheres();
                cylinders         = gameplayParser.GetCylinders();
                type4Cs           = gameplayParser.GetType4Cs();
                type7Cs           = gameplayParser.GetType7Cs();
                type80s           = gameplayParser.GetType80();
                type88s           = gameplayParser.GetType88s();
                type50s           = gameplayParser.GetType50s();
                type5Cs           = gameplayParser.GetType5Cs();

                pVars       = gameplayParser.GetPvars(mobs);
                cuboids     = gameplayParser.GetCuboids();
                gameCameras = gameplayParser.GetGameCameras();

                mobyIds       = gameplayParser.GetMobyIds();
                tieIds        = gameplayParser.GetTieIds();
                shrubIds      = gameplayParser.GetShrubIds();
                occlusionData = gameplayParser.GetOcclusionData();
            }

            terrainChunks   = new List <Terrain>();
            collisionChunks = new List <Model>();
            collBytesChunks = new List <byte[]>();

            for (int i = 0; i < 5; i++)
            {
                var chunkPath = Path.Join(path, @"chunk" + i + ".ps3");
                if (!File.Exists(chunkPath))
                {
                    continue;
                }

                using (ChunkParser chunkParser = new ChunkParser(chunkPath, game))
                {
                    terrainChunks.Add(chunkParser.GetTerrainModels());
                    collisionChunks.Add(chunkParser.GetCollisionModel());
                    collBytesChunks.Add(chunkParser.GetCollBytes());
                }
            }

            List <string> armorPaths = ArmorHeader.FindArmorFiles(game, enginePath);

            armorModels   = new List <Model>();
            armorTextures = new List <List <Texture> >();

            foreach (string armor in armorPaths)
            {
                LOGGER.Debug("Looking for armor data in {0}", armor);
                List <Texture> tex;
                MobyModel      model;
                using (ArmorParser parser = new ArmorParser(game, armor))
                {
                    tex   = parser.GetTextures();
                    model = parser.GetArmor();
                }

                string vram = armor.Replace(".ps3", ".vram");

                using (VramParser parser = new VramParser(vram))
                {
                    parser.GetTextures(tex);
                }

                if (model != null)
                {
                    armorModels.Add(model);
                }

                armorTextures.Add(tex);
            }

            string gadgetPath = GadgetHeader.FindGadgetFile(game, enginePath);

            gadgetTextures = new List <Texture>();

            if (gadgetPath != "")
            {
                LOGGER.Debug("Looking for gadget data in {0}", gadgetPath);
                using (GadgetParser parser = new GadgetParser(game, gadgetPath))
                {
                    gadgetModels.AddRange(parser.GetModels());
                    gadgetTextures.AddRange(parser.GetTextures());
                }

                using (VramParser parser = new VramParser(gadgetPath.Replace(".ps3", ".vram")))
                {
                    parser.GetTextures(gadgetTextures);
                }
            }

            List <string> missionPaths = MissionHeader.FindMissionFiles(game, enginePath);

            missions = new List <Mission>();

            for (int i = 0; i < missionPaths.Count; i++)
            {
                string missionPath = missionPaths[i];
                string vramPath    = missionPath.Replace(".ps3", ".vram");

                if (!File.Exists(vramPath))
                {
                    LOGGER.Warn("Could not find .vram file for {0}", missionPath);
                    continue;
                }

                LOGGER.Debug("Looking for mission data in {0}", missionPath);

                Mission mission = new Mission(i);

                using (MissionParser parser = new MissionParser(game, missionPath))
                {
                    mission.models   = parser.GetModels();
                    mission.textures = parser.GetTextures();
                }

                using (VramParser parser = new VramParser(vramPath))
                {
                    parser.GetTextures(mission.textures);
                }

                missions.Add(mission);
            }

            using (VramParser vramParser = new VramParser(path + @"/vram.ps3"))
            {
                vramParser.GetTextures(textures);
            }

            LOGGER.Info("Level parsing done");
            valid = true;
        }
Ejemplo n.º 7
0
        public async Task <dynamic> Handle(dynamic session, dynamic message)
        {
            string what   = message.head.what;
            var    userId = Guid.Parse(session.userId.ToString());

            if (what == "node-states")
            {
                foreach (var state in message.body.states)
                {
                    Guid nodeId = Guid.Parse(state.nodeId.ToString());
                    var  cache  = Data.CacheRepository.Instance.GetCache(nodeId);
                    if (cache == null)
                    {
                        cache = new ExpandoObject();
                    }
                    cache.State = state;
                    Data.CacheRepository.Instance.SaveCache(nodeId, cache);
                    Data.RowsCache.Instance.UpdateState(state, nodeId, userId);
                    Carantine.Instance.Push(nodeId, (int)state.code);
                }
            }
            if (what == "node-get-astronomTimer")
            {
                var     answer = Helper.BuildMessage(what);
                Guid    id     = Guid.Parse(message.body.objectId.ToString());
                dynamic tube   = StructureGraph.Instance.GetTube(id, userId);

                var dtube = tube as IDictionary <string, object>;

                if (dtube.ContainsKey("coordinates"))
                {
                    answer.body.coordinates = (string)tube.coordinates;
                }
                if (dtube.ContainsKey("afterBeforeSunSetRise"))
                {
                    answer.body.afterBeforeSunSetRise = (string)tube.afterBeforeSunSetRise;
                }
                if (dtube.ContainsKey("utc"))
                {
                    answer.body.utc = (string)tube.utc;
                }
                return(answer);
            }
            if (what == "node-update-astronomTimer")
            {
                string coordinates           = (string)message.body.coordinates;
                string utc                   = (string)message.body.utc;
                string afterBeforeSunSetRise = (string)message.body.afterBeforeSunSetRise;
                Guid   objectId              = Guid.Parse((string)message.body.objectId);
                StructureGraph.Instance.UpdateLightControlsAstronTimersValues(coordinates, utc, afterBeforeSunSetRise, objectId);
                var ans = Helper.BuildMessage(what);
                return(ans);
            }
            if (what == "node-controller-data")
            {
                dynamic control  = (dynamic)message.body.control;
                var     dcontrol = control as IDictionary <string, object>;
                Guid    objectId = Guid.Parse((string)message.body.objectId);
                //для освещения
                if (dcontrol.ContainsKey("controllerData"))
                {
                    string controllerData = (string)control.controllerData;
                    Data.RowsCache.Instance.UpdateControllerData(controllerData, objectId, userId);
                    Carantine.Instance.Push(objectId);
                }
                if (dcontrol.ContainsKey("lightV2Config"))
                {
                    string strConfig = (string)control.lightV2Config;
                    StructureGraph.Instance.UpdateControlConfig(strConfig, objectId); //strConfig
                    var ans = Helper.BuildMessage(what);
                    return(ans);
                }
                if (dcontrol.ContainsKey("controllerConfig"))
                {
                    string strConfig = (string)control.controllerConfig;
                    StructureGraph.Instance.UpdateControlConfig(strConfig, objectId); //strConfig
                    var ans = Helper.BuildMessage(what);
                    return(ans);
                }
            }
            if (what == "node-config")
            {
            }
            if (what == "node-events")
            {
                int  events   = Convert.ToInt32(message.body.events);
                Guid objectId = Guid.Parse((string)message.body.objectId);
                Data.RowsCache.Instance.UpdateEvents(events, objectId, userId);
                Carantine.Instance.Push(objectId);
            }
            if (what == "node-watertower")
            {
                float max         = Convert.ToSingle(message.body.max);
                float min         = Convert.ToSingle(message.body.min);
                int   controlMode = Convert.ToInt32(message.body.controlMode);
                Guid  objectId    = Guid.Parse((string)message.body.objectId);
                StructureGraph.Instance.UpdateWaterTowenParametr(min, max, controlMode, objectId);
                List <dynamic> rules       = new List <dynamic>();
                var            connections = StructureGraph.Instance.GetNeightbours(objectId, userId);
                foreach (var connection in connections)
                {
                    dynamic ruleConnection = new ExpandoObject();
                    ruleConnection.action       = "upd";
                    ruleConnection.target       = "node";
                    ruleConnection.content      = new ExpandoObject();
                    ruleConnection.content.id   = connection.id;
                    ruleConnection.content.body = connection;
                    ruleConnection.content.type = (string)connection.type;
                    rules.Add(ruleConnection);
                }
                var     area     = StructureGraph.Instance.GetArea(objectId, userId);
                dynamic ruleArea = new ExpandoObject();
                ruleArea.action       = "upd";
                ruleArea.target       = "node";
                ruleArea.content      = new ExpandoObject();
                ruleArea.content.id   = area.id;
                ruleArea.content.body = area;
                ruleArea.content.type = "Area";
                rules.Add(ruleArea);
                var     tube     = StructureGraph.Instance.GetTube(objectId, userId);
                dynamic ruleTube = new ExpandoObject();
                ruleTube.action       = "upd";
                ruleTube.target       = "node";
                ruleTube.content      = new ExpandoObject();
                ruleTube.content.id   = tube.id;
                ruleTube.content.body = tube;
                ruleTube.content.type = "Tube";
                rules.Add(ruleTube);
                var sessions = CacheRepository.Instance.GetSessions();
                sessions.AsParallel().ForAll(s =>
                {
                    var ds = s as IDictionary <string, object>;
                    if (ds == null || !ds.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID) || ds[SignalRConnection.SIGNAL_CONNECTION_ID] == null)
                    {
                        return;
                    }

                    Guid uId       = Guid.Parse(s.userId.ToString());
                    dynamic msg    = Helper.BuildMessage("changes");
                    msg.body.rules = new List <dynamic>();
                    foreach (var rule in rules)
                    {
                        dynamic content = rule.content;
                        Guid id         = Guid.Empty;
                        id = Guid.Parse(content.id.ToString());
                        if (id != Guid.Empty && StructureGraph.Instance.CanSee(id, uId))
                        {
                            msg.body.rules.Add(rule);
                        }
                    }
                    if (msg.body.rules.Count > 0)
                    {
                        var connectionId = ds[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                        SignalRConnection.RaiseEvent(msg, connectionId);
                    }
                });
                return(Helper.BuildMessage(what));
            }
            if (what == "node-get-light-control-config")
            {
                var      answer             = Helper.BuildMessage(what);
                string[] lightControlMetod  = new string[4];
                int[]    lightBeforeSunRise = new int[4];

                int[,] afterSunSetAndBeforeSunRise = new int[4, 2];

                dynamic[,] lightSheduleOn = new dynamic[4, 2];

                dynamic[,] lightSheduleOff = new dynamic[4, 2];

                DateTime dt1970         = new DateTime(1970, 1, 1, 0, 0, 0);
                DateTime dt1970With1sec = new DateTime(1970, 1, 1, 0, 0, 1);

                Guid    id   = Guid.Parse(message.body.objectId.ToString());
                dynamic tube = StructureGraph.Instance.GetTube(id, userId);

                var dtube = tube as IDictionary <string, object>;

                if (dtube.ContainsKey("strConfig"))
                {
                    string      strConfig   = (string)tube.strConfig;
                    var         bytesConfig = strConfig.Split('-').Select(x => byte.Parse(x, NumberStyles.HexNumber)).ToArray();
                    LightConfig conf        = StructsHelper.Instance.setBytesFromConfig <LightConfig>(bytesConfig, new LightConfig());

                    //Celestial cel = Celestial.CalculateCelestialTimes(Convert.ToInt32(conf.u32lat)+0, Convert.ToInt32(conf.u32lon), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day));
                    //DateTime sunRiseUTC = cel.SunRise.Value;
                    //DateTime sunSetUTC = cel.SunSet.Value;
                    //DateTime lightAstronomOn = sunRiseUTC.AddHours(Convert.ToInt32(conf.u8timeDiff));
                    //DateTime lightAstronomOff = sunSetUTC.AddHours(Convert.ToInt32(conf.u8timeDiff));

                    lightControlMetod[0] = (conf.ligthtChannels1.u8ControlMode == 0xFF) ? "" : Convert.ToString(conf.ligthtChannels1.u8ControlMode);
                    lightControlMetod[1] = (conf.ligthtChannels2.u8ControlMode == 0xFF) ? "" : Convert.ToString(conf.ligthtChannels2.u8ControlMode);
                    lightControlMetod[2] = (conf.ligthtChannels3.u8ControlMode == 0xFF) ? "" : Convert.ToString(conf.ligthtChannels3.u8ControlMode);
                    lightControlMetod[3] = (conf.ligthtChannels4.u8ControlMode == 0xFF) ? "" : Convert.ToString(conf.ligthtChannels4.u8ControlMode);

                    afterSunSetAndBeforeSunRise[0, 0] = (conf.ligthtChannels1.u8afterSunSet == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels1.u8afterSunSet);
                    afterSunSetAndBeforeSunRise[1, 0] = (conf.ligthtChannels2.u8afterSunSet == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels2.u8afterSunSet);
                    afterSunSetAndBeforeSunRise[2, 0] = (conf.ligthtChannels3.u8afterSunSet == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels3.u8afterSunSet);
                    afterSunSetAndBeforeSunRise[3, 0] = (conf.ligthtChannels4.u8afterSunSet == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels4.u8afterSunSet);

                    afterSunSetAndBeforeSunRise[0, 1] = (conf.ligthtChannels1.u8beforeSunRise == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels1.u8beforeSunRise);
                    afterSunSetAndBeforeSunRise[1, 1] = (conf.ligthtChannels2.u8beforeSunRise == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels2.u8beforeSunRise);
                    afterSunSetAndBeforeSunRise[2, 1] = (conf.ligthtChannels3.u8beforeSunRise == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels3.u8beforeSunRise);
                    afterSunSetAndBeforeSunRise[3, 1] = (conf.ligthtChannels4.u8beforeSunRise == 0xFF) ? 0 : Convert.ToInt32(conf.ligthtChannels4.u8beforeSunRise);

                    lightSheduleOn[0, 0] = conf.ligthtChannels1.on1;
                    lightSheduleOn[1, 0] = conf.ligthtChannels2.on1;
                    lightSheduleOn[2, 0] = conf.ligthtChannels3.on1;
                    lightSheduleOn[3, 0] = conf.ligthtChannels4.on1;
                    lightSheduleOn[0, 1] = conf.ligthtChannels1.on2;
                    lightSheduleOn[1, 1] = conf.ligthtChannels2.on2;
                    lightSheduleOn[2, 1] = conf.ligthtChannels3.on2;
                    lightSheduleOn[3, 1] = conf.ligthtChannels4.on2;

                    lightSheduleOff[0, 0] = conf.ligthtChannels1.off1;
                    lightSheduleOff[1, 0] = conf.ligthtChannels2.off1;
                    lightSheduleOff[2, 0] = conf.ligthtChannels3.off1;
                    lightSheduleOff[3, 0] = conf.ligthtChannels4.off1;
                    lightSheduleOff[0, 1] = conf.ligthtChannels1.off2;
                    lightSheduleOff[1, 1] = conf.ligthtChannels2.off2;
                    lightSheduleOff[2, 1] = conf.ligthtChannels3.off2;
                    lightSheduleOff[3, 1] = conf.ligthtChannels4.off2;

                    answer.body.strConfig                   = strConfig;
                    answer.body.lightControlMetod           = lightControlMetod;
                    answer.body.afterSunSetAndBeforeSunRise = afterSunSetAndBeforeSunRise;

                    answer.body.lightSheduleOn  = lightSheduleOn;
                    answer.body.lightSheduleOff = lightSheduleOff;
                }
                return(answer);
            }

            if (what == "node-get-matrix-terminal-config")
            {
                var answer = Helper.BuildMessage(what);

                Guid    id   = Guid.Parse(message.body.objectId.ToString());
                dynamic node = StructureGraph.Instance.GetNodeById(id);

                var dnode = node as IDictionary <string, object>;

                if (dnode.ContainsKey("config"))
                {
                    string strConfig          = (string)node.config;
                    var    bytesConfig        = strConfig.Split('-').Select(x => byte.Parse(x, NumberStyles.HexNumber)).ToArray();
                    MatrixTerminalConfig conf = StructsHelper.Instance.setBytesFromConfig <MatrixTerminalConfig>(bytesConfig, new MatrixTerminalConfig());
                    answer.body.config = conf;

                    List <dynamic> listProfile = new List <dynamic>();
                    List <string>  listApnName = new List <string>();
                    foreach (var profile in conf.profile)
                    {
                        dynamic profileTmp = new ExpandoObject();
                        string  ipPort     = StructsHelper.Instance.ParseStringFromBytes(profile.ip_port);

                        profileTmp.ip   = (ipPort.Contains(':')) ? ipPort.Split(':')[0] : ipPort;
                        profileTmp.port = (ipPort.Contains(':')) ? ipPort.Split(':')[1] : "";
                        listProfile.Add(profileTmp);
                    }
                    foreach (var apnName in conf.apnName)
                    {
                        listApnName.Add(StructsHelper.Instance.ParseStringFromBytes(apnName.APN));
                    }
                    answer.body.profiles  = listProfile;
                    answer.body.APNs      = listApnName;
                    answer.body.strConfig = strConfig;
                }
                return(answer);
            }

            if (what == "node-value")
            {
                double   value = (double)message.body.indication;
                string   valueUnitMeasurement = (string)message.body.indicatioUnitMeasurement;
                DateTime date     = DateTime.Parse(message.body.date.ToString());
                Guid     objectId = Guid.Parse((string)message.body.objectId);
                Data.RowsCache.Instance.UpdateValue(value, valueUnitMeasurement, date, objectId, userId);
                Carantine.Instance.Push(objectId);
            }
            if (what == "node-save")
            {
                //var node = message.body.node;
                //Data.StructureGraph.Instance.SaveNode(node.type.ToString(), node, Guid.Parse((string)session.User.id));
            }

            if (what == "nodes-save")
            {
                var nodes  = message.body.nodes;
                var tokens = new List <dynamic>();
                foreach (var node in nodes)
                {
                    var token = node;
                    token.userId = userId;
                    tokens.Add(token);
                }

                Data.NodeBackgroundProccessor.Instance.AddTokens(tokens);
                return(Helper.BuildMessage(what));
            }

            if (what == "node-poll-server")
            {
                string serverName = message.body.serverName;
                var    server     = StructureGraph.Instance.GetPollServer(serverName);
                var    ans        = Helper.BuildMessage(what);
                ans.body.server = StructureGraph.Instance.GetServer(serverName, Guid.Parse((string)session.userId));
                return(ans);
            }

            if (what == "nodes-poll-branch")
            {
                string serverName = message.body.serverName;
                var    server     = StructureGraph.Instance.GetPollServer(serverName);
                var    ans        = Helper.BuildMessage(what);
                ans.body.server = server;//StructureGraph.Instance.GetServer(serverName, Guid.Parse((string)session.userId));
                return(ans);
            }

            return(Helper.BuildMessage(what));
        }
Ejemplo n.º 8
0
    void Start()
    {
        // Load material for the light sphere
        emmisive_white     = Resources.Load("Materials/Emmisive_White") as Material;
        lightProp.lightMat = emmisive_white;
        // Load room objects
        firstRoomObject = Resources.Load("Prefabs/FirstRoom");
        roomObject      = Resources.Load("Prefabs/Room");
        endRoomObject   = Resources.Load("Prefabs/EndRoom");
        // Load sphere primitive to represent a light
        firstRoomCoords      = new Vector3(0, 0, 0);
        firstRoomOrientation = Quaternion.Euler(-90, 0, 0);
        initialLeftOffset    = new Vector3(1.9f, 2.095f, -0.35f);
        initialRightOffset   = new Vector3(-1.9f, 2.095f, 0.35f);

        // Left & right offsets and material will always be the same so they are set here.
        lightProp.lightLeftOffset  = new Vector3(0.36f, 1.2f, 0.26f);
        lightProp.lightRightOffset = new Vector3(-0.36f, 1.2f, 0.26f);
        lightProp.lightMat         = emmisive_white;

        lightLeftOffset      = new Vector3(0.36f, 1.2f, 0.26f);
        lightRightOffset     = new Vector3(-0.36f, 1.2f, 0.26f);
        lastLightLeftOffset  = new Vector3(385, 170, 215);
        lastLightRightOffset = new Vector3(-385, 170, 215);

        leftOffset     = new Vector3(0.85f, 1.49f, 0f);
        rightOffset    = new Vector3(-0.85f, 1.49f, 0f);
        endLeftOffset  = new Vector3(1.73f, 2f, 0f);
        endRightOffset = new Vector3(-1.73f, 2f, 0f);
        // Standard room scale - this is used to scale down the rooms as they adopt the scale of their parent (far too big)
        roomProp.scale   = new Vector3(1f, 1f, 1f);
        leftOrientation  = Quaternion.Euler(0, 0, -60);
        rightOrientation = Quaternion.Euler(0, 0, 60);

        // Populate room array - This is done using the ROOMS_PER_BRANCH value to the power of MAZE_DEPTH -1.
        // This ensures the maze is always the appropriate size.
        int mazeSize = (int)Mathf.Pow(ROOMS_PER_BRANCH, MAZE_DEPTH) - 1;

        roomSet = new Room[mazeSize];

        // Read in colour values from config file
        roomLightValues = new List <float>();
        chainValues     = new List <int>();
        string configText = File.ReadAllText("LightConfig.txt");

        roomLightValues = ReadConfig(configText, roomLightValues);
        // Sets the number of configurations based on the amount read from external file.
        lightConfigs = LightConfigs(roomLightValues);
        // A collection of all possible Light Configurations
        LightConfig[] lc = new LightConfig[lightConfigs];

        string currentConfigs = File.ReadAllText("LightConfigChains.txt");

        // Array of Light Configurations for the current maze to be built
        LightConfig[] mazeConfig = new LightConfig[MAZE_DEPTH - 1];
        roomCombination = new int[MAZE_DEPTH - 1];

        // Determines the configuration chain based on the current light configuration
        ReadConfigChain(currentConfigs, chainValues);
        // Process all configs and setup an array of LightConfigs.
        ProcessConfig(roomLightValues, lc);
        // Set properties of the room lights
        SetupLights(lightconfig);
        LightConfig[] roomArray = new LightConfig[roomSet.Length];

        // Picks out the correct light configuration for each level of the maze.
        startIndex = 1;
        endIndex   = 1;
        for (int i = 0; i < MAZE_DEPTH - 1; i++)
        {
            if (i == 0)
            {
                roomArray[0] = lc[roomCombination[0] - 1]; // First room config
            }
            else
            {
                startIndex = (int)Mathf.Pow(ROOMS_PER_BRANCH, i);     // Defines the index to start inserting the roomCombination at
                endIndex   = (int)Mathf.Pow(ROOMS_PER_BRANCH, i + 1); //  Defines the index to stop inserting the roomCombination at
                for (int j = startIndex - 1; j < endIndex - 1; j++)
                {
                    roomArray[j] = lc[roomCombination[i] - 1]; // All other levels.
                }
            }
        }
        // Assign end rooms to deafult values
        // 8 signifies how many light properties there are
        // As they are contained in an array that starts at 0 we go with (8-1) = 7
        for (int j = 7; j < roomArray.Length; j++)
        {
            // Left Light rgb values
            roomArray[j].leftLightColour = new Vector3(1.0f, 1.0f, 1.0f);
            // Right light rgb values
            roomArray[j].rightLightColour = new Vector3(1.0f, 1.0f, 1.0f);
            // Left light intensity
            roomArray[j].leftLightIntensity = 1.0f;
            // Right light intensity
            roomArray[j].rightLightIntensity = 1.0f;
        }
        // Constructs each room in a tree structure
        for (int j = 0; j < roomSet.Length; j++)
        {
            roomProp.roomIndex = j;
            if (j == 0)
            {
                if (roomSet[j] == null) // If the first room is null construct it.
                {
                    // Set room properties for the first room.
                    roomProp.tag             = "FIRST ROOM";
                    roomProp.rObject         = firstRoomObject;
                    roomProp.offset          = firstRoomCoords;
                    roomProp.orientation     = firstRoomOrientation;
                    roomProp.scale           = Vector3.zero;
                    roomProp.parentTransform = null;
                    // Set light properties for the first room.
                    lightProp.lightMat    = emmisive_white;
                    lightProp.lightConfig = roomArray[j];

                    roomSet[j] = new Room(roomProp, lightProp);
                }
            }
            else
            {
                // Finds the parent index of the room based on it's position in the array and number of branching rooms.
                float indexFloat      = j;
                int   parentRoomIndex = Mathf.CeilToInt(indexFloat /= ROOMS_PER_BRANCH) - 1;
                if (j >= endIndex - 1) // If the index is that of an end room
                {
                    roomProp.rObject = endRoomObject;
                    roomProp.tag     = "END ROOM";
                    roomProp.scale   = new Vector3(0.001f, 0.001f, 0.001f);
                }
                else
                {
                    roomProp.rObject = roomObject;
                    roomProp.tag     = "ROOM";
                    roomProp.scale   = new Vector3(1, 1, 1);
                }
                roomProp.parentTransform = roomSet[parentRoomIndex].gameObj.transform;
                // Set light properties for the current room.
                lightProp.lightConfig = roomArray[j];
                if (j == 1) // First room on the right
                {
                    roomProp.offset      = initialRightOffset;
                    roomProp.orientation = rightOrientation;
                    roomSet[j]           = new Room(roomProp, lightProp);
                }
                else if (j == 2) // First room on the left
                {
                    roomProp.offset      = initialLeftOffset;
                    roomProp.orientation = leftOrientation;
                    roomSet[j]           = new Room(roomProp, lightProp);
                }
                else
                {
                    // Final Child Rooms
                    if (j % 2 == 0) // If the index is even, the room is on the left
                    {
                        if (roomProp.tag == "END ROOM")
                        {
                            lightProp.lightLeftOffset  = lastLightLeftOffset;
                            lightProp.lightRightOffset = lastLightRightOffset;
                            roomProp.offset            = endLeftOffset;
                        }
                        else
                        {
                            roomProp.offset = leftOffset;
                        }
                        roomProp.orientation = leftOrientation;
                        roomSet[j]           = new Room(roomProp, lightProp);
                    }
                    else // If the index is odd, the room is on the right
                    {
                        if (roomProp.tag == "END ROOM")
                        {
                            lightProp.lightLeftOffset  = lastLightLeftOffset;
                            lightProp.lightRightOffset = lastLightRightOffset;
                            roomProp.offset            = endRightOffset;
                        }
                        else
                        {
                            roomProp.offset = rightOffset;
                        }
                        roomProp.orientation = rightOrientation;
                        roomSet[j]           = new Room(roomProp, lightProp);
                    }
                }
            }
            // Give the room the name room + it's array index.
            roomSet[j].gameObj.name = "Room" + j.ToString();
        }
    }
Ejemplo n.º 9
0
 private byte[] WriteLightConfig(LightConfig config)
 {
     return(config.Serialize());
 }
Ejemplo n.º 10
0
        public async Task <dynamic> Handle(dynamic session, dynamic message)
        {
            string what   = message.head.what;
            var    userId = Guid.Parse(session.userId.ToString());

            if (what == "poll-cancel")
            {
                //var sessions = StructureGraph.Instance.GetSessions();
                var sessions = CacheRepository.Instance.GetSessions();
                foreach (var sess in sessions)
                {
                    if (sess.id == session.id)
                    {
                        continue;
                    }
                    var bag = sess as IDictionary <string, object>;
                    if (!bag.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID))
                    {
                        continue;
                    }
                    var connectionId = bag[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                    SignalRConnection.RaiseEvent(message, connectionId);
                }
                return(Helper.BuildMessage(what));
            }


            if (what.StartsWith("poll-vcom"))
            {
                //var sessions = StructureGraph.Instance.GetSessions();
                var sessions = CacheRepository.Instance.GetSessions();
                foreach (var sess in sessions)
                {
                    if (sess.id == session.id)
                    {
                        continue;
                    }
                    var bag = sess as IDictionary <string, object>;
                    if (!bag.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID))
                    {
                        continue;
                    }
                    var connectionId = bag[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                    SignalRConnection.RaiseEvent(message, connectionId);
                }
                return(Helper.BuildMessage(what));
            }


            if (what == "poll")
            {
                //препроцессинг
                //редиректы

                var dmessage = message.body as IDictionary <string, object>;
                if (dmessage.ContainsKey("redirect"))
                {
                    var objIds = new List <Guid>();
                    foreach (var objId in message.body.objectIds)
                    {
                        objIds.Add(Guid.Parse(objId));
                    }
                    message.body.objectIds = StructureGraph.Instance.GetRelatedIds(objIds, message.body.redirect.ToString());
                }

                var sessions = CacheRepository.Instance.GetSessions();
                foreach (var sess in sessions)
                {
                    if (sess.id == session.id)
                    {
                        continue;
                    }
                    var bag = sess as IDictionary <string, object>;
                    if (!bag.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID))
                    {
                        continue;
                    }
                    var connectionId = bag[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                    SignalRConnection.RaiseEvent(message, connectionId);
                }
            }

            if (what == "poll-subscribe")
            {
                var bag = session.bag as IDictionary <string, object>;
                if (!bag.ContainsKey(SUBSCRIBE))
                {
                    bag.Add(SUBSCRIBE, new Dictionary <Guid, IEnumerable <Guid> >());
                }
                var old = (Dictionary <Guid, IEnumerable <Guid> >)bag[SUBSCRIBE];
                foreach (dynamic subs in message.body.subscribers)
                {
                    Guid tubeId     = subs.id;
                    var  sattelites = new List <Guid>();
                    foreach (Guid satteliteId in subs.sattelites)
                    {
                        sattelites.Add(satteliteId);
                    }
                    if (old.ContainsKey(tubeId))
                    {
                        old[tubeId] = sattelites;
                    }
                    else
                    {
                        old.Add(tubeId, sattelites);
                    }
                }
                session.Bag[SUBSCRIBE] = old;
            }

            if (what == "poll-unsubscribe")
            {
                var bag = session.bag as IDictionary <string, object>;
                if (!bag.ContainsKey(SUBSCRIBE))
                {
                    bag.Add(SUBSCRIBE, new Dictionary <Guid, IEnumerable <Guid> >());
                }
                var old = (Dictionary <Guid, IEnumerable <Guid> >)bag[SUBSCRIBE];
                foreach (dynamic subs in message.body.subscribers)
                {
                    Guid tubeId = subs.tubeId;
                    if (old.ContainsKey(tubeId))
                    {
                        old.Remove(tubeId);
                    }
                }
                session.Bag[SUBSCRIBE] = old;
            }
            if (what == "poll-get-objectid-imeina")
            {
                string imei           = message.body.imei;
                string networkaddress = $"{message.body.networkaddress}";
                var    objectId       = StructureGraph.Instance.GetTubeIdFromIMEIandNetworkAddress(imei, networkaddress);
                var    answer         = Helper.BuildMessage(what);
                answer.body.objectId = objectId;
                return(answer);
            }
            if (what == "poll-get-objectid-imeina-matrixterminal")
            {
                string imei           = message.body.imei;
                string networkaddress = $"{message.body.networkaddress}";
                var    objectId       = StructureGraph.Instance.GetTubeIdFromIMEIandNAMatrixTerminal(imei, networkaddress);
                var    answer         = Helper.BuildMessage(what);
                answer.body.objectId = objectId;
                return(answer);
            }
            if (what == "poll-set-light-astronomtimer")
            {
                byte afterSunSet   = Byte.Parse(message.body.afterBeforeSunSetRise[0]);
                byte beforeSunRise = Byte.Parse(message.body.afterBeforeSunSetRise[1]);

                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                byte   u8timeDiff = Byte.Parse(message.body.utc);
                double dLatitude  = Double.Parse(((string)message.body.coordinates[0]).Replace(',', '.'));
                UInt32 latitude   = (UInt32)(dLatitude * 10000000);
                double dLongitude = Double.Parse(((string)message.body.coordinates[1]).Replace(',', '.'));
                UInt32 longitude  = (UInt32)(dLongitude * 10000000);
                string cmd        = "setAstronTimer";

                List <byte> listSetAstronom = new List <byte>();
                listSetAstronom.Add(u8timeDiff);

                byte[] u32Lat = BitConverter.GetBytes(latitude);
                listSetAstronom.AddRange(u32Lat);

                byte[] u32Lon = BitConverter.GetBytes(longitude);
                listSetAstronom.AddRange(u32Lon);

                listSetAstronom.Add(afterSunSet);

                listSetAstronom.Add(beforeSunRise);

                dynamic msg = new ExpandoObject();
                msg = Helper.BuildMessage("poll");
                msg.head.sessionId      = message.head.sessionId;
                msg.body.objectIds      = new string[] { (string)message.body.objectId };
                msg.body.what           = "all";
                msg.body.arg            = new ExpandoObject();
                msg.body.arg.components = "Current";
                msg.body.arg.onlyHoles  = false;
                msg.body.arg.cmd        = cmd + BitConverter.ToString(listSetAstronom.ToArray());
                var sessions = CacheRepository.Instance.GetSessions();
                foreach (var sess in sessions)
                {
                    if (sess.id == session.id)
                    {
                        continue;
                    }
                    var bag = sess as IDictionary <string, object>;
                    if (!bag.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID))
                    {
                        continue;
                    }
                    var connectionId = bag[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                    SignalRConnection.RaiseEvent(msg, connectionId);
                }
            }
            if (what == "poll-light-control-config")
            {
                var lightControlMetod           = message.body.lightControlMetod;
                var afterSunSetAndBeforeSunRise = message.body.afterSunSetAndBeforeSunRise;

                var      lightSheduleOn  = message.body.lightSheduleOn;
                var      lightSheduleOff = message.body.lightSheduleOff;
                DateTime dt1970          = new DateTime(1970, 1, 1, 0, 0, 0);

                Guid        id          = Guid.Parse(message.body.objectId.ToString());
                dynamic     tube        = StructureGraph.Instance.GetTube(id, userId);
                string      strConfig   = (string)tube.strConfig;
                var         bytesConfig = strConfig.Split('-').Select(x => byte.Parse(x, NumberStyles.HexNumber)).ToArray();
                LightConfig conf        = StructsHelper.Instance.setBytesFromConfig <LightConfig>(bytesConfig, new LightConfig());

                string cmd = "setAstronTimer";

                if (lightControlMetod.Count > 0 && lightControlMetod[0] != null)
                {
                    conf.ligthtChannels1.u8ControlMode = Convert.ToByte(lightControlMetod[0]);
                }
                conf.ligthtChannels1.u8afterSunSet   = Convert.ToByte(afterSunSetAndBeforeSunRise[0][0]);
                conf.ligthtChannels1.u8beforeSunRise = Convert.ToByte(afterSunSetAndBeforeSunRise[0][1]);

                conf.ligthtChannels1.on1 = lightChannelOnOff(lightSheduleOn[0][0]);
                conf.ligthtChannels1.on2 = lightChannelOnOff(lightSheduleOn[0][1]);   //------------------

                conf.ligthtChannels1.off1 = lightChannelOnOff(lightSheduleOff[0][0]); //---------------------
                conf.ligthtChannels1.off2 = lightChannelOnOff(lightSheduleOff[0][1]);

                if (lightControlMetod.Count > 1 && lightControlMetod[1] != null)
                {
                    conf.ligthtChannels2.u8ControlMode = Convert.ToByte(lightControlMetod[1]);
                }

                conf.ligthtChannels2.u8afterSunSet   = Convert.ToByte(afterSunSetAndBeforeSunRise[1][0]);
                conf.ligthtChannels2.u8beforeSunRise = Convert.ToByte(afterSunSetAndBeforeSunRise[1][1]);

                conf.ligthtChannels2.on1 = lightChannelOnOff(lightSheduleOn[1][0]);
                conf.ligthtChannels2.on2 = lightChannelOnOff(lightSheduleOn[1][1]);

                conf.ligthtChannels2.off1 = lightChannelOnOff(lightSheduleOff[1][0]);
                conf.ligthtChannels2.off2 = lightChannelOnOff(lightSheduleOff[1][1]);

                if (lightControlMetod.Count > 2 && lightControlMetod[2] != null)
                {
                    conf.ligthtChannels3.u8ControlMode = Convert.ToByte(lightControlMetod[2]);
                }
                conf.ligthtChannels3.u8afterSunSet   = Convert.ToByte(afterSunSetAndBeforeSunRise[2][0]);
                conf.ligthtChannels3.u8beforeSunRise = Convert.ToByte(afterSunSetAndBeforeSunRise[2][1]);

                conf.ligthtChannels3.on1 = lightChannelOnOff(lightSheduleOn[2][0]);
                conf.ligthtChannels3.on2 = lightChannelOnOff(lightSheduleOn[2][1]);

                conf.ligthtChannels3.off1 = lightChannelOnOff(lightSheduleOff[2][0]);
                conf.ligthtChannels3.off2 = lightChannelOnOff(lightSheduleOff[2][1]);

                if (lightControlMetod.Count > 3 && lightControlMetod[3] != null)
                {
                    conf.ligthtChannels4.u8ControlMode = Convert.ToByte(lightControlMetod[3]);
                }
                conf.ligthtChannels4.u8afterSunSet   = Convert.ToByte(afterSunSetAndBeforeSunRise[3][0]);
                conf.ligthtChannels4.u8beforeSunRise = Convert.ToByte(afterSunSetAndBeforeSunRise[3][1]);

                conf.ligthtChannels4.on1  = lightChannelOnOff(lightSheduleOn[3][0]);
                conf.ligthtChannels4.on2  = lightChannelOnOff(lightSheduleOn[3][1]);
                conf.ligthtChannels4.off1 = lightChannelOnOff(lightSheduleOff[3][0]);
                conf.ligthtChannels4.off2 = lightChannelOnOff(lightSheduleOff[3][1]);

                byte[]  outByte = StructsHelper.Instance.getBytes <LightConfig>(conf);
                dynamic msg     = new ExpandoObject();
                msg = Helper.BuildMessage("poll");
                msg.head.sessionId      = message.head.sessionId;
                msg.body.objectIds      = new string[] { (string)message.body.objectId };
                msg.body.what           = "all";
                msg.body.arg            = new ExpandoObject();
                msg.body.arg.components = "Current";
                msg.body.arg.onlyHoles  = false;
                msg.body.arg.cmd        = cmd + BitConverter.ToString(outByte);
                var sessions = CacheRepository.Instance.GetSessions();
                foreach (var sess in sessions)
                {
                    if (sess.id == session.id)
                    {
                        continue;
                    }
                    var bag = sess as IDictionary <string, object>;
                    if (!bag.ContainsKey(SignalRConnection.SIGNAL_CONNECTION_ID))
                    {
                        continue;
                    }
                    var connectionId = bag[SignalRConnection.SIGNAL_CONNECTION_ID].ToString();
                    SignalRConnection.RaiseEvent(msg, connectionId);
                }
            }

            var ans = Helper.BuildMessage("poll-accepted");

            return(ans);
        }
Ejemplo n.º 11
0
 public void HueLightEntityRegistry()
 {
     LightConfig.DeserializeLightObjectGraph();
 }
Ejemplo n.º 12
0
        //Engine file constructor
        public Level(string enginePath)
        {
            path = Path.GetDirectoryName(enginePath);

            // Engine elements
            using (EngineParser engineParser = new EngineParser(enginePath))
            {
                game = engineParser.DetectGame();

                //REMOVE THESE ASAP!!!!!111
                renderDefBytes   = engineParser.GetRenderDefBytes();
                collBytes        = engineParser.GetCollisionBytes();
                billboardBytes   = engineParser.GetBillboardBytes();
                soundConfigBytes = engineParser.GetSoundConfigBytes();

                Console.WriteLine("Parsing skybox...");
                skybox = engineParser.GetSkyboxModel();
                Console.WriteLine("Success");

                Console.WriteLine("Parsing moby models...");
                mobyModels = engineParser.GetMobyModels();
                Console.WriteLine("Added " + mobyModels.Count + " moby models");

                Console.WriteLine("Parsing tie models...");
                tieModels = engineParser.GetTieModels();
                Console.WriteLine("Added " + tieModels.Count + " tie models");

                Console.WriteLine("Parsing shrub models...");
                shrubModels = engineParser.GetShrubModels();
                Console.WriteLine("Added " + shrubModels.Count + " shrub models");

                Console.WriteLine("Parsing weapons...");
                weaponModels = engineParser.GetWeapons();
                Console.WriteLine("Added " + weaponModels.Count + " weapons");

                Console.WriteLine("Parsing textures...");
                textures = engineParser.GetTextures();
                Console.WriteLine("Added " + textures.Count + " textures");

                Console.WriteLine("Parsing ties...");
                ties = engineParser.GetTies(tieModels);
                Console.WriteLine("Added " + ties.Count + " ties");

                Console.WriteLine("Parsing Shrubs...");
                shrubs = engineParser.GetShrubs(shrubModels);
                Console.WriteLine("Added " + shrubs.Count + " Shrubs");

                Console.WriteLine("Parsing Lights...");
                lights = engineParser.GetLights();
                Console.WriteLine("Added " + lights.Count + " lights");

                Console.WriteLine("Parsing terrain elements...");
                terrains = engineParser.GetTerrainModels();
                Console.WriteLine("Added " + terrains?.Count + " terrain elements");

                Console.WriteLine("Parsing player animations...");
                playerAnimations = engineParser.GetPlayerAnimations((MobyModel)mobyModels[0]);
                Console.WriteLine("Added " + playerAnimations?.Count + " player animations");

                uiElements = engineParser.GetUiElements();
                Console.WriteLine("Added " + uiElements?.Count + " ui elements");

                lightConfig        = engineParser.GetLightConfig();
                textureConfigMenus = engineParser.GetTextureConfigMenu();
                collisionModel     = engineParser.GetCollisionModel();
            }


            // Gameplay elements
            using (GameplayParser gameplayParser = new GameplayParser(game, path + @"/gameplay_ntsc"))
            {
                Console.WriteLine("Parsing Level variables...");
                levelVariables = gameplayParser.GetLevelVariables();

                Console.WriteLine("Parsing mobs...");
                mobs = gameplayParser.GetMobies(game, mobyModels);
                Console.WriteLine("Added " + mobs?.Count + " mobs");

                Console.WriteLine("Parsing splines...");
                splines = gameplayParser.GetSplines();
                //Console.WriteLine("Added " + splines.Count + " splines");

                Console.WriteLine("Parsing languages...");
                english = gameplayParser.GetEnglish();
                lang2   = gameplayParser.GetLang2();
                french  = gameplayParser.GetFrench();
                german  = gameplayParser.GetGerman();
                spanish = gameplayParser.GetSpanish();
                italian = gameplayParser.GetItalian();
                lang7   = gameplayParser.GetLang7();
                lang8   = gameplayParser.GetLang8();

                Console.WriteLine("Parsing other gameplay assets...");
                unk6  = gameplayParser.GetUnk6();
                unk7  = gameplayParser.GetUnk7();
                unk13 = gameplayParser.GetUnk13();
                unk17 = gameplayParser.GetUnk17();
                unk14 = gameplayParser.GetUnk14();

                tieData   = gameplayParser.GetTieData(ties.Count);
                shrubData = gameplayParser.getShrubData(shrubs.Count);

                type04s = gameplayParser.GetType04s();
                type0Cs = gameplayParser.GetType0Cs();
                type64s = gameplayParser.GetType64s();
                type68s = gameplayParser.GetType68s();
                type7Cs = gameplayParser.GetType7Cs();
                type80s = gameplayParser.GetType80();
                type88s = gameplayParser.GetType88s();
                type50s = gameplayParser.GetType50s();
                type5Cs = gameplayParser.GetType5Cs();

                pVars       = gameplayParser.GetPvars(mobs);
                cuboids     = gameplayParser.GetCuboids();
                gameCameras = gameplayParser.GetGameCameras();

                mobyIds       = gameplayParser.GetMobyIds();
                tieIds        = gameplayParser.GetTieIds();
                shrubIds      = gameplayParser.GetShrubIds();
                occlusionData = gameplayParser.GetOcclusionData();
            }


            VramParser vramParser = new VramParser(path + @"/vram.ps3");

            if (!vramParser.valid)
            {
                valid = false;
                return;
            }

            vramParser.GetTextures(textures);
            vramParser.Close();


            Console.WriteLine("Level parsing done");
            valid = true;
        }
Ejemplo n.º 13
0
 internal LightController(LightConfig config, Action <LightController> onLightStateChanged)
 {
     _onLightStateChanged = onLightStateChanged;
     Config = config;
 }