Skip to content

Commit ea7efff

Browse files
committed
Quick fix to enable building in the cyclops.
1 parent 0d25530 commit ea7efff

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

NitroxClient/GameLogic/Building.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void PlaceBasePiece(BaseGhost baseGhost, ConstructableBase constructableB
3838
}
3939

4040
NitroxId id = NitroxEntity.GetId(constructableBase.gameObject);
41+
4142
NitroxId parentBaseId = null;
4243

4344
if (baseGhost != null)
@@ -96,8 +97,13 @@ public void PlaceFurniture(GameObject gameObject, TechType techType, Vector3 ite
9697
}
9798
}
9899

100+
// Leverage local position when in a cyclops as items must be relative.
101+
bool inCyclops = (sub != null && sub.isCyclops);
102+
Vector3 position = (inCyclops) ? gameObject.transform.localPosition : itemPosition;
103+
Quaternion rotation = (inCyclops) ? gameObject.transform.localRotation : quaternion;
104+
99105
Transform camera = Camera.main.transform;
100-
BasePiece basePiece = new BasePiece(id, itemPosition.ToDto(), quaternion.ToDto(), camera.position.ToDto(), camera.rotation.ToDto(), techType.ToDto(), Optional.OfNullable(parentId), true, Optional.Empty);
106+
BasePiece basePiece = new BasePiece(id, position.ToDto(), rotation.ToDto(), camera.position.ToDto(), camera.rotation.ToDto(), techType.ToDto(), Optional.OfNullable(parentId), true, Optional.Empty);
101107
PlaceBasePiece placedBasePiece = new PlaceBasePiece(basePiece);
102108
packetSender.Send(placedBasePiece);
103109
}

NitroxClient/MonoBehaviours/Overrides/MultiplayerBuilder.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,17 @@ public static GameObject TryPlaceFurniture(SubRoot currentSub)
426426

427427
componentInParent3.SetIsInside(flag || flag2);
428428
SkyEnvironmentChanged.Send(gameObject, currentSub);
429-
gameObject.transform.position = overridePosition;
430-
gameObject.transform.rotation = overrideQuaternion;
429+
430+
if (currentSub != null && currentSub.isCyclops)
431+
{
432+
gameObject.transform.localPosition = overridePosition;
433+
gameObject.transform.localRotation = overrideQuaternion;
434+
}
435+
else
436+
{
437+
gameObject.transform.position = overridePosition;
438+
gameObject.transform.rotation = overrideQuaternion;
439+
}
431440

432441
MultiplayerBuilder.ghostModel = null;
433442
MultiplayerBuilder.prefab = null;

0 commit comments

Comments
 (0)