Skip to content

Commit

Permalink
Merge pull request #10 from Corvax-Frontier/Up300624
Browse files Browse the repository at this point in the history
Up300624
  • Loading branch information
Vonsant authored Jun 30, 2024
2 parents 6beac5f + 9b3d138 commit 8f9bb77
Show file tree
Hide file tree
Showing 220 changed files with 382,911 additions and 228 deletions.
8 changes: 4 additions & 4 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static readonly CVarDef<bool>
/// Controls the default game preset.
/// </summary>
public static readonly CVarDef<string>
GameLobbyDefaultPreset = CVarDef.Create("game.defaultpreset", "Waves", CVar.ARCHIVE);
GameLobbyDefaultPreset = CVarDef.Create("game.defaultpreset", "Extended", CVar.ARCHIVE);

/// <summary>
/// Controls if the game can force a different preset if the current preset's criteria are not met.
Expand All @@ -165,7 +165,7 @@ public static readonly CVarDef<bool>
/// The preset for the game to fall back to if the selected preset could not be used, and fallback is enabled.
/// </summary>
public static readonly CVarDef<string>
GameLobbyFallbackPreset = CVarDef.Create("game.fallbackpreset", "Traitor,Extended", CVar.ARCHIVE);
GameLobbyFallbackPreset = CVarDef.Create("game.fallbackpreset", "Waves,Traitor,Extended", CVar.ARCHIVE);

/// <summary>
/// Controls if people can win the game in Suspicion or Deathmatch.
Expand Down Expand Up @@ -1346,7 +1346,7 @@ public static readonly CVarDef<bool>
/// See vote.enabled, but specific to map votes
/// </summary>
public static readonly CVarDef<bool> VoteMapEnabled =
CVarDef.Create("vote.map_enabled", false, CVar.SERVERONLY);
CVarDef.Create("vote.map_enabled", true, CVar.SERVERONLY);

/// <summary>
/// The required ratio of the server that must agree for a restart round vote to go through.
Expand All @@ -1358,7 +1358,7 @@ public static readonly CVarDef<bool>
/// Whether or not to prevent the restart vote from having any effect when there is an online admin
/// </summary>
public static readonly CVarDef<bool> VoteRestartNotAllowedWhenAdminOnline =
CVarDef.Create("vote.restart_not_allowed_when_admin_online", true, CVar.SERVERONLY);
CVarDef.Create("vote.restart_not_allowed_when_admin_online", false, CVar.SERVERONLY);

/// <summary>
/// The delay which two votes of the same type are allowed to be made by separate people, in seconds.
Expand Down
50 changes: 50 additions & 0 deletions Content.Shared/_NC/DayNightCycle/DayNightCycleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

namespace Content.Shared._NC14.DayNightCycle
{
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class DayNightCycleComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("cycleDuration")]
public float CycleDurationMinutes { get; set; } = 60f; // Default cycle duration is 60 minutes

[DataField("timeEntries")]
public List<TimeEntry> TimeEntries { get; set; } = new()
{
new() { Time = 0.00f, ColorHex = "#000000" }, // Midnight
new() { Time = 0.04f, ColorHex = "#02020b" }, // Very early morning
new() { Time = 0.08f, ColorHex = "#312716" }, // Early dawn
new() { Time = 0.17f, ColorHex = "#4E3D23" }, // Dawn
new() { Time = 0.25f, ColorHex = "#58372D" }, // Sunrise
new() { Time = 0.33f, ColorHex = "#876A42" }, // Early morning
new() { Time = 0.42f, ColorHex = "#A08042" }, // Mid-morning
new() { Time = 0.50f, ColorHex = "#A88F73" }, // Noon
new() { Time = 0.58f, ColorHex = "#C1A78A" }, // Early afternoon
new() { Time = 0.67f, ColorHex = "#7D6244" }, // Late afternoon
new() { Time = 0.75f, ColorHex = "#8C6130" }, // Sunset
new() { Time = 0.83f, ColorHex = "#543521" }, // Dusk
new() { Time = 0.92f, ColorHex = "#02020b" }, // Early night
new() { Time = 1.00f, ColorHex = "#000000" } // Back to Midnight
};

