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); }
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 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"); }
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); }