Dynamic demiplane weather + farming hotfix (#1131)

* dynamic demiplane weather

* add skeleton sprite

* hotfix farming

* Update wheat.yml
This commit is contained in:
Ed
2025-04-04 10:35:48 +03:00
committed by GitHub
parent e125605f25
commit b66ee390a6
28 changed files with 212 additions and 142 deletions

View File

@@ -48,7 +48,7 @@ public sealed class CP14WeatherRule : StationEventSystem<CP14WeatherRuleComponen
{
if (TryComp<CP14WeatherControllerComponent>(mapUid, out var controller))
{
controller.NextWeatherTime = _timing.CurTime + TimeSpan.FromSeconds(controller.ClearDuration.Max);
controller.NextWeatherTime = _timing.CurTime;
controller.Enabled = true;
}

View File

@@ -13,12 +13,6 @@ public sealed partial class CP14WeatherControllerComponent : Component
[DataField]
public bool Enabled = true;
/// <summary>
/// random time with no weather.
/// </summary>
[DataField]
public MinMax ClearDuration = new(120,1200);
[DataField]
public HashSet<CP14WeatherData> Entries = new();

View File

@@ -1,4 +1,7 @@
using System.Linq;
using Content.Server.Weather;
using Content.Shared._CP14.WeatherControl;
using Content.Shared.Weather;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -12,13 +15,6 @@ public sealed class CP14WeatherControllerSystem : EntitySystem
[Dependency] private readonly WeatherSystem _weather = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14WeatherControllerComponent, MapInitEvent>(OnMapInit);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
@@ -32,22 +28,52 @@ public sealed class CP14WeatherControllerSystem : EntitySystem
if (!weather.Enabled)
continue;
var weatherData = _random.Pick(weather.Entries);
var weatherData = PickWeatherDataByWeight(uid, weather.Entries);
if (!_proto.TryIndex(weatherData.Visuals, out var weatherVisualsIndexed))
continue;
var weatherDuration = TimeSpan.FromSeconds(weatherData.Duration.Next(_random));
_weather.SetWeather(Transform(uid).MapID, weatherVisualsIndexed, _timing.CurTime + weatherDuration);
var clearDuration = TimeSpan.FromSeconds(weather.ClearDuration.Next(_random));
weather.NextWeatherTime = _timing.CurTime + weatherDuration + clearDuration;
{
var weatherDuration = TimeSpan.FromSeconds(weatherData.Duration.Next(_random));
_weather.SetWeather(Transform(uid).MapID, null, null);
weather.NextWeatherTime = _timing.CurTime + weatherDuration;
}
else
{
var weatherDuration = TimeSpan.FromSeconds(weatherData.Duration.Next(_random));
_weather.SetWeather(Transform(uid).MapID, weatherVisualsIndexed, null);
weather.NextWeatherTime = _timing.CurTime + weatherDuration;
}
}
}
private void OnMapInit(Entity<CP14WeatherControllerComponent> ent, ref MapInitEvent args)
private CP14WeatherData PickWeatherDataByWeight(EntityUid map, HashSet<CP14WeatherData> entries)
{
ent.Comp.NextWeatherTime = _timing.CurTime + TimeSpan.FromSeconds(ent.Comp.ClearDuration.Next(_random));
var filteredEntries = new HashSet<CP14WeatherData>(entries);
if (TryComp<WeatherComponent>(map, out var currentWeather))
{
foreach (var (weatherProto, data) in currentWeather.Weather)
{
if (!_proto.TryIndex(weatherProto, out var weatherPrototype))
continue;
filteredEntries.RemoveWhere(entry => entry.Visuals == weatherPrototype);
}
}
var totalWeight = filteredEntries.Sum(entry => entry.Weight);
var randomWeight = _random.NextFloat() * totalWeight;
var currentWeight = 0f;
foreach (var entry in filteredEntries)
{
currentWeight += entry.Weight;
if (randomWeight < currentWeight)
{
return entry;
}
}
// Fallback in case of rounding errors
return filteredEntries.Last();
}
}

View File

