* god rays

* fix

* fix?
This commit is contained in:
Red
2025-09-27 22:14:11 +03:00
committed by GitHub
parent ec4a9a59cf
commit 51a3fb53aa
22 changed files with 358 additions and 60 deletions

View File

@@ -0,0 +1,40 @@
using Robust.Client.GameObjects;
using Robust.Shared.Map.Components;
namespace Content.Client._CP14.GodRays;
public sealed partial class CP14GodRaysSystem : EntitySystem
{
[Dependency] private readonly SpriteSystem _sprite = default!;
[Dependency] private readonly PointLightSystem _pointLight = default!;
private EntityQuery<MapLightComponent> _mapLightQuery;
public override void Initialize()
{
base.Initialize();
_mapLightQuery = GetEntityQuery<MapLightComponent>();
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var spriteSync = EntityQueryEnumerator<CP14SyncColorWithMapLightComponent>();
while (spriteSync.MoveNext(out var uid, out _))
{
if (!_mapLightQuery.TryComp(Transform(uid).MapUid, out var map))
continue;
//We calculate target color as map color, but transparency is based on map color brightness
var targetColor = Color.ToHsv(map.AmbientLightColor);
targetColor.W = targetColor.Z / 2;
var finalColor = Color.FromHsv(targetColor);
_sprite.SetColor(uid, finalColor);
_pointLight.SetColor(uid, finalColor);
}
}
}

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
namespace Content.Client._CP14.GodRays;
/// <summary>
/// Sync PointLight color and Sprite color with map light color
/// </summary>
[RegisterComponent]
public sealed partial class CP14SyncColorWithMapLightComponent : Component
{
}

View File

@@ -4,7 +4,10 @@ namespace Content.Server.Entry
public static class IgnoredComponents
{
public static string[] List => new[] {
"CP14WaveShader", // CP14 Wave shader
//CP14 start
"CP14SyncColorWithMapLight",
"CP14WaveShader",
//CP14 rnd
"ConstructionGhost",
"IconSmooth",
"InteractionOutline",

View File

@@ -82,6 +82,9 @@ public sealed class CP14SpawnProceduralLocationJob(
map.SetPaused(mapId, false);
//Add map components
entManager.AddComponents(MapUid, locationConfig.Components);
//Spawn modified config
await WaitAsyncTask(dungeon.GenerateDungeonAsync(dungeonConfig,
MapUid,
@@ -89,9 +92,6 @@ public sealed class CP14SpawnProceduralLocationJob(
position,
seed));
//Add map components
entManager.AddComponents(MapUid, locationConfig.Components);
return true;
}
}

View File

@@ -0,0 +1,55 @@
using Content.Shared.Light.Components;
using Content.Shared.Light.EntitySystems;
using Robust.Shared.Map.Components;
namespace Content.Server._CP14.Roof;
/// <inheritdoc/>
public sealed class CP14RoofSystem : EntitySystem
{
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly SharedRoofSystem _roof = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14SetGridRoovedComponent, ComponentStartup>(OnRoofStartup);
SubscribeLocalEvent<CP14SetGridUnroovedComponent, ComponentStartup>(OnRoofStartup);
SubscribeLocalEvent<CP14SetGridRoovedComponent, TileChangedEvent>(OnTileChanged);
}
private void OnTileChanged(Entity<CP14SetGridRoovedComponent> ent, ref TileChangedEvent args)
{
foreach (var changed in args.Changes)
{
if (changed.OldTile.IsEmpty)
_roof.SetRoof(ent.Owner, changed.GridIndices, true);
}
}
private void OnRoofStartup(Entity<CP14SetGridRoovedComponent> ent, ref ComponentStartup args)
{
if (!TryComp<MapGridComponent>(ent.Owner, out var gridComp))
return;
var enumerator = _maps.GetAllTilesEnumerator(ent, gridComp);
while (enumerator.MoveNext(out var tileRef))
{
_roof.SetRoof(ent.Owner, tileRef.Value.GridIndices, true);
}
}
private void OnRoofStartup(Entity<CP14SetGridUnroovedComponent> ent, ref ComponentStartup args)
{
if (!TryComp<MapGridComponent>(ent.Owner, out var gridComp))
return;
var enumerator = _maps.GetAllTilesEnumerator(ent, gridComp);
while (enumerator.MoveNext(out var tileRef))
{
_roof.SetRoof(ent.Owner, tileRef.Value.GridIndices, false);
}
}
}

View File

@@ -0,0 +1,17 @@
namespace Content.Server._CP14.Roof;
/// <summary>
/// When added, marks ALL tiles on grid as rooved
/// </summary>
[RegisterComponent]
public sealed partial class CP14SetGridRoovedComponent : Component
{
}
/// <summary>
/// When added, marks ALL tiles on grid as unrooved
/// </summary>
[RegisterComponent]
public sealed partial class CP14SetGridUnroovedComponent : Component
{
}

View File

@@ -8,5 +8,5 @@ public sealed partial class CCVars
/// Language used for the in-game localization.
/// </summary>
public static readonly CVarDef<string> Language =
CVarDef.Create("localization.language", "en-US", CVar.SERVER | CVar.REPLICATED);
CVarDef.Create("loc.server_language", "en-US", CVar.SERVER | CVar.REPLICATED);
}

