11#region
22
3+ using System ;
34using System . Collections . Generic ;
45using NebulaAPI ;
56using NebulaAPI . Packets ;
@@ -31,9 +32,22 @@ protected override void ProcessPacket(FoundationBlueprintPastePacket packet, Neb
3132 GameMain . gpuiManager . specifyPlanet = planet ;
3233
3334 // Split BuildTool_BlueprintPaste.DetermineReforms into following functions
34- SetReform ( factory , packet . ReformGridIds , packet . ReformType , packet . ReformColor ) ;
35- AlterHeightMap ( planet , packet . LevelChanges ) ;
36- RemoveVeges ( factory , packet . LevelChanges ) ;
35+ factory . platformSystem . EnsureReformData ( ) ;
36+ if ( packet . ReformData != null && packet . ReformData . Length > 0 )
37+ {
38+ SetReformByData ( factory , packet . ReformData ) ;
39+ }
40+ else if ( packet . ReformGridIds != null && packet . ReformGridIds . Length > 0 )
41+ {
42+ SetReformByGridIds ( factory , packet . ReformGridIds , packet . ReformType , packet . ReformColor ) ;
43+ }
44+ var levelChanges = new Dictionary < int , int > ( ) ;
45+ for ( int i = 0 ; i < packet . LevelChangesKeys . Length ; i ++ )
46+ {
47+ levelChanges . Add ( packet . LevelChangesKeys [ i ] , packet . LevelChangesValues [ i ] ) ;
48+ }
49+ AlterHeightMap ( planet , levelChanges ) ;
50+ RemoveVeges ( factory , levelChanges ) ;
3751 UpdateGeothermalStrength ( factory ) ;
3852 AlterVeinModels ( factory ) ;
3953
@@ -42,11 +56,17 @@ protected override void ProcessPacket(FoundationBlueprintPastePacket packet, Neb
4256 }
4357 }
4458
45- static void SetReform ( PlanetFactory factory , List < int > reformGridIds , int brushType , int brushColor )
59+ static void SetReformByData ( PlanetFactory factory , byte [ ] reformData )
4660 {
47- PlatformSystem platformSystem = factory . platformSystem ;
48- platformSystem . EnsureReformData ( ) ;
61+ // EBlueprintPasteResult.HasReform in DetermineReforms()
62+ var length = Math . Min ( reformData . Length , factory . platformSystem . reformData . Length ) ;
63+ Array . Copy ( reformData , factory . platformSystem . reformData , length ) ;
64+ }
4965
66+ static void SetReformByGridIds ( PlanetFactory factory , int [ ] reformGridIds , int brushType , int brushColor )
67+ {
68+ // EBlueprintPasteResult.BuildingNeedReform in DetermineReforms()
69+ var platformSystem = factory . platformSystem ;
5070 foreach ( int gridId in reformGridIds )
5171 {
5272 int reformIndex = platformSystem . GetReformIndex ( gridId >> 16 , gridId & 65535 ) ;
@@ -57,6 +77,7 @@ static void SetReform(PlanetFactory factory, List<int> reformGridIds, int brushT
5777 }
5878 }
5979 }
80+
6081 static void AlterHeightMap ( PlanetData planet , Dictionary < int , int > heightLevelChanges )
6182 {
6283 PlanetRawData planetRawData = planet . data ;
@@ -167,7 +188,7 @@ static void AlterVeinModels(PlanetFactory factory)
167188 physics . SetPlanetPhysicsColliderDirty ( ) ;
168189 if ( Mathf . Abs ( magnitude - veinSurfaceThreshold ) > 0.1f )
169190 {
170- Quaternion quaternion = Maths . SphericalRotation ( pos , Random . value * 360f ) ;
191+ Quaternion quaternion = Maths . SphericalRotation ( pos , UnityEngine . Random . value * 360f ) ;
171192 GameMain . gpuiManager . AlterModel ( veinPtr . modelIndex , veinPtr . modelId , veinId , pos , quaternion , false ) ;
172193 }
173194 else
0 commit comments