[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public int CurrentTimeEntryIndex { get; set; }

[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float CurrentCycleTime { get; set; }
}

[DataDefinition, NetSerializable, Serializable]
public sealed partial class TimeEntry
{
[DataField("colorHex")]
public string ColorHex { get; set; } = "#FFFFFF";

[DataField("time")]
public float Time { get; set; } // Normalized time (0-1)
}
}
117 changes: 117 additions & 0 deletions Content.Shared/_NC/DayNightCycle/DayNightCycleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using System.Linq;
using Robust.Shared.Map.Components;
using Robust.Shared.Timing;

namespace Content.Shared._NC14.DayNightCycle
{
public sealed class DayNightCycleSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;

private const float EARLY_MORNING_TIME = 0.2f; // This represents 20% into the cycle, which is early morning

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DayNightCycleComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<DayNightCycleComponent, ComponentStartup>(OnComponentStartup);
}

private void OnMapInit(EntityUid uid, DayNightCycleComponent component, MapInitEvent args)
{
if (component.TimeEntries.Count < 2)
{
// Default Fallout-inspired color cycle with more variants
component.TimeEntries = new List<TimeEntry>
{
new() { Time = 0.00f, ColorHex = "#000000" }, // Midnight
new() { Time = 0.04f, ColorHex = "#02020b" }, // Very early morning
new() { Time = 0.08f, ColorHex = "#312716" }, // Early dawn
new() { Time = 0.17f, ColorHex = "#4E3D23" }, // Dawn
new() { Time = 0.25f, ColorHex = "#58372D" }, // Sunrise
new() { Time = 0.33f, ColorHex = "#876A42" }, // Early morning
new() { Time = 0.42f, ColorHex = "#A08042" }, // Mid-morning
new() { Time = 0.50f, ColorHex = "#A88F73" }, // Noon
new() { Time = 0.58f, ColorHex = "#C1A78A" }, // Early afternoon
new() { Time = 0.67f, ColorHex = "#7D6244" }, // Late afternoon
new() { Time = 0.75f, ColorHex = "#8C6130" }, // Sunset
new() { Time = 0.83f, ColorHex = "#543521" }, // Dusk
new() { Time = 0.92f, ColorHex = "#02020b" }, // Early night
new() { Time = 1.00f, ColorHex = "#000000" } // Back to Midnight
};
}

InitializeEarlyMorning(component);
}

private void OnComponentStartup(EntityUid uid, DayNightCycleComponent component, ComponentStartup args)
{
InitializeEarlyMorning(component);
}

private void InitializeEarlyMorning(DayNightCycleComponent component)
{
component.CurrentCycleTime = EARLY_MORNING_TIME;
UpdateLightColor(component);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<DayNightCycleComponent, MapLightComponent>();
while (query.MoveNext(out var uid, out var dayNight, out var mapLight))
{
dayNight.CurrentCycleTime += frameTime / (dayNight.CycleDurationMinutes * 60f);
dayNight.CurrentCycleTime %= 1f; // Keep it between 0 and 1

UpdateLightColor(dayNight, mapLight, uid);
}
}

private void UpdateLightColor(DayNightCycleComponent dayNight, MapLightComponent? mapLight = null, EntityUid? uid = null)
{
var color = GetInterpolatedColor(dayNight);

if (mapLight != null && uid.HasValue)
{
mapLight.AmbientLightColor = color;
Dirty(uid.Value, mapLight);
Dirty(uid.Value, dayNight);
}
}