View File

@@ -43,7 +43,7 @@ public sealed partial class CP14ProceduralModifierPrototype : IPrototype
/// Can this modifier be generated multiple times within a single location?
/// </summary>
[DataField]
public bool Unique = false;
public bool Unique = true;
/// <summary>
/// Generation layers that will be added to the location generation after the main layers.

View File

@@ -1,8 +1,8 @@
[whitelist]
enabled = true
[localization]
language = "en-US"
[loc]
server_language = "en-US"
[log]
path = "logs"

View File

@@ -0,0 +1,32 @@
- type: entity
id: CP14GodRays
categories: [ ForkFiltered ]
name: god rays
components:
- type: Sprite
sprite: _CP14/Effects/god_rays.rsi
drawdepth: Mobs
noRot: true
offset: -0.25, 1.5
layers:
- state: ray
shader: unshaded
- type: CP14SyncColorWithMapLight
- type: PointLight
enabled: true
energy: 1
radius: 5
netsync: true
- type: LightBehaviour
behaviours:
- !type:PulseBehaviour
interpolate: Cubic
maxDuration: 14
startValue: 0.5
endValue: 1.0
property: Energy
isLooped: true
enabled: true
- type: Tag
tags:
- HideContextMenu

View File

@@ -0,0 +1,37 @@
- type: entity
id: CP14RoofMarker
name: Roof enable Marker
categories: [ ForkFiltered ]
parent: MarkerBase
components:
- type: SetRoof
value: true
- type: Sprite
layers:
- state: green
shader: unshaded
- type: entity
id: CP14NoRoofMarker
name: Roof disable Marker
categories: [ ForkFiltered ]
parent: MarkerBase
components:
- type: SetRoof
value: false
- type: Sprite
layers:
- state: red
shader: unshaded
- type: entity
parent: CP14NoRoofMarker
id: CP14NoRoofMarkerGodRays
suffix: God Rays (5%)
components:
- type: RandomSpawner
prototypes:
- CP14GodRays
chance: 0.05
deleteSpawnerAfterSpawn: false

View File

@@ -5,7 +5,7 @@
sprite: _CP14/Interface/Misc/demiplane_locations.rsi
state: caves
levels:
min: 1
min: 0
max: 2
locationConfig: CP14Caves
tags:
@@ -14,6 +14,12 @@
components:
- type: Biome
template: CP14CavesIndestructibleFill
- type: Roof
- type: CP14SetGridRooved
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: dungeonConfig
id: CP14Caves

View File

@@ -15,6 +15,12 @@
components:
- type: Biome
template: CP14IceChasmFill
- type: Roof
- type: CP14SetGridRooved
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: dungeonConfig
id: CP14IceCaves

View File

@@ -15,6 +15,12 @@
components:
- type: Biome
template: CP14LavaOceanFill
- type: Roof
- type: CP14SetGridRooved
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: dungeonConfig
id: CP14MagmaCaves

View File

@@ -15,6 +15,12 @@
components:
- type: Biome
template: CP14ChasmFill
- type: Roof
- type: CP14SetGridRooved
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: dungeonConfig
id: CP14MushroomCaves

View File

