Skip to content

Instantly share code, notes, and snippets.

@spajus
Created October 13, 2022 08:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spajus/7e5993a7bd5755f142f17a7d16785ea2 to your computer and use it in GitHub Desktop.
Save spajus/7e5993a7bd5755f142f17a7d16785ea2 to your computer and use it in GitHub Desktop.
Stardeus scenario example code
using System.Collections;
using Game.Audio;
using Game.Constants;
using Game.Data;
using Game.Procgen;
using Game.Story.Events;
using Game.Systems.Goals;
using Game.Utils;
using KL.Randomness;
using KL.Utils;
using UnityEngine;
namespace Game.Scenarios {
public sealed class WreckedEmptyShipScenario : BaseRandomShipScenario {
[RuntimeInitializeOnLoadMethod(
RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Load() {
Register(new WreckedEmptyShipScenario());
}
public override string TooltipKey => "game.scenario.tip";
public override Curve StartingSystemPopulationDensity =>
Tunable.FloatSet(TunableKey.WreckedEmptyShip_StartingSystemPopulationDensityCurve);
public override Curve StartingGalaxyPopulationDensity =>
Tunable.FloatSet(TunableKey.WreckedEmptyShip_StartingGalaxyPopulationDensityCurve);
protected override void BeforeGenerate() {
The.ScreenBlock.SetSideText(
T.StoryWrecked_Empty_ShipLoading_Side);
The.ScreenBlock.SetCenterText(
"story.wrecked_empty_ship.loading".T(S.GameName), 3f);
Sounds.PlayMusic(SoundtrackMood.Uplifting, true);
}
protected override void AfterGenerate() {
The.ScreenBlock.SetSideText("");
S.Sig.AddGoal.Send(GoalStartWreckedScenario.GoalId);
S.Story.StartEvent(new WreckedEmptyShipScenarioIntroStoryEvent());
}
public override string RichPresenceStatus => "Rebuilding a wrecked space ship";
protected override ShipFactory ConfigureShipFactory(Rng rng) {
var factory = new ShipFactory();
factory.AddStage(new BollingerShapeGenStage());
if (rng.Chance(0.25f)) {
factory.AddStage(new ConnectionGenStage());
}
factory.AddStage(new IslandCreationGenStage());
factory.AddStage(new IslandDetectionAndAttachmentGenStage());
factory.AddStage(new HoleFillerGenStage());
factory.AddStage(new EngineGenStage(DefIds.ObjectsDevicesThruster));
factory.AddStage(new AngleRoundingGenStage(rng.Range(0f, 1f)));
factory.AddStage(new OuterWallGenStage());
factory.AddStage(new InnerWallGenStage());
factory.AddStage(new WallGapFillGenStage());
factory.AddStage(new AreaDivisionGenStage());
factory.AddStage(new WallCompactGenStage());
factory.AddStage(new WallGapFillGenStage());
factory.AddStage(new AirlockGenStage());
factory.AddStage(new InnerDoorGenStage());
factory.AddStage(new MissingDoorGenStage());
factory.AddStage(new VentGenStage());
factory.AddStage(new FloorRandomizeGenStage());
factory.AddStage(new FloorWindowGenStage());
factory.AddStage(new WallWindowGenStage());
factory.AddStage(new FloorLightsGenStage());
factory.AddStage(new SelectSurvivorAreaGenStage(80, 200, 3));
//factory.AddStage(new ShipFireGenStage());
factory.AddStage(new DestroyShipGenStage());
factory.AddStage(new IslandFloatGenStage());
factory.AddStage(new MoveToCenterGenStage());
//factory.AddStage(new DebugPauseGenStage());
var survivors = Tunable.Int(TunableKey.WreckedEmptyShip_Survivors);
var foodPerSurvivor = Tunable.Int(TunableKey.WreckedEmptyShip_FoodPerSurvivor);
var fuel = Tunable.Int(TunableKey.WreckedEmptyShip_FuelInSurvivorArea);
factory.AddStage(new SurvivorAreaGenStage(
survivors, foodPerSurvivor, fuel, SpeciesType.Human));
//factory.AddStage(new DebugPauseGenStage());
var robots = Tunable.Int(TunableKey.WreckedEmptyShip_Robots);
var drones = Tunable.Int(TunableKey.WreckedEmptyShip_Drones);
var carriers = Tunable.Int(TunableKey.WreckedEmptyShip_Carriers);
factory.AddStage(new StartingAreaGenStage(robots, drones, carriers, true));
//factory.AddStage(new DebugPauseGenStage());
factory.AddStage(new StasisAreaGenStage(doSomeDamageToTheArea: true));
//factory.AddStage(new DebugPauseGenStage());
factory.AddStage(new ShuttleGenStage());
factory.AddStage(new ObjectsGenStage(
Tunable.StringSet(TunableKey.WreckedEmptyShip_Objects)));
factory.AddStage(new ObjectsInSpaceGenStage(
Tunable.StringSet(TunableKey.WreckedEmptyShip_ObjectsInSpace)));
factory.AddStage(new ObjectDamageGenStage());
factory.AddStage(new DeadWorkersGenStage());
factory.AddStage(new SlaughterSpotGenStage());
factory.AddStage(new DirtGenStage());
var resKeys = Tunable.StringSet(TunableKey.WreckedEmptyShip_StartingResourceTypes);
var resAmts = Tunable.IntSet(TunableKey.WreckedEmptyShip_StartingResourceAmounts);
var startingRes = Arrays.ToDict(resKeys, resAmts);
factory.AddStage(new StartingResourcesGenStage(startingRes));
factory.AddStage(new DebrisCleanupGenStage());
factory.AddStage(new DebrisShuffleGenStage());
factory.AddStage(new DebrisMergeGenStage());
factory.AddStage(new ObjGenStage(
Tunable.StringSet(TunableKey.WreckedEmptyShip_Objs)));
return factory;
}
public override string NameKey => "scenario.wrecked_empty_ship";
public override int Priority => int.MinValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment