Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidewalk #121

Merged
merged 13 commits into from
Sep 3, 2023
1 change: 1 addition & 0 deletions GameRealisticMap.Arma3/Arma3LayerGeneratorCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Arma3LayerGeneratorCatalog(IProgressSystem progress, IArma3RegionAssets a
Generators.Add(new RailwayGenerator(progress, assets));
Generators.Add(new VineyardsGenerator(progress, assets));
Generators.Add(new OrchardGenerator(progress, assets));
Generators.Add(new SidewalksGenerator(progress, assets));

// Nature
Generators.Add(new ForestEdgeGenerator(progress, assets));
Expand Down
4 changes: 4 additions & 0 deletions GameRealisticMap.Arma3/Assets/Arma3Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ private IReadOnlyCollection<T> Lookup<K,T>(Dictionary<K, List<T>> dict, K typeId

IReadOnlyCollection<ModDependencyDefinition> IArma3RegionAssets.Dependencies => Dependencies;

public List<SidewalksDefinition> Sidewalks { get; set; } = new();

IReadOnlyCollection<SidewalksDefinition> IArma3RegionAssets.Sidewalks => Sidewalks;

public static JsonSerializerOptions CreateJsonSerializerOptions(IModelInfoLibrary library, bool allowUnresolvedModel = false)
{
return new JsonSerializerOptions()
Expand Down
7 changes: 6 additions & 1 deletion GameRealisticMap.Arma3/Assets/Arma3RoadTypeInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GameRealisticMap.Arma3.Assets
public class Arma3RoadTypeInfos : IRoadTypeInfos
{
[JsonConstructor]
public Arma3RoadTypeInfos(RoadTypeId id, Rgb24 satelliteColor, float textureWidth, string texture, string textureEnd, string material, float width, float clearWidth, bool? hasStreetLamp = null, float? distanceBetweenStreetLamps = null)
public Arma3RoadTypeInfos(RoadTypeId id, Rgb24 satelliteColor, float textureWidth, string texture, string textureEnd, string material, float width, float clearWidth, bool? hasStreetLamp = null, float? distanceBetweenStreetLamps = null, bool? hasSideWalks = null)
{
SatelliteColor = satelliteColor;
TextureWidth = textureWidth;
Expand All @@ -24,6 +24,7 @@ public Arma3RoadTypeInfos(RoadTypeId id, Rgb24 satelliteColor, float textureWidt
{
DistanceBetweenStreetLamps = distanceBetweenStreetLamps ?? (ClearWidth * 2.5f);
}
HasSideWalks = hasSideWalks ?? DefaultRoadTypeLibrary.Instance.GetInfo(id).HasSideWalks;
}

[JsonConverter(typeof(Rgb24Converter))]
Expand All @@ -47,8 +48,12 @@ public Arma3RoadTypeInfos(RoadTypeId id, Rgb24 satelliteColor, float textureWidt

public float? DistanceBetweenStreetLamps { get; }

public bool? HasSideWalks { get; }

bool IRoadTypeInfos.HasStreetLamp => HasStreetLamp ?? false;

float IRoadTypeInfos.DistanceBetweenStreetLamps => DistanceBetweenStreetLamps ?? (ClearWidth * 2.5f);

bool IRoadTypeInfos.HasSideWalks => HasSideWalks ?? false;
}
}
5 changes: 4 additions & 1 deletion GameRealisticMap.Arma3/Assets/BridgeDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GameRealisticMap.ManMade.Roads.Libraries;
using System.Text.Json.Serialization;
using GameRealisticMap.ManMade.Roads.Libraries;

namespace GameRealisticMap.Arma3.Assets
{
Expand All @@ -20,8 +21,10 @@ public BridgeDefinition(StraightSegmentDefinition single, StraightSegmentDefinit

public StraightSegmentDefinition End { get; }

[JsonIgnore]
public bool HasBridge => true;

[JsonIgnore]
public float MinimalBridgeLength => Single.Size / 3;
}
}
2 changes: 2 additions & 0 deletions GameRealisticMap.Arma3/Assets/IArma3RegionAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ public interface IArma3RegionAssets
RailwaysDefinition? Railways { get; }

IReadOnlyCollection<ModDependencyDefinition> Dependencies { get; }

IReadOnlyCollection<SidewalksDefinition> Sidewalks { get; }
}
}
47 changes: 47 additions & 0 deletions GameRealisticMap.Arma3/Assets/SidewalksDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using GameRealisticMap.Algorithms.Definitions;
using GameRealisticMap.Arma3.Assets.Fences;

namespace GameRealisticMap.Arma3.Assets
{
public class SidewalksDefinition : ISegmentsDefinition<Composition>
{
public SidewalksDefinition(double probability,
List<FenceStraightSegmentDefinition>? straights,
List<FenceCornerOrEndDefinition>? leftCorners = null,
List<FenceCornerOrEndDefinition>? rightCorners = null,
List<FenceCornerOrEndDefinition>? ends = null,
bool useAnySize = false,
string label = "")
{
Probability = probability;
Straights = straights ?? new List<FenceStraightSegmentDefinition>();
Label = label;
UseAnySize = useAnySize;
LeftCorners = leftCorners ?? new List<FenceCornerOrEndDefinition>();
RightCorners = rightCorners ?? new List<FenceCornerOrEndDefinition>();
Ends = ends ?? new List<FenceCornerOrEndDefinition>();
}

public double Probability { get; }

public List<FenceStraightSegmentDefinition> Straights { get; }

public List<FenceCornerOrEndDefinition> LeftCorners { get; }

public List<FenceCornerOrEndDefinition> RightCorners { get; }

public List<FenceCornerOrEndDefinition> Ends { get; }

public string Label { get; }

public bool UseAnySize { get; }

IReadOnlyCollection<ICornerOrEndSegmentDefinition<Composition>> ISegmentsDefinition<Composition>.LeftCorners => LeftCorners;

IReadOnlyCollection<ICornerOrEndSegmentDefinition<Composition>> ISegmentsDefinition<Composition>.RightCorners => RightCorners;

IReadOnlyCollection<ICornerOrEndSegmentDefinition<Composition>> ISegmentsDefinition<Composition>.Ends => Ends;

IReadOnlyCollection<IStraightSegmentProportionDefinition<Composition>> ISegmentsDefinition<Composition>.Straights => Straights;
}
}
51 changes: 42 additions & 9 deletions GameRealisticMap.Arma3/Builtin/CentralEurope.grma3a
Original file line number Diff line number Diff line change
Expand Up @@ -3367,7 +3367,8 @@
"Width": 10,
"ClearWidth": 15,
"HasStreetLamp": false,
"DistanceBetweenStreetLamps": null
"DistanceBetweenStreetLamps": null,
"HasSideWalks": false
},
{
"SatelliteColor": "4D4D4DFF",
Expand All @@ -3379,7 +3380,8 @@
"Width": 10,
"ClearWidth": 14,
"HasStreetLamp": true,
"DistanceBetweenStreetLamps": 40
"DistanceBetweenStreetLamps": 40,
"HasSideWalks": true
},
{
"SatelliteColor": "4D4D4DFF",
Expand All @@ -3391,7 +3393,8 @@
"Width": 7.5,
"ClearWidth": 11.5,
"HasStreetLamp": true,
"DistanceBetweenStreetLamps": 30
"DistanceBetweenStreetLamps": 30,
"HasSideWalks": true
},
{
"SatelliteColor": "625F5BFF",
Expand All @@ -3403,7 +3406,8 @@
"Width": 7,
"ClearWidth": 10,
"HasStreetLamp": true,
"DistanceBetweenStreetLamps": 30
"DistanceBetweenStreetLamps": 30,
"HasSideWalks": true
},
{
"SatelliteColor": "625F5BFF",
Expand All @@ -3415,7 +3419,8 @@
"Width": 4,
"ClearWidth": 6,
"HasStreetLamp": true,
"DistanceBetweenStreetLamps": 30
"DistanceBetweenStreetLamps": 30,
"HasSideWalks": false
},
{
"SatelliteColor": "534C43FF",
Expand All @@ -3427,7 +3432,8 @@
"Width": 3.5,
"ClearWidth": 5,
"HasStreetLamp": false,
"DistanceBetweenStreetLamps": null
"DistanceBetweenStreetLamps": null,
"HasSideWalks": false
},
{
"SatelliteColor": "534C43FF",
Expand All @@ -3439,7 +3445,8 @@
"Width": 3.5,
"ClearWidth": 6,
"HasStreetLamp": false,
"DistanceBetweenStreetLamps": null
"DistanceBetweenStreetLamps": null,
"HasSideWalks": false
},
{
"SatelliteColor": "625F5BFF",
Expand All @@ -3451,7 +3458,8 @@
"Width": 2,
"ClearWidth": 3,
"HasStreetLamp": false,
"DistanceBetweenStreetLamps": null
"DistanceBetweenStreetLamps": null,
"HasSideWalks": false
},
{
"SatelliteColor": "534C43FF",
Expand All @@ -3463,7 +3471,8 @@
"Width": 1.5,
"ClearWidth": 3.5,
"HasStreetLamp": false,
"DistanceBetweenStreetLamps": null
"DistanceBetweenStreetLamps": null,
"HasSideWalks": false
}
],
"Objects": {
Expand Down Expand Up @@ -4242,6 +4251,30 @@
},
"BaseWorldName": "arm_world_centraleurope",
"BaseDependency": "arm_centraleurope",
"Sidewalks": [
{
"Probability": 1,
"Straights": [
{
"Proportion": 1,
"Model": {
"Objects": [
{
"Model": "a3\\structures_f_enoch\\infrastructure\\Pavements\\ConcretePavement_01_wide_F.p3d",
"Transform": [0.015749479,-0.07911052,1.75]
}
]
},
"Size": 4
}
],
"LeftCorners": [],
"RightCorners": [],
"Ends": [],
"Label": "",
"UseAnySize": false
}
],
"Dependencies": [
{
"SteamId": "2982306133"
Expand Down
41 changes: 41 additions & 0 deletions GameRealisticMap.Arma3/ManMade/SidewalksGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using GameRealisticMap.Algorithms;
using GameRealisticMap.Algorithms.Following;
using GameRealisticMap.Arma3.Assets;
using GameRealisticMap.Arma3.TerrainBuilder;
using GameRealisticMap.ManMade.Roads;
using GameRealisticMap.Reporting;

namespace GameRealisticMap.Arma3.ManMade
{
internal class SidewalksGenerator : ITerrainBuilderLayerGenerator
{
private readonly IProgressSystem progress;
private readonly IArma3RegionAssets assets;

public SidewalksGenerator(IProgressSystem progress, IArma3RegionAssets assets)
{
this.progress = progress;
this.assets = assets;
}

public IEnumerable<TerrainBuilderObject> Generate(IArma3MapConfig config, IContext context)
{
var layer = new List<PlacedModel<Composition>>();

if (assets.Sidewalks.Count != 0)
{
var paths = context.GetData<SidewalksData>().Paths;
foreach (var path in paths.ProgressStep(progress, "Sidewalks"))
{
if (path.Points.Count > 1)
{
var random = RandomHelper.CreateRandom(path.FirstPoint);
var def = assets.Sidewalks.GetRandom(random);
FollowPathWithObjects.PlaceOnPathRightAngle(random, def, layer, path.Points);
}
}
}
return layer.SelectMany(o => o.Model.ToTerrainBuilderObjects(o));
}
}
}
36 changes: 36 additions & 0 deletions GameRealisticMap.Studio/Labels.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions GameRealisticMap.Studio/Labels.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,16 @@ Dernière génération le {1}</value>
<data name="AbsoluteElevation" xml:space="preserve">
<value>Position absolue</value>
</data>
<data name="InResidentialAreas" xml:space="preserve">
<value>Dans les zones résidentielles</value>
</data>
<data name="Sidewalks" xml:space="preserve">
<value>Trottoirs</value>
</data>
<data name="Never" xml:space="preserve">
<value>Jamais</value>
</data>
<data name="AssetSidewalks" xml:space="preserve">
<value>Trottoirs</value>
</data>
</root>
12 changes: 12 additions & 0 deletions GameRealisticMap.Studio/Labels.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,16 @@ Last generated on {1}</value>
<data name="NumObjectsToImport" xml:space="preserve">
<value>{0} objects to import</value>
</data>
<data name="Sidewalks" xml:space="preserve">
<value>Sidewalks</value>
</data>
<data name="InResidentialAreas" xml:space="preserve">
<value>In residential areas</value>
</data>
<data name="Never" xml:space="preserve">
<value>Never</value>
</data>
<data name="AssetSidewalks" xml:space="preserve">
<value>Sidewalks</value>
</data>
</root>
Loading
Loading