@@ -17,6 +17,12 @@
components:
- type: Biome
template: CP14CavesIndestructibleFill
- type: Roof
- type: CP14SetGridRooved
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: dungeonConfig
id: CP14SwampGeode

View File

@@ -14,14 +14,14 @@
- CP14DemiplaneOpenSky
- CP14DemiplanePeacefulAnimals
components:
- type: Biome
template: CP14SandOceanFill
- type: Roof
- type: SunShadow
- type: SunShadowCycle
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: CP14CloudShadows
- type: Biome
template: CP14SandOceanFill
- type: SunShadow
- type: SunShadowCycle
- type: Roof
- type: dungeonConfig
id: CP14GrasslandIsland

View File

@@ -11,42 +11,6 @@
- type: MapLight
ambientLightColor: "#000000"
- type: cp14LocationModifier
id: MapLightDarkRed
levels:
min: 3
max: 10
categories:
MapLight: 1
name: cp14-modifier-night
components:
- type: MapLight
ambientLightColor: "#0f0104"
- type: cp14LocationModifier
id: MapLightDarkPurple
levels:
min: 1
max: 10
categories:
MapLight: 1
name: cp14-modifier-night
components:
- type: MapLight
ambientLightColor: "#09010f"
- type: cp14LocationModifier
id: MapLightDarkGreen
levels:
min: 1
max: 10
categories:
MapLight: 1
name: cp14-modifier-night
components:
- type: MapLight
ambientLightColor: "#000502"
- type: cp14LocationModifier
id: MapLightDarkNight
levels:
@@ -69,8 +33,6 @@
categories:
MapLight: 1
generationWeight: 2
requiredTags:
- CP14DemiplaneOpenSky
components:
- type: LightCycle
@@ -83,7 +45,6 @@
MapLight: 1
generationWeight: 2
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneCold
components:
- type: LightCycle
@@ -99,7 +60,6 @@
categories:
MapLight: 1
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneHot
components:
- type: LightCycle
@@ -115,7 +75,6 @@
categories:
MapLight: 1
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneHot
components:
- type: LightCycle
@@ -123,3 +82,19 @@
- type: MapLight
ambientLightColor: "#d68787"
- type: cp14LocationModifier
id: CavesRoofHoles
levels:
min: 0
max: 10
generationProb: 0.8
categories:
MapLight: 0
requiredTags:
- CP14DemiplaneUnderground
layers:
- !type:CP14OreDunGen
entity: CP14NoRoofMarkerGodRays
count: 15
minGroupSize: 10
maxGroupSize: 30

View File

@@ -14,6 +14,8 @@
max: 10
categories:
Weather: 1
requiredTags:
- CP14DemiplaneOpenSky
components:
- type: CP14WeatherController
entries:
@@ -26,8 +28,6 @@
max: 10
categories:
Weather: 1
requiredTags:
- CP14DemiplaneOpenSky
components:
- type: CP14WeatherController
entries:
@@ -48,8 +48,6 @@
name: cp14-modifier-storm
categories:
Weather: 1
requiredTags:
- CP14DemiplaneOpenSky
components:
- type: CP14WeatherController
entries:
@@ -124,6 +122,8 @@
- type: CP14WeatherController
entries:
- visuals: CP14ManaMist
requiredTags:
- CP14DemiplaneOpenSky
layers:
- !type:CP14RoomsDunGen
count: 8
@@ -142,6 +142,8 @@
- type: CP14WeatherController
entries:
- visuals: CP14AntiManaMist
requiredTags:
- CP14DemiplaneOpenSky
layers:
- !type:CP14RoomsDunGen
count: 8
@@ -156,6 +158,7 @@
max: 10
requiredTags:
- CP14DemiplaneHot
- CP14DemiplaneOpenSky
categories:
Weather: 1
components:

View File

@@ -20,5 +20,5 @@
id: CP14CarcatHues
strategy: !type:ClampedHsvColoration
hue: [0.05, 0.10]
saturation: [0.15, 0.35]
saturation: [0.15, 0.7]
value: [0.25, 0.95]

View File

@@ -0,0 +1,95 @@
{
"version": 1,
"size": {
"x": 58,
"y": 100
},
"license": "CC-BY-SA-3.0",
"copyright": "Created by TheShuEd",
"states": [
{
"name": "ray",
"delays": [
[
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
0.12,
5.12
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB