@@ -34,7 +34,7 @@ internal class VisibleInterior
3434 static readonly int w = 6 ;
3535 static readonly int h = 6 ;
3636 static readonly float [ ] xDispl = { 0.44f , 0.264f , 0.088f , - 0.088f , - 0.264f , - 0.44f } ;
37- static readonly float [ ] yDispl = { 1.59f , 1.35f , .97f , 0.59f , 0.28f , 0.05f } ;
37+ static readonly float [ ] yDispl = { 1.59f , 1.33f , .97f , 0.59f , 0.28f , 0.05f } ;
3838 GameObject [ , ] slots ;
3939 GameObject root ;
4040 public VisibleInterior ( Transform locker )
@@ -80,45 +80,52 @@ public void UseStorageRoot(Transform storageRoot)
8080 }
8181 static void CopyMeshes ( GameObject source , GameObject target )
8282 {
83- GameObject meshContainer = new GameObject ( "MeshContainer" ) ;
84- meshContainer . transform . SetParent ( target . transform , false ) ;
85- meshContainer . transform . localPosition = Vector3 . zero ;
86- meshContainer . transform . localRotation = Quaternion . identity ;
83+ GameObject copy = GameObject . Instantiate ( source ) ;
84+ copy . SetActive ( true ) ;
85+ copy . transform . SetParent ( target . transform , false ) ;
86+ copy . transform . localScale = Vector3 . one ;
87+ copy . transform . localRotation = Quaternion . identity ;
8788
88- Renderer [ ] componentList = source . GetComponentsInChildren < MeshRenderer > ( true ) ;
89-
90- if ( componentList . Length == 0 )
89+ Pickupable pickupable = copy . GetComponent < Pickupable > ( ) ;
90+ if ( pickupable != null )
9191 {
92- //fallback for fish
93- CopyModelByName ( source . transform , meshContainer ) ;
94- RescaleContainer ( meshContainer ) ;
95- return ;
92+ pickupable . DisableBehaviours ( ) ;
93+ pickupable . DisableColliders ( ) ;
94+ pickupable . DisableRigidbodies ( ) ;
95+ ApplyExceptions ( target , pickupable . GetTechType ( ) ) ;
9696 }
97-
98- foreach ( Renderer component in componentList )
97+ foreach ( Collider collider in copy . GetComponents < Collider > ( ) ) // previous thingy didn't work with stuff with two colliders
9998 {
100- if ( component . gameObject . name . Contains ( "_fp" ) )
101- {
102- continue ;
103- }
104- if ( Array . Exists ( blacklist , element => element == component . gameObject . name ) )
99+ if ( collider != null )
105100 {
106- continue ;
101+ collider . enabled = false ;
107102 }
108103
109- GameObject meshObject = UnityEngine . Object . Instantiate ( component . gameObject ) ;
110- meshObject . transform . SetParent ( meshContainer . transform , false ) ;
111104 }
112- RescaleContainer ( meshContainer ) ;
105+ SanitizeObject ( copy ) ;
106+ RescaleContainer ( copy ) ;
107+
108+ }
109+
110+ private static void ApplyExceptions ( GameObject target , TechType techType )
111+ {
112+ if ( techType == TechType . Salt )
113+ {
114+ target . transform . localPosition += - 0.03f * Vector3 . up ;
115+ }
113116 }
114- static bool CopyModelByName ( Transform source , GameObject meshContainer )
117+
118+ private static void SanitizeObject ( GameObject target )
115119 {
116- Transform meshObjectOriginal = source . Find ( "model" ) ;
117- if ( meshObjectOriginal == null ) return false ;
118- GameObject meshObject = UnityEngine . Object . Instantiate ( meshObjectOriginal . gameObject ) ;
119- meshObject . transform . SetParent ( meshContainer . transform , false ) ;
120- return true ;
120+ foreach ( Transform child in target . transform )
121+ {
122+ if ( child . name . StartsWith ( "x" ) )
123+ {
124+ child . gameObject . SetActive ( false ) ;
125+ }
126+ }
121127 }
128+
122129 static void RescaleContainer ( GameObject meshContainer )
123130 {
124131
@@ -148,7 +155,6 @@ static Bounds GetMaxBounds(GameObject g)
148155 }
149156 return b ;
150157 }
151- static readonly string [ ] blacklist = { "fire_extinguisher_handle_01_tp" , "x_flashlightC0one" } ;
152158 public static void EnsureDestructionOfPreviousInterior ( Transform locker )
153159 {
154160 Transform interior = locker . Find ( childName ) ;
0 commit comments