Silva Photosynthes returns + Carcat guidebook page (#1269)
* f * restore silva feature * carcat guidebook * day cycle
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.Farming.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
|
||||
@@ -5,6 +6,7 @@ namespace Content.Server._CP14.Farming;
|
||||
|
||||
public sealed partial class CP14FarmingSystem
|
||||
{
|
||||
[Dependency] private readonly CP14DayCycleSystem _dayCycle = default!;
|
||||
private void InitializeResources()
|
||||
{
|
||||
SubscribeLocalEvent<CP14PlantEnergyFromLightComponent, CP14PlantUpdateEvent>(OnTakeEnergyFromLight);
|
||||
@@ -16,7 +18,7 @@ public sealed partial class CP14FarmingSystem
|
||||
private void OnTakeEnergyFromLight(Entity<CP14PlantEnergyFromLightComponent> regeneration, ref CP14PlantUpdateEvent args)
|
||||
{
|
||||
var gainEnergy = false;
|
||||
var daylight = true;//_dayCycle.UnderSunlight(regeneration);
|
||||
var daylight = _dayCycle.UnderSunlight(regeneration);
|
||||
|
||||
if (regeneration.Comp.Daytime && daylight)
|
||||
gainEnergy = true;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using Content.Server._CP14.MagicEnergy.Components;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.MagicEnergy.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server._CP14.MagicEnergy;
|
||||
|
||||
public partial class CP14MagicEnergySystem
|
||||
{
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly CP14DayCycleSystem _dayCycle = default!;
|
||||
|
||||
private void InitializeDraw()
|
||||
{
|
||||
@@ -75,16 +76,7 @@ public partial class CP14MagicEnergySystem
|
||||
|
||||
draw.NextUpdateTime = _gameTiming.CurTime + TimeSpan.FromSeconds(draw.Delay);
|
||||
|
||||
var daylight = false;
|
||||
|
||||
//if (TryComp<MapLightComponent>(Transform(uid).MapUid, out var mapLight))
|
||||
//{
|
||||
// var color = mapLight.AmbientLightColor;
|
||||
// var medium = (color.R + color.G + color.B) / 3f;
|
||||
//
|
||||
// if (medium > draw.LightThreshold)
|
||||
// daylight = true;
|
||||
//}
|
||||
var daylight = _dayCycle.UnderSunlight(uid);
|
||||
|
||||
ChangeEnergy((uid, magicContainer), daylight ? draw.DaylightEnergy : draw.DarknessEnergy, out _, out _, true);
|
||||
}
|
||||
|
||||
11
Content.Shared/_CP14/DayCycle/CP14DayCycleComponent.cs
Normal file
11
Content.Shared/_CP14/DayCycle/CP14DayCycleComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CP14DayCycleComponent : Component
|
||||
{
|
||||
public double LastLightLevel = 0f;
|
||||
|
||||
[DataField]
|
||||
public double Threshold = 0.5f;
|
||||
}
|
||||
118
Content.Shared/_CP14/DayCycle/CP14DayCycleSystem.cs
Normal file
118
Content.Shared/_CP14/DayCycle/CP14DayCycleSystem.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Light.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Weather;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
|
||||
/// <summary>
|
||||
/// This is an add-on to the LightCycle system that helps you determine what time of day it is on the map
|
||||
/// </summary>
|
||||
public sealed class CP14DayCycleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly SharedGameTicker _ticker = default!;
|
||||
[Dependency] private readonly SharedMapSystem _maps = default!;
|
||||
[Dependency] private readonly SharedWeatherSystem _weather = default!;
|
||||
|
||||
private EntityQuery<MapGridComponent> _mapGridQuery;
|
||||
private EntityQuery<InsideEntityStorageComponent> _storageQuery;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_mapGridQuery = GetEntityQuery<MapGridComponent>();
|
||||
_storageQuery = GetEntityQuery<InsideEntityStorageComponent>();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<LightCycleComponent, CP14DayCycleComponent, MapComponent>();
|
||||
while (query.MoveNext(out var uid, out var lightCycle, out var dayCycle, out var map))
|
||||
{
|
||||
var oldLightLevel = dayCycle.LastLightLevel;
|
||||
var newLightLevel = GetLightLevel((uid, lightCycle));
|
||||
|
||||
dayCycle.LastLightLevel = newLightLevel;
|
||||
|
||||
// Going into darkness
|
||||
if (oldLightLevel < newLightLevel && oldLightLevel > dayCycle.Threshold && newLightLevel < dayCycle.Threshold)
|
||||
{
|
||||
var ev = new CP14StartNightEvent(map.MapId);
|
||||
RaiseLocalEvent(uid, ref ev, true);
|
||||
}
|
||||
|
||||
// Going into light
|
||||
if (oldLightLevel > newLightLevel && oldLightLevel < dayCycle.Threshold && newLightLevel > dayCycle.Threshold)
|
||||
{
|
||||
var ev = new CP14StartDayEvent(map.MapId);
|
||||
RaiseLocalEvent(uid, ref ev, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double GetLightLevel(Entity<LightCycleComponent?> map)
|
||||
{
|
||||
if (!Resolve(map.Owner, ref map.Comp, false))
|
||||
return 0;
|
||||
|
||||
var time = (float) _timing.CurTime
|
||||
.Add(map.Comp.Offset)
|
||||
.Subtract(_ticker.RoundStartTimeSpan)
|
||||
.Subtract(_metaData.GetPauseTime(map))
|
||||
.TotalSeconds;
|
||||
|
||||
var normalizedTime = time % map.Comp.Duration.TotalSeconds;
|
||||
var lightLevel = Math.Sin((normalizedTime / map.Comp.Duration.TotalSeconds) * MathF.PI);
|
||||
return lightLevel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the specified entity is on the map where it's daytime.
|
||||
/// </summary>
|
||||
/// <param name="target">An entity being tested to see if it is in daylight</param>
|
||||
public bool UnderSunlight(EntityUid target)
|
||||
{
|
||||
if (_storageQuery.HasComp(target))
|
||||
return false;
|
||||
|
||||
var xform = Transform(target);
|
||||
|
||||
if (xform.MapUid is null || xform.GridUid is null)
|
||||
return false;
|
||||
|
||||
var day = GetLightLevel(xform.MapUid.Value) > 0.5f;
|
||||
|
||||
var grid = xform.GridUid;
|
||||
if (grid is null)
|
||||
return day;
|
||||
|
||||
if (!_mapGridQuery.TryComp(grid, out var gridComp))
|
||||
return day;
|
||||
|
||||
if (!_weather.CanWeatherAffect(grid.Value, gridComp, _maps.GetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates)))
|
||||
return false;
|
||||
|
||||
return day;
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct CP14StartNightEvent(MapId Map)
|
||||
{
|
||||
public readonly MapId Map = Map;
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public record struct CP14StartDayEvent(MapId Map)
|
||||
{
|
||||
public readonly MapId Map = Map;
|
||||
}
|
||||
@@ -73,9 +73,9 @@
|
||||
spawned:
|
||||
- id: CP14FoodMeatHuman # Replace it with silva meat, heh.
|
||||
amount: 5
|
||||
#- type: CP14MagicEnergyPhotosynthesis # Silva special feature #Disabled until sunlight fixed
|
||||
#- type: CP14MagicEnergyDraw #Enabled default mana regen until sunlight fixed
|
||||
# enable: false
|
||||
- type: CP14MagicEnergyPhotosynthesis # Silva special feature #Disabled until sunlight fixed
|
||||
- type: CP14MagicEnergyDraw #Enabled default mana regen until sunlight fixed
|
||||
enable: false
|
||||
- type: Body
|
||||
prototype: CP14Silva
|
||||
requiredLegs: 2
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
- CP14_EN_Elf
|
||||
- CP14_EN_Tiefling
|
||||
- CP14_EN_Goblin
|
||||
- CP14_EN_Carcat
|
||||
filterEnabled: True
|
||||
|
||||
- type: guideEntry
|
||||
@@ -44,4 +45,11 @@
|
||||
id: CP14_EN_Goblin
|
||||
name: Goblin
|
||||
text: "/ServerInfo/_CP14/Guidebook_EN/SpeciesTabs/Goblin.xml"
|
||||
filterEnabled: True
|
||||
|
||||
- type: guideEntry
|
||||
crystallPunkAllowed: true
|
||||
id: CP14_EN_Carcat
|
||||
name: Carcat
|
||||
text: "/ServerInfo/_CP14/Guidebook_EN/SpeciesTabs/Carcat.xml"
|
||||
filterEnabled: True
|
||||
@@ -9,6 +9,7 @@
|
||||
- CP14_RU_Elf
|
||||
- CP14_RU_Tiefling
|
||||
- CP14_RU_Goblin
|
||||
- CP14_RU_Carcat
|
||||
filterEnabled: True
|
||||
|
||||
- type: guideEntry
|
||||
@@ -44,4 +45,11 @@
|
||||
id: CP14_RU_Goblin
|
||||
name: Гоблин
|
||||
text: "/ServerInfo/_CP14/Guidebook_RU/SpeciesTabs/Goblin.xml"
|
||||
filterEnabled: True
|
||||
|
||||
- type: guideEntry
|
||||
crystallPunkAllowed: true
|
||||
id: CP14_RU_Carcat
|
||||
name: Каркат
|
||||
text: "/ServerInfo/_CP14/Guidebook_RU/SpeciesTabs/Carcat.xml"
|
||||
filterEnabled: True
|
||||
@@ -0,0 +1,18 @@
|
||||
<Document>
|
||||
# Carcats
|
||||
|
||||
<Box>
|
||||
<GuideEntityEmbed Entity="CP14MobCarcat" Caption="Carcat"/>
|
||||
</Box>
|
||||
|
||||
TODO: Lorekeeper awaiting
|
||||
|
||||
## Night vision
|
||||
|
||||
As natural predators, darkness is no problem for the Carkat.
|
||||
|
||||
## Soft feet
|
||||
|
||||
The unusual shape of a Carkat's feet is both an advantage and a disadvantage. The soft pads make for a silent footstep. But the inability to wear shoes makes their paws vulnerable to sharp objects.
|
||||
|
||||
</Document>
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
The Silva are a race of humanoid plants living in deep relic forests. Emerging from the mother tree in the centre of their cities, the Silvas do not travel the world very often.
|
||||
|
||||
## Magical photosynthesis (TEMPORARILY DISABLED)
|
||||
## Magical photosynthesis
|
||||
|
||||
Silvas regenerate [protodata="CP14MobSilva" comp="CP14MagicEnergyPhotosynthesis" member="DaylightEnergy"/] mana while in sunlight, but without it, mana regeneration is completely absent.
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<Document>
|
||||
# Каркаты
|
||||
|
||||
<Box>
|
||||
<GuideEntityEmbed Entity="CP14MobCarcat" Caption="Каркат"/>
|
||||
</Box>
|
||||
|
||||
TODO: Ожидаем лор лороведов
|
||||
|
||||
## Ночное зрение
|
||||
|
||||
Будучи прирожденными хищниками, темнота для Каркатов - не помеха.
|
||||
|
||||
## Мягкая поступь
|
||||
|
||||
Необычная форма ног у Каркатов, одновременно является их преимуществом и недостатком. Мягкие подушечки обеспечивают абсолютно бесшумную поступь. Но невозможность носить обувь делает их лапы уязвимыми для острых предметов.
|
||||
|
||||
</Document>
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
Сильва - раса гуманоидных растений обитающих в глубоких реликтовых лесах. Появляясь в центре своих городов из материнского дерева, Сильвы не особо часто путешествуют по миру.
|
||||
|
||||
## Магический фотосинтез (ВРЕМЕННО ОТКЛЮЧЕНО)
|
||||
## Магический фотосинтез
|
||||
|
||||
Сильвы регенерируют [protodata="CP14MobSilva" comp="CP14MagicEnergyPhotosynthesis" member="DaylightEnergy"/] маны находясь под солнечным светом, но без него регенерация маны полностью отсутствует.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user