diff --git a/common/src/state.rs b/common/src/state.rs index 56d476b4f4..656ff40a51 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -20,11 +20,11 @@ use vek::*; /// How much faster should an in-game day be compared to a real day? // TODO: Don't hard-code this. -const DAY_CYCLE_FACTOR: f64 = 24.0 * 60.0; +const DAY_CYCLE_FACTOR: f64 = 24.0 * 2.0; /// A resource that stores the time of day. #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct TimeOfDay(f64); +pub struct TimeOfDay(pub f64); /// A resource that stores the tick (i.e: physics) time. #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 510a171ff9..750bb6ef2d 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -7,6 +7,7 @@ use common::{ comp, msg::ServerMsg, npc::{get_npc_name, NpcKind}, + state::TimeOfDay, }; use specs::{Builder, Entity as EcsEntity, Join}; use vek::*; @@ -59,37 +60,43 @@ lazy_static! { "jump", "{d} {d} {d}", "/jump : Offset your current position", - handle_jump + handle_jump, ), ChatCommand::new( "goto", "{d} {d} {d}", "/goto : Teleport to a position", - handle_goto + handle_goto, ), ChatCommand::new( "alias", "{}", "/alias : Change your alias", - handle_alias + handle_alias, ), ChatCommand::new( "tp", "{}", "/tp : Teleport to another player", - handle_tp + handle_tp, ), ChatCommand::new( "kill", "{}", "/kill : Kill yourself", - handle_kill + handle_kill, + ), + ChatCommand::new( + "time", + "{} {s}", + "/time : Set the time of day", + handle_time, ), ChatCommand::new( "spawn", "{} {} {d}", "/spawn [amount] : Spawn a test entity", - handle_spawn + handle_spawn, ), ChatCommand::new( "help", "", "/help: Display this message", handle_help) @@ -143,6 +150,31 @@ fn handle_kill(server: &mut Server, entity: EcsEntity, _args: String, _action: & .map(|s| s.hp.set_to(0, comp::HealthSource::Suicide)); } +fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) { + let time = scan_fmt!(&args, action.arg_fmt, String); + server + .state + .ecs_mut() + .write_resource::() + .0 = match time.as_ref().map(|s| s.as_str()) { + Some("day") => 12.0 * 3600.0, + Some("night") => 24.0 * 3600.0, + Some("dawn") => 5.0 * 3600.0, + Some("dusk") => 17.0 * 3600.0, + Some(n) => match n.parse() { + Ok(n) => n, + Err(_) => { + server.clients.notify(entity, ServerMsg::Chat(format!("'{}' is not a time!", n))); + return; + }, + }, + None => { + server.clients.notify(entity, ServerMsg::Chat("You must specify a time!".to_string())); + return; + }, + }; +} + fn handle_alias(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) { let opt_alias = scan_fmt!(&args, action.arg_fmt, String); match opt_alias { diff --git a/voxygen/shaders/include/sky.glsl b/voxygen/shaders/include/sky.glsl index c65fd42544..c7402333b3 100644 --- a/voxygen/shaders/include/sky.glsl +++ b/voxygen/shaders/include/sky.glsl @@ -66,7 +66,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day) { vec3 sun_dir = get_sun_dir(time_of_day); float sky_brightness = get_sun_brightness(sun_dir); - vec3 sun_halo = pow(max(dot(dir, -sun_dir) + 0.5, 0.0), 8.0) * SUN_HALO_COLOR; + vec3 sun_halo = pow(max(dot(dir, -sun_dir) + 0.1, 0.0), 8.0) * SUN_HALO_COLOR; vec3 sun_surf = pow(max(dot(dir, -sun_dir) - 0.0045, 0.0), 1000.0) * SUN_SURF_COLOR; vec3 sun_light = sun_halo + sun_surf;