private Color GetInterpolatedColor(DayNightCycleComponent component)
{
var entries = component.TimeEntries;
var time = component.CurrentCycleTime;

for (int i = 0; i < entries.Count - 1; i++)
{
if (time >= entries[i].Time && time <= entries[i + 1].Time)
{
var t = (time - entries[i].Time) / (entries[i + 1].Time - entries[i].Time);
return InterpolateHexColors(entries[i].ColorHex, entries[i + 1].ColorHex, t);
}
}

// If we're here, we're between the last and first entry
var lastEntry = entries.Last();
var firstEntry = entries.First();
var wrappedT = (time - lastEntry.Time) / (1f + firstEntry.Time - lastEntry.Time);
return InterpolateHexColors(lastEntry.ColorHex, firstEntry.ColorHex, wrappedT);
}

private Color InterpolateHexColors(string hexColor1, string hexColor2, float t)
{
Color color1 = Color.FromHex(hexColor1);
Color color2 = Color.FromHex(hexColor2);

float r = color1.R + (color2.R - color1.R) * t;
float g = color1.G + (color2.G - color1.G) * t;
float b = color1.B + (color2.B - color1.B) * t;

return new Color(r, g, b);
}
}
}
9 changes: 8 additions & 1 deletion Resources/Locale/en-US/Nuclear14/job-names.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ job-description-ncr-officer = A local leader in the NCR military. Fulfil your mi
job-name-ncr-soldier = NCR Soldier
job-description-ncr-soldier = The backbone of any military. Soldiers get stuff done and follow an NCO on missions.
job-name-ranger-recruit = Ranger Recruit
job-description-ranger-recruit = You've just been accepted within the Desert Rangers. Prove yourself worthy by learning the ropes and helping the wasteland become a better place.
job-name-ranger-ranking = Ranger
job-description-ranger-ranking = As an Ranger, you are the vigilante the wasteland needs. Your mission is to keep the wasteland safe for the innocent and bring justice to the raider gangs, as well as continuing the tradition of stopping slavery in it's tracks.
job-name-ranger-veteran = Veteran Ranger
job-description-ranger-veteran = You answer to yourself, working either independently or with your team to complete your mission objectives however required, operating either alone, in a squad or with one of the other factions. Your primary mission is to improve the situation of the wasteland and to neutralize slavers and raiders operating in the area.
job-name-tribal = Tribesperson
job-description-tribal = Maintain your tribes way of life in the wasteland at all costs. Security, crafting, wellbeing, homelife, you do it all.
job-name-tribal-elder = Tribe Elder
Expand Down Expand Up @@ -65,7 +72,7 @@ job-name-wastelander = Wastelander
job-description-wastelander = Survive in the wasteland and carve out your own path. It's tough out there alone, consider finding others.
job-name-townsperson = Townsperson
job-description-townsperson = A member of the new world society. Follow the town rules or try run for Mayor to change them.
job-description-townsperson = A member of the new world society. Follow the town rules or try run for Mayor to change them.
job-name-towndoctor = Town Doctor
job-description-towndoctor = Sell your medical knowledge as a service. Treat the injured for money and manage a doctors practice in town.
job-name-townmechanic = Town Mechanic
Expand Down
5 changes: 4 additions & 1 deletion Resources/Locale/en-US/Nuclear14/job-supervisors.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ job-supervisors-caravan = the caravan leader
job-supervisors-caravan-leader = lead your caravan company to riches through trade
job-supervisors-ncr = the NCR officer
job-supervisors-ncr-nco = the NCR officer followed by the NCO
job-supervisors-ncr-captain = the NCR Captain
job-supervisors-ranger = the Ranger
job-supervisors-veteran-ranger = the Veteran Ranger
job-supervisors-tribal = the tribe elder
job-supervisors-tribal-elder = lead your tribe to health and prosperity
job-supervisors-overseer = the vaults overseer
job-supervisors-vault-overseer = lead your vault to prosperity and maintain the status quo
job-supervisors-wastelander = look after yourself above all else
job-supervisors-townsfolk = the town mayor
job-supervisors-townsfolk = the town mayor
Loading

0 comments on commit 8f9bb77

Please sign in to comment.