public static void StructureComponentAction(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info, StructureComponentDataBlock SCDB) { uLink.NetworkPlayer netPlayer = info.sender; PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == netPlayer); IStructureComponentItem item; NetCull.VerifyRPC(ref info); if (rep.Item<IStructureComponentItem>(out item) && (item.uses > 0)) { StructureComponent structureToPlacePrefab = SCDB.structureToPlacePrefab; Vector3 origin = stream.ReadVector3(); Vector3 direction = stream.ReadVector3(); Vector3 position = stream.ReadVector3(); Quaternion rotation = stream.ReadQuaternion(); uLink.NetworkViewID viewID = stream.ReadNetworkViewID(); StructureMaster component = null; if (nearZone(position) && !buildList.Contains(playerClient.userID.ToString())) { Rust.Notice.Popup(info.sender, "", "You can't place that near safe zones or war zones.", 4f); } else { if (viewID == uLink.NetworkViewID.unassigned) { if (SCDB.MasterFromRay(new Ray(origin, direction))) { return; } if (structureToPlacePrefab.type != StructureComponent.StructureComponentType.Foundation) { Debug.Log("ERROR, tried to place non foundation structure on terrain!"); } else { component = NetCull.InstantiateClassic<StructureMaster>(Bundling.Load<StructureMaster>("content/structures/StructureMasterPrefab"), position, rotation, 0); component.SetupCreator(item.controllable); } } else { component = uLink.NetworkView.Find(viewID).gameObject.GetComponent<StructureMaster>(); } if (component == null) { Debug.Log("NO master, something seriously wrong"); } else if (SCDB._structureToPlace.CheckLocation(component, position, rotation) && SCDB.CheckBlockers(position)) { StructureComponent comp = NetCull.InstantiateStatic(SCDB.structureToPlaceName, position, rotation).GetComponent<StructureComponent>(); if (comp != null) { component.AddStructureComponent(comp); int count = 1; if (item.Consume(ref count)) { item.inventory.RemoveItem(item.slot); } } } } } }