@@ -141,7 +141,7 @@ public abstract partial class CP14SharedFarmingSystem
private void OnSeedInteract(Entity<CP14SeedComponent> seed, ref AfterInteractEvent args)
{
if (args.Handled)
if (args.Handled || !args.CanReach)
return;
if (!CanPlantSeed(seed, args.ClickLocation, args.User))
@@ -206,7 +206,7 @@ public abstract partial class CP14SharedFarmingSystem
if (_map.GetAnchoredEntities((map.Value, gridComp), position).ToList().Count > 0)
{
if (user is not null)
if (user is not null && _timing.IsFirstTimePredicted && _net.IsClient)
_popup.PopupEntity(Loc.GetString("cp14-farming-soil-occupied"), user.Value, user.Value);
return false;
}

View File

@@ -8,8 +8,11 @@ namespace Content.Shared._CP14.WeatherControl;
public sealed class CP14WeatherData
{
[DataField(required: true)]
public ProtoId<WeatherPrototype> Visuals { get; set; }
public ProtoId<WeatherPrototype>? Visuals { get; set; } = null;
[DataField]
public MinMax Duration { get; set; } = new(30, 300);
[DataField]
public float Weight { get; set; } = 1f;
}

View File

@@ -65,6 +65,8 @@ entities:
id: Comoss
- type: CP14WeatherController
entries:
- visuals: null
weight: 3
- visuals: CP14Mist
- visuals: CP14Rain
- type: LightCycle

View File

@@ -70,6 +70,8 @@ entities:
- 0
- type: CP14WeatherController
entries:
- visuals: null
weight: 2
- visuals: CP14Mist
- type: MapGrid
chunks:

View File

@@ -70,9 +70,10 @@ entities:
data: {}
- type: CP14WeatherController
entries:
- visuals: null
weight: 3
- visuals: CP14Mist
- visuals: CP14Rain
- visuals: CP14Storm
- type: Biome
forcedMarkerLayers: []
markerLayers: []

View File

@@ -246,6 +246,8 @@ entities:
layers: []
- type: CP14WeatherController
entries:
- visuals: null
weight: 2
- visuals: CP14Mist
- type: Fixtures
fixtures: {}

View File

@@ -12,7 +12,7 @@
key: floorTile
- type: TileEmission
range: 0.5
color: "#ff9c40"
color: "#ffc691"
- type: StepTrigger
requiredTriggeredSpeed: 0
intersectRatio: 0.1

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantCabbage
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: cabbage
description: You see a cabbage in front of you. Perhaps you were born in one.
components:
@@ -13,7 +13,6 @@
sprite: _CP14/Structures/Flora/Farm/cabbage.rsi
map: ["enum.PlantVisualLayers.Base"]
- type: CP14PlantGatherable
deleteAfterHarvest: true
loot:
All: CP14GatherCabbage

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantCucumber
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantMultiHarvestBase
name: cucumber
description: Don't trust people who know how to turn into pickles.
components:
@@ -13,7 +13,6 @@
sprite: _CP14/Structures/Flora/Farm/cucumber.rsi
map: ["enum.PlantVisualLayers.Base"]
- type: CP14PlantGatherable
deleteAfterHarvest: false
loot:
All: CP14GatherCucumber
@@ -21,5 +20,5 @@
id: CP14GatherCucumber
entries:
- id: CP14FoodCucumber
amount: 3
maxAmount: 5
amount: 1
maxAmount: 3

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantOnion
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: onion
description: He's so cute it brings tears to my eyes to cut him up.
components:
@@ -13,7 +13,6 @@
sprite: _CP14/Structures/Flora/Farm/onion.rsi
map: ["enum.PlantVisualLayers.Base"]
- type: CP14PlantGatherable
deleteAfterHarvest: false
loot:
All: CP14GatherOnion
@@ -21,5 +20,5 @@
id: CP14GatherOnion
entries:
- id: CP14FoodOnion
amount: 3
maxAmount: 5
amount: 1
maxAmount: 3

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantPepper
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: pepper
description: Russian roulette. Are you hot, or are you sweet peppers?
components:
@@ -15,7 +15,6 @@
- type: CP14PlantVisuals
growthSteps: 5
- type: CP14PlantGatherable
deleteAfterHarvest: false
loot:
All: CP14GatherPepper
@@ -23,5 +22,5 @@
id: CP14GatherPepper
entries:
- id: CP14FoodPepper
amount: 3
maxAmount: 5
amount: 2
maxAmount: 4

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantPotato
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: potato
description: Some like to associate themselves with potatoes. People like that are not bad people.
components:
@@ -15,7 +15,6 @@
- type: CP14PlantVisuals
growthSteps: 5
- type: CP14PlantGatherable
deleteAfterHarvest: true
loot:
All: CP14GatherPotato
@@ -23,5 +22,5 @@
id: CP14GatherPotato
entries:
- id: CP14FoodPotato
amount: 3
maxAmount: 5
amount: 2
maxAmount: 4

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantPumpkin
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: pumpkin
description: Legends say there is a pumpkin king who stares into your soul through the crowns of trees.
components:
@@ -13,7 +13,6 @@
sprite: _CP14/Structures/Flora/Farm/pumpkin.rsi
map: ["enum.PlantVisualLayers.Base"]
- type: CP14PlantGatherable
deleteAfterHarvest: true
loot:
All: CP14GatherPumpkin

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantSage
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: sage
description: Medicinal sage. Some love it for its medicinal properties, others for its narcotic properties. Which side are you on?
components:
@@ -15,7 +15,6 @@
- type: CP14PlantVisuals
growthSteps: 4
- type: CP14PlantGatherable
deleteAfterHarvest: true
loot:
All: CP14GatherSage
@@ -24,4 +23,4 @@
entries:
- id: CP14WildSage
amount: 1
maxAmount: 2
maxAmount: 3

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantTomatoes
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantMultiHarvestBase
name: tomatoes
description: On the one hand, it's a delicious fruit. But why eat it when it's much more fun to use tomatoes as a throwing projectile?
components:
@@ -21,5 +21,5 @@
id: CP14GatherTomatoes
entries:
- id: CP14FoodTomatoes
amount: 3
maxAmount: 5
amount: 1
maxAmount: 3

View File

@@ -1,6 +1,6 @@
- type: entity
id: CP14PlantWheat
parent: CP14GatherablePlantBoringBase
parent: CP14GatherablePlantSingleHarvestBase
name: wheat
description: Most popular crop. Unpretentious, it opens the way to an abundance of flour products.
components:
@@ -13,9 +13,8 @@
sprite: _CP14/Structures/Flora/Farm/wheat.rsi
map: ["enum.PlantVisualLayers.Base"]
- type: CP14PlantVisuals
growthSteps: 3
growthSteps: 5
- type: CP14PlantGatherable
deleteAfterHarvest: true
loot:
All: CP14GatherWheat
- type: CP14WaveShader
@@ -26,5 +25,5 @@
id: CP14GatherWheat
entries:
- id: CP14Wheat
amount: 3
maxAmount: 5
amount: 2
maxAmount: 4

View File

@@ -146,8 +146,8 @@
max: 3
- type: entity
id: CP14GatherablePlantBoringBase
parent:
id: CP14GatherablePlantSingleHarvestBase
parent:
- CP14BaseFlammableSpreading
- CP14GatherablePlantBase
abstract: true
@@ -170,4 +170,18 @@
- type: FireVisuals
sprite: _CP14/Effects/fire.rsi
normalState: full
alternateState: full2
alternateState: full2
- type: CP14PlantGatherable
deleteAfterHarvest: true
- type: entity
id: CP14GatherablePlantMultiHarvestBase
parent: CP14GatherablePlantSingleHarvestBase
abstract: true
components:
- type: CP14PlantGrowing
growthPerUpdate: 0.025
- type: CP14PlantFading
resourcePerMinute: 0.20
- type: CP14PlantGatherable
deleteAfterHarvest: false

View File

@@ -7,11 +7,18 @@
name: cp14-demiplane-location-cave-magma
tags:
- CP14DemiplaneOres
- CP14DemiplaneUnderground
#- CP14DemiplaneUnderground
- CP14DemiplaneOpenSky
- CP14DemiplaneHot
components:
- type: MapLight
ambientLightColor: "#BFEEFFFF"
- type: CP14CloudShadows
- type: Biome
template: CP14LavaOceanFill
- type: SunShadow
- type: SunShadowCycle
- type: Roof
- type: dungeonConfig
id: CP14DemiplaneCavesRing

View File

@@ -9,6 +9,8 @@
generationWeight: 1.5
categories:
Danger: 0.3
blacklistTags:
- CP14DemiplaneHot
layers:
- !type:OreDunGen
entity: CP14SpawnMobUndeadZombieRandom

View File

@@ -72,4 +72,47 @@
requiredTags:
- CP14DemiplaneOpenSky
components:
- type: LightCycle
- type: LightCycle
- type: cp14DemiplaneModifier
id: MapLightCycleCold
levels:
min: 1
max: 10
categories:
MapLight: 1
generationWeight: 2
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneCold
components:
- type: LightCycle
originalColor: "#7bc2e0"
- type: cp14DemiplaneModifier
id: MapLightCycleHot
levels:
min: 1
max: 10
categories:
MapLight: 1
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneHot
components:
- type: LightCycle
originalColor: "#ff8929"
- type: cp14DemiplaneModifier
id: MapLightCycleHot2
levels:
min: 1
max: 10
categories:
MapLight: 1
requiredTags:
- CP14DemiplaneOpenSky
- CP14DemiplaneHot
components:
- type: LightCycle
originalColor: "#d68787"

View File

@@ -5,19 +5,13 @@
Weather: 1
- type: cp14DemiplaneModifier
id: WeatherMist
id: WeatherInfinityMist
categories:
Weather: 1
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14Mist
duration:
min: 10000
max: 10000
- type: cp14DemiplaneModifier
id: WeatherRain
@@ -27,17 +21,18 @@
- CP14DemiplaneOpenSky
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: null
duration:
min: 30
max: 120
- visuals: CP14Rain
duration:
min: 10000
max: 10000
min: 180
max: 240
- type: cp14DemiplaneModifier
id: WeatherStorm
id: WeatherInfinityStorm
levels:
min: 3
max: 10
@@ -48,14 +43,8 @@
- CP14DemiplaneOpenSky
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14Storm
duration:
min: 10000
max: 10000
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner
@@ -64,7 +53,7 @@
maxGroupSize: 1
- type: cp14DemiplaneModifier
id: WeatherSnowLight
id: WeatherSnow
levels:
min: 1
max: 4
@@ -74,38 +63,15 @@
- CP14DemiplaneCold
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14SnowLight
duration:
min: 10000
max: 10000
- type: cp14DemiplaneModifier
id: WeatherSnowMedium
categories:
Weather: 1
name: cp14-modifier-snow-storm
requiredTags:
- CP14DemiplaneCold
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
min: 30
max: 180
- visuals: CP14SnowMedium
duration:
min: 10000
max: 10000
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner
count: 10
minGroupSize: 1
maxGroupSize: 1
min: 30
max: 180
- type: cp14DemiplaneModifier
id: WeatherSnowHeavy
@@ -119,14 +85,15 @@
- CP14DemiplaneCold
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14SnowHeavy
- visuals: CP14SnowHeavyWithStorm
duration:
min: 10000
max: 10000
min: 30
max: 180
- visuals: SnowfallHeavy
duration:
min: 30
max: 60
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner
@@ -144,14 +111,8 @@
Weather: 1
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14ManaMist
duration:
min: 10000
max: 10000
- visuals: CP14ManaMist
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner
@@ -169,14 +130,8 @@
Weather: 1
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14AntiManaMist
duration:
min: 10000
max: 10000
- visuals: CP14AntiManaMist
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner
@@ -185,7 +140,7 @@
maxGroupSize: 1
- type: cp14DemiplaneModifier
id: CP14FireStorm
id: CP14FireStormPeriod
name: cp14-modifier-fire-storm
levels:
min: 4
@@ -196,14 +151,15 @@
Weather: 1
components:
- type: CP14WeatherController
clearDuration:
min: 0
max: 0
entries:
- visuals: CP14FireStorm
- visuals: AshfallLight
duration:
min: 10000
max: 10000
min: 30
max: 180
- visuals: CP14FireStorm
duration:
min: 30
max: 60
layers:
- !type:OreDunGen
entity: CP14DemiplaneRuinsRoomSpawner

View File

@@ -66,7 +66,7 @@
- !type:HealthChange
damage:
types:
Blunt: 1
Blunt: -1
- !type:GenericStatusEffect
key: SeeingRainbows
component: SeeingRainbows

View File

@@ -143,6 +143,31 @@
# - !type:AdjustTemperature
# amount: -60000
- type: weather
id: CP14SnowHeavyWithStorm
sprite:
sprite: /Textures/_CP14/Effects/weather.rsi
state: snowfall_heavy
sound:
path: /Audio/Effects/Weather/snowstorm.ogg
params:
loop: true
volume: -6
config:
- maxEntities: 2
frequency: 10
canAffectOnWeatherBlocker: false
effects:
- !type:SpawnEntityOnTop
prob: 0.25
entity: CP14SkyLightning
#- effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -60000
- type: weather
id: CP14FireStorm
sprite:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 709 B

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -8,7 +8,8 @@
},
"states": [
{
"name": "full"
"name": "full",
"directions": 4
},
{
"name": "head",