WKLib 0.2.3
A modding library for White Knuckle
Loading...
Searching...
No Matches
SubRegionBuilder.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4
5namespace WKLib.API.Gamemodes;
6
11public class SubRegionBuilder
12{
13 private string _name = "New Subregion";
14 private List<M_Level.LevelAssetHolder> _levelAssets = [];
15
21 public SubRegionBuilder WithName(string subregionName)
22 {
23 _name = subregionName;
24 return this;
25 }
26
32 public SubRegionBuilder WithLevels(List<M_Level> levels)
33 {
34 _levelAssets = levels.Select((l) => M_Level.LevelAssetHolder.GetNewHolderFromLevel(l)).ToList();
35 return this;
36 }
37
42 public M_Subregion Build()
43 {
44 var subregion = ScriptableObject.CreateInstance<M_Subregion>();
45 subregion.subregionName = _name;
46 subregion.name = _name;
47 subregion.levelReferences = _levelAssets;
48 subregion.subregionHeight = _levelAssets.Sum(lv => lv.level.GetHeight());
49 subregion.sessionEventLists = _levelAssets.SelectMany(lv => lv.level.sessionEventLists).ToList();
50 return subregion;
51 }
52}
Builds an M_Subregion from a name plus a list of M_Level instances This builder simplifies the creat...
SubRegionBuilder WithName(string subregionName)
Sets the name for the subregion. This name will be used for both display and internal identification.
M_Subregion Build()
Constructs and returns a new M_Subregion instance based on the properties configured in this builder.
SubRegionBuilder WithLevels(List< M_Level > levels)
Sets the list of M_Level instances that comprise this subregion.