private void Load(IFileStore store) { var kvp = new KeyValuePairs(); using (var reader = store.OpenTextFile(Path)) { kvp.Load(reader); } BackgroundColour = kvp.GetColour("background_colour", Vector3.Zero); BackgroundImage = kvp.GetString("background_image", null); AmbientColour = kvp.GetColour("ambient_colour", Vector3.One); LightColour = kvp.GetColour("light_colour", Vector3.Zero); LightDirection = kvp.GetUnitVector("light_direction", -Vector3.UnitY); Light2Colour = kvp.GetColour("light2_colour", Vector3.Zero); Light2Direction = kvp.GetUnitVector("light2_direction", -Vector3.UnitY); ModelPath = kvp.GetString("model", null); ForegroundModelPath = kvp.GetString("foreground_model", null); AnimPath = kvp.GetString("animation", null); RenderPass = kvp.GetEnum("render_pass", RenderPass.Opaque); ForegroundRenderPass = kvp.GetEnum("foreground_render_pass", RenderPass.Opaque); CastShadows = kvp.GetBool("cast_shadows", false); }
public SpawnTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_colour = kvp.GetString("colour", "grey"); m_immobile = kvp.GetBool("immobile", false); m_required = kvp.GetBool("required", m_colour != "grey" && !m_immobile); m_turnPreference = kvp.GetEnum("turn_preference", TurnDirection.Left); if (kvp.ContainsKey("robot_model")) { m_robotModel = kvp.GetString("robot_model"); } else { throw new IOException("robot_model not specified"); } m_robotLightColour = kvp.GetColour("light_colour", Vector3.Zero); if (m_robotLightColour.Value.Length <= 0.0f) { m_robotLightColour = null; } m_robotLightRadius = kvp.GetFloat("light_radius", 15.0f); if (m_robotLightRadius.Value <= 0.0f) { m_robotLightRadius = null; } m_robotAnimSet = kvp.GetString("robot_animset", "animation/entities/new_robot/new_robot.animset"); m_robotSoundSet = kvp.GetString("robot_soundset", "sound/new_robot/new_robot.soundset"); m_guiColour = kvp.GetColour("gui_colour", Vector3.One); }
private void Load(IFileStore store) { var kvp = new KeyValuePairs(); using (var stream = store.OpenTextFile(m_path)) { kvp.Load(stream); } m_vertexShaderPath = kvp.GetString("vertex_shader"); string[] vertexShaderDefines = kvp.ContainsKey("vertex_shader_defines") ? kvp.GetString("vertex_shader_defines").Split(',') : null; string vertexShaderCode = Preprocess(store, m_vertexShaderPath, vertexShaderDefines); m_fragmentShaderPath = kvp.GetString("fragment_shader"); string[] fragmentShaderDefines = kvp.ContainsKey("fragment_shader_defines") ? kvp.GetString("fragment_shader_defines").Split(',') : null; string fragmentShaderCode = Preprocess(store, m_fragmentShaderPath, fragmentShaderDefines); m_vertexShader = GL.CreateShader(ShaderType.VertexShader); GL.ShaderSource(m_vertexShader, vertexShaderCode); GL.CompileShader(m_vertexShader); CheckCompileResult(m_vertexShader); m_fragmentShader = GL.CreateShader(ShaderType.FragmentShader); GL.ShaderSource(m_fragmentShader, fragmentShaderCode); GL.CompileShader(m_fragmentShader); CheckCompileResult(m_fragmentShader); m_program = GL.CreateProgram(); GL.AttachShader(m_program, m_vertexShader); GL.AttachShader(m_program, m_fragmentShader); GL.LinkProgram(m_program); TestLink(m_program); m_blendMode = kvp.GetEnum("blend_mode", BlendMode.Overwrite); }
public ElevatorTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { Distance = kvp.GetInteger("distance", 1); Speed = 1.0f / Robot.Robot.STEP_TIME; Direction = kvp.GetEnum("direction", ElevatorDirection.Up); Trigger = kvp.GetEnum("trigger", ElevatorTrigger.Powered); RiseSoundPath = kvp.GetString("rise_sound", null); FallSoundPath = kvp.GetString("fall_sound", null); }
public void ReloadInfo() { // Set default info Title = "Untitled Mod"; Version = new Version(1, 0, 0); MinimumGameVersion = new Version(0, 0, 0); Author = null; AuthorTwitter = null; AutoLoad = false; SteamWorkshopID = null; SteamUserID = null; // Reload the index if (m_contents != null) { m_contents.ReloadIndex(); } // Parse info.txt var infoPath = "info.txt"; if (m_contents != null && m_contents.FileExists(infoPath)) { var kvp = new KeyValuePairs(); using (var stream = m_contents.OpenTextFile(infoPath)) { kvp.Load(stream); } Title = kvp.GetString("title", Title); Version = kvp.GetVersion("version", Version); MinimumGameVersion = kvp.GetVersion("game_version", MinimumGameVersion); Author = kvp.GetString("author", null); AuthorTwitter = kvp.GetString("author_twitter", null); AutoLoad = kvp.GetBool("autoload", false); if (kvp.ContainsKey("steam_workshop_id")) { SteamWorkshopID = kvp.GetULong("steam_workshop_id"); } else { SteamWorkshopID = null; } if (kvp.ContainsKey("steam_user_id")) { SteamUserID = kvp.GetULong("steam_user_id"); } else { SteamUserID = null; } } // Reload the index m_assets.Name = Title; m_assets.FileStore.ReloadIndex(); }
public IAnimation GetAnim(string key) { if (m_kvp.ContainsKey(key)) { return(LuaAnimation.Get(m_kvp.GetString(key))); } if (m_kvp.ContainsKey("default")) { return(LuaAnimation.Get(m_kvp.GetString("default"))); } return(null); }
public string GetSound(string key) { if (m_kvp.ContainsKey(key)) { return(m_kvp.GetString(key)); } if (m_kvp.ContainsKey("default")) { return(m_kvp.GetString("default")); } return(null); }
public WireTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_poweredModelPath = kvp.GetString("powered_model", tile.ModelPath); m_altPoweredModelPath = kvp.GetString("alt_powered_model", m_poweredModelPath); bool connected = kvp.GetBool("connected", false); m_connectivity = new bool[6]; m_connectivity[0] = kvp.GetBool("connected_front", connected); m_connectivity[1] = kvp.GetBool("connected_right", connected); m_connectivity[2] = kvp.GetBool("connected_back", connected); m_connectivity[3] = kvp.GetBool("connected_left", connected); m_connectivity[4] = kvp.GetBool("connected_top", connected); m_connectivity[5] = kvp.GetBool("connected_bottom", connected); }
public void Load(IFileStore store) { var kvp = new KeyValuePairs(); using (var stream = store.OpenTextFile(m_path)) { kvp.Load(stream); } m_modelPath = kvp.GetString("model", null); m_altModelPath = kvp.GetString("alt_model", m_modelPath); m_editorModelPath = kvp.GetString("editor_model", null); m_height = kvp.GetInteger("height", 1); m_placeable = kvp.GetBool("placeable", false); m_replaceable = kvp.GetBool("replaceable", false); m_solidity = new bool[6]; bool solid = kvp.GetBool("solid", false); m_solidity[0] = kvp.GetBool("solid_front", solid); m_solidity[1] = kvp.GetBool("solid_right", solid); m_solidity[2] = kvp.GetBool("solid_back", solid); m_solidity[3] = kvp.GetBool("solid_left", solid); m_solidity[4] = kvp.GetBool("solid_top", solid); m_solidity[5] = kvp.GetBool("solid_bottom", solid); m_opacity = new bool[6]; bool opaque = kvp.GetBool("opaque", false); m_opacity[0] = kvp.GetBool("opaque_front", opaque); m_opacity[1] = kvp.GetBool("opaque_right", opaque); m_opacity[2] = kvp.GetBool("opaque_back", opaque); m_opacity[3] = kvp.GetBool("opaque_left", opaque); m_opacity[4] = kvp.GetBool("opaque_top", opaque); m_opacity[5] = kvp.GetBool("opaque_bottom", opaque); m_forwardIncline = kvp.GetInteger("incline_forward", 0); m_rightIncline = kvp.GetInteger("incline_right", 0); m_allowPlacement = kvp.GetBool("allow_placement", true); var behaviour = kvp.GetString("behaviour", "generic"); m_behaviour = TileBehaviour.CreateFromName(behaviour, this, kvp); m_renderPass = kvp.GetEnum("render_pass", RenderPass.Opaque); m_castShadows = kvp.GetBool("cast_shadows", true); }
public void Reload(IFileStore store) { var kvp = new KeyValuePairs(); using (var reader = store.OpenTextFile(m_path)) { kvp.Load(reader); } Lifetime = kvp.GetFloat("lifetime", 5.0f); EmitterRate = kvp.GetFloat("emitter_rate", 1.0f); Position = kvp.GetVector("position", Vector3.Zero); PositionRange = kvp.GetVector("position_range", Vector3.Zero); Velocity = kvp.GetVector("velocity", Vector3.Zero); VelocityRange = kvp.GetVector("velocity_range", Vector3.Zero); Gravity = kvp.GetVector("gravity", new Vector3(0.0f, -9.8f, 0.0f)); Radius = kvp.GetFloat("radius", 0.125f); FinalRadius = kvp.GetFloat("final_radius", Radius); var colour = kvp.GetColour("colour", Vector3.One); var alpha = kvp.GetFloat("alpha", 1.0f); Colour = new Vector4(colour, alpha); var finalColour = kvp.GetColour("final_colour", colour); var finalAlpha = kvp.GetFloat("final_alpha", alpha); FinalColour = new Vector4(finalColour, finalAlpha); Texture = kvp.GetString("texture", "white.png"); }
public void Reload(IFileStore store) { var kvp = new KeyValuePairs(); using (var reader = store.OpenTextFile(m_path)) { kvp.Load(reader); } ID = kvp.GetInteger("id", 0); Title = kvp.GetString("title", null); ContentPath = kvp.GetString("content_path", DefaultContentPath); Button0Prompt = kvp.GetString("button0_prompt", "A"); Button1Prompt = kvp.GetString("button1_prompt", "B"); UnlockCampaign = kvp.GetString("unlock_campaign", null); UnlockLevelCount = kvp.GetInteger("unlock_level_count", 0); }
public static bool GetEmbeddedGameInfo(out string o_gameTitle, out string o_gameVersion, out string o_gameURL, out string o_username, out string o_password) { try { var assembly = Assembly.GetExecutingAssembly(); var stream = assembly.GetManifestResourceStream("EmbeddedGame." + Program.Platform + ".txt"); if (stream == null) { stream = assembly.GetManifestResourceStream("EmbeddedGame.txt"); } if (stream != null) { var kvp = new KeyValuePairs(); kvp.Load(stream); if (kvp.ContainsKey("game")) { o_gameTitle = kvp.GetString("game"); o_gameVersion = kvp.GetString("version"); o_gameURL = kvp.GetString("url"); o_username = kvp.GetString("username"); o_password = kvp.GetString("password"); return(true); } } o_gameTitle = default(string); o_gameVersion = default(string); o_gameURL = default(string); o_username = default(string); o_password = default(string); return(false); } catch (Exception e) { Logger.Log("Caught Exception: {0}", e.ToString()); o_gameTitle = default(string); o_gameVersion = default(string); o_gameURL = default(string); o_username = default(string); o_password = default(string); return(false); } }
public ButtonTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_poweredModelPath = kvp.GetString("powered_model", tile.ModelPath); m_altPoweredModelPath = kvp.GetString("alt_powered_model", m_poweredModelPath); m_soundPath = kvp.GetString("sound", null); bool connected = kvp.GetBool("connected", false); m_connectivity = new bool[6]; m_connectivity[0] = kvp.GetBool("connected_front", connected); m_connectivity[1] = kvp.GetBool("connected_right", connected); m_connectivity[2] = kvp.GetBool("connected_back", connected); m_connectivity[3] = kvp.GetBool("connected_left", connected); m_connectivity[4] = kvp.GetBool("connected_top", connected); m_connectivity[5] = kvp.GetBool("connected_bottom", connected); m_type = kvp.GetEnum("type", ButtonType.Momentary); m_inverted = kvp.GetBool("inverted", false); m_colour = kvp.GetString("colour"); }
public AnimatedTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { Animation = kvp.GetString("animation", null); PoweredAnimation = kvp.GetString("powered_animation", Animation); PFX = kvp.GetString("pfx", null); PoweredPFX = kvp.GetString("powered_pfx", PFX); PoweredModel = kvp.GetString("powered_model", tile.ModelPath); AltPoweredModel = kvp.GetString("alt_powered_model", PoweredModel); }
private void Load(IFileStore store) { var kvp = new KeyValuePairs(); using (var reader = store.OpenTextFile(m_path)) { kvp.Load(reader); } if (kvp.Count == 0) { LegacyLoad(store); } else { // Read in the title and levels m_title = kvp.GetString("title", "Untitled Campaign"); m_levels.AddRange(kvp.GetStringArray("levels", new string[0])); m_checkpoints.AddRange(kvp.GetIntegerArray("checkpoints", new int[0])); m_id = kvp.GetInteger("id", MathUtils.SimpleStableHash(m_path)); m_initialLevelsUnlocked = kvp.GetInteger("initial_levels_unlocked", 1); m_hidden = kvp.GetBool("hidden", false); } }
private void Load(IFileStore store) { // Load the file var kvp = new KeyValuePairs(); using (var stream = store.OpenTextFile(m_path)) { kvp.Load(stream); } // Load the ID m_id = kvp.GetInteger("id", MathUtils.SimpleStableHash(m_path)); // Load the dimensions Width = kvp.GetInteger("tiles.width", 0); Height = kvp.GetInteger("tiles.height", 0); Depth = kvp.GetInteger("tiles.depth", 0); XOrigin = kvp.GetInteger("tiles.x_origin", 0); YOrigin = kvp.GetInteger("tiles.y_origin", 0); ZOrigin = kvp.GetInteger("tiles.z_origin", 0); // Load the tile lookup TileLookup = kvp.GetStringArray("tiles.lookup", new string[0]); // Load the tiles TileIDs = new int[Width, Height, Depth]; TileDirections = new FlatDirection[Width, Height, Depth]; var tileData = kvp.GetString("tiles.data", ""); for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { for (int z = 0; z < Depth; ++z) { int index = (x * Height * Depth) + (y * Depth) + z; var id = 0; var direction = FlatDirection.North; if (((index * 3) + 3) <= tileData.Length) { id = Base64.ParseInt(tileData.Substring(index * 3, 2)); int directionNum = Base64.ParseInt(tileData.Substring((index * 3) + 2, 1)); if (directionNum >= 0 && directionNum < 4) { direction = (FlatDirection)directionNum; } } TileIDs[x, y, z] = id; TileDirections[x, y, z] = direction; } } } // Load the level info Title = kvp.GetString("title", "Untitled"); Music = kvp.GetString("music", "music/lightless_dawn.ogg"); Sky = kvp.GetString("sky", "skies/starfield.sky"); Script = kvp.GetString("script", null); if (kvp.ContainsKey("items.grey_cube.count")) { Item = "tiles/new/cone_spawn.tile"; ItemCount = kvp.GetInteger("items.grey_cube.count", 0); } else { Item = kvp.GetString("item", "tiles/new/cone_spawn.tile"); ItemCount = kvp.GetInteger("item_count", 0); } EverCompleted = kvp.GetBool("ever_completed", false); CameraPitch = kvp.GetFloat("camera.pitch", 60.0f); CameraYaw = kvp.GetFloat("camera.yaw", 270.0f - 22.5f); CameraDistance = kvp.GetFloat("camera.distance", 18.0f); Intro = kvp.GetString("intro", null); Outro = kvp.GetString("outro", null); RandomSeed = kvp.GetInteger("random.seed", Path.GetHashCode()); RobotCount = kvp.GetInteger("robot_count", 0); }
public LiquidTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_texture = kvp.GetString("texture"); m_textureScale = kvp.GetFloat("texture_scale", 1.0f); m_animation = kvp.GetString("animation"); }
public ConveyorTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { PoweredMode = kvp.GetEnum("powered_mode", ConveyorMode.Stopped); UnpoweredMode = kvp.GetEnum("unpowered_mode", ConveyorMode.Forwards); Animation = kvp.GetString("animation", null); }
private void Load(IFileStore store) { using (var stream = store.OpenFile(m_path)) { var reader = new StreamReader(stream, Encoding.UTF8); string line; string type = null; var options = new KeyValuePairs(); while ((line = reader.ReadLine()) != null) { // Parse each line string[] parts = line.Split(' '); if (parts.Length < 1) { continue; } // Extract type and options type = parts[0]; options.Clear(); for (int i = 1; i < parts.Length; ++i) { string part = parts[i]; int equalsIndex = part.IndexOf('='); if (equalsIndex >= 0) { string key = part.Substring(0, equalsIndex); string value = part.Substring(equalsIndex + 1); int intValue; if (value.StartsWith("\"")) { if (value.EndsWith("\"") && value.Length >= 2) { value = value.Substring(1, value.Length - 2); } else { value = value.Substring(1) + " "; i++; while (!parts[i].EndsWith("\"")) { value += parts[i] + " "; i++; } value += parts[i].Substring(0, parts[i].Length - 1); } options.Set(key, value); } else if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue)) { options.Set(key, intValue); } } } // Interpret switch (type) { case "common": { m_lineHeight = options.GetInteger("lineHeight"); m_base = options.GetInteger("base"); m_scaleW = options.GetInteger("scaleW"); m_scaleH = options.GetInteger("scaleH"); m_pages = new Page[options.GetInteger("pages")]; break; } case "page": { int id = options.GetInteger("id"); if (id >= PageCount) { Array.Resize(ref m_pages, id + 1); } m_pages[id] = new Page(); m_pages[id].Path = AssetPath.Combine(AssetPath.GetDirectoryName(m_path), options.GetString("file")); break; } case "chars": { m_chars = new Dictionary <int, Char>(options.GetInteger("count")); break; } case "char": { var id = options.GetInteger("id"); m_chars[id] = new Char(); m_chars[id].X = options.GetInteger("x"); m_chars[id].Y = options.GetInteger("y"); m_chars[id].Width = options.GetInteger("width"); m_chars[id].Height = options.GetInteger("height"); m_chars[id].XOffset = options.GetInteger("xoffset"); m_chars[id].YOffset = options.GetInteger("yoffset"); m_chars[id].XAdvance = options.GetInteger("xadvance"); m_chars[id].Page = options.GetInteger("page"); if (m_chars[id].Page < 0 || m_chars[id].Page >= PageCount) { m_chars[id].Page = 0; //throw new IOException( "Page count out of range" ); } break; } case "kernings": { m_kernings = new Dictionary <KerningPair, Kerning>(options.GetInteger("count")); break; } case "kerning": { var first = options.GetInteger("first"); var second = options.GetInteger("second"); var pair = new KerningPair(first, second); m_kernings[pair] = new Kerning(); m_kernings[pair].Amount = options.GetInteger("amount"); break; } } } } }
public GoalTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_colour = kvp.GetString("colour", "red"); }
public TelepadTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { Colour = kvp.GetString("colour", "green"); Animation = kvp.GetString("animation", null); PFX = kvp.GetString("pfx", null); }
public FallingTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { m_trigger = kvp.GetEnum("trigger", FallingTrigger.Automatic); m_sound = kvp.GetString("sound", null); }
public TurntableTileBehaviour(Tile tile, KeyValuePairs kvp) : base(tile, kvp) { TurnDirection = kvp.GetEnum("turn_direction", TurnDirection.Left); Animation = kvp.GetString("animation", null); Sound = kvp.GetString("sound", null); }