Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Simplifica o calculo de luminosidade/cor.
Browse files Browse the repository at this point in the history
  • Loading branch information
DoutorWhite committed Dec 15, 2023
1 parent 916462e commit b4d5624
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
6 changes: 0 additions & 6 deletions Content.Server/Time/DayCycleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,5 @@ public sealed partial class DayCycleComponent : Component
public double PeakLightLevel = 1.25;
[ViewVariables(VVAccess.ReadWrite), DataField("baseLightLevel")]
public double BaseLightLevel = 0.4;
[ViewVariables(VVAccess.ReadWrite), DataField("lightLevelLimit")]
public double LightLevelLimit = 1.15;
[ViewVariables(VVAccess.ReadWrite), DataField("exponentialConstant")]
public double ExponentialConstant = 2;
[ViewVariables(VVAccess.ReadWrite), DataField("lightAmplitude")]
public double LightAmplitude = 1;
}
}
39 changes: 19 additions & 20 deletions Content.Server/Time/DayCycleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;
using Content.Server.Chat.Systems;
using Content.Server.Light.EntitySystems;
using Content.Server.Station.Components;
using Content.Shared.CCVar;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.Map.Components;
Expand Down Expand Up @@ -124,45 +121,47 @@ private void ShiftChange(bool isNight)
public double CalculateDayLightLevel(DayCycleComponent comp)
{
var time = _timeSystem!.GetStationTime().TotalSeconds;
var wave_lenght = Math.Max(0, comp.CycleDuration * 24);
var wave_lenght = Math.Max(0, comp.CycleDuration) * 24;
var crest = Math.Max(1, comp.PeakLightLevel);
var shift = Math.Max(0, comp.BaseLightLevel);
var amplitude = Math.Max(0, comp.LightAmplitude);
var exponential = Math.Max(1, comp.ExponentialConstant);
return Math.Min(comp.LightLevelLimit, CalculateCurve(time, wave_lenght, crest, shift, amplitude, 2 * exponential));
var exponential = 6;
return CalculateCurve(time, wave_lenght, crest, shift, 2 * exponential);
}
public double CalculateColorLevel(DayCycleComponent comp, int color)
{
double crest = 6;
double shift = 0.725;
var exponent = 6;
var crest = 1.65;
var shift = 0.7;
var exponent = 4;
var time = _timeSystem!.GetStationTime().TotalSeconds;
var wave_lenght = Math.Max(0, comp.CycleDuration) * 24;
var phase = 0d;
switch (color)
{
/*case 1:
break;*/
case 1:
crest = 1.65;
shift = 0.7;
exponent = 4;
break;
case 2:
crest = 4;
exponent = 10;
crest = 1.9;
shift = 0.7;
exponent = 8;
break;
case 3:
crest = 12;
wave_lenght /= 2;
crest = 3.75;
shift = 0.685;
exponent = 2;
wave_lenght /= 2;
phase = wave_lenght / 2;
break;
}
return CalculateCurve(time, wave_lenght, crest, shift, 1, exponent, phase);
return CalculateCurve(time, wave_lenght, crest, shift, exponent, phase);
}

public static double CalculateCurve(double x, double wave_lenght, double crest, double shift, double amplitude, double exponent, double phase = 0)
public static double CalculateCurve(double x, double wave_lenght, double crest, double shift, double exponent, double phase = 0)
{
var sen = Math.Pow(Math.Sin((Math.PI * (phase + x)) / wave_lenght), exponent);
var function = amplitude * (Math.Pow(crest - shift + 1, sen) - 1) + shift;
return function;
return ((crest - shift) * sen) + shift;
}
}
}

0 comments on commit b4d5624

Please sign in to comment.