public void Prefabs() { ItemDataBlock[] all = DatablockDictionary.All; for (int i = 0; i < all.Length; i++) { ItemDataBlock itemDataBlock = all[i]; if (itemDataBlock is DeployableItemDataBlock) { DeployableItemDataBlock deployableItemDataBlock = itemDataBlock as DeployableItemDataBlock; File.AppendAllText(Util.GetAbsoluteFilePath("Prefabs.txt"), string.Concat(new string[] { "[\"", deployableItemDataBlock.ObjectToPlace.name, "\", \"", deployableItemDataBlock.DeployableObjectPrefabName, "\"],\n" })); } else if (itemDataBlock is StructureComponentDataBlock) { StructureComponentDataBlock structureComponentDataBlock = itemDataBlock as StructureComponentDataBlock; File.AppendAllText(Util.GetAbsoluteFilePath("Prefabs.txt"), string.Concat(new string[] { "[\"", structureComponentDataBlock.structureToPlacePrefab.name, "\", \"", structureComponentDataBlock.structureToPlaceName, "\"],\n" })); } } }
public static void DeployableItemDataBlock_DoAction1(DeployableItemDataBlock deploy, uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info) { object[] array = new object[] { deploy, stream, rep, info }; Method.Invoke("RustExtended.RustHook.DeployableItemDataBlock_DoAction1", array); info = (uLink.NetworkMessageInfo)array[3]; }
public void Prefabs() { foreach (ItemDataBlock block in DatablockDictionary.All) { if (block is DeployableItemDataBlock) { DeployableItemDataBlock block2 = block as DeployableItemDataBlock; File.AppendAllText(Util.GetAbsoluteFilePath("Prefabs.txt"), "[\"" + block2.ObjectToPlace.name + "\", \"" + block2.DeployableObjectPrefabName + "\"],\n"); } else if (block is StructureComponentDataBlock) { StructureComponentDataBlock block3 = block as StructureComponentDataBlock; File.AppendAllText(Util.GetAbsoluteFilePath("Prefabs.txt"), "[\"" + block3.structureToPlacePrefab.name + "\", \"" + block3.structureToPlaceName + "\"],\n"); } } }
public static void Prefabs() { if (File.Exists(FilePath)) { File.Delete(FilePath); } foreach (ItemDataBlock block in DatablockDictionary.All) { if (block is DeployableItemDataBlock) { DeployableItemDataBlock block2 = block as DeployableItemDataBlock; File.AppendAllText(FilePath, block2.ObjectToPlace.name + "=" + block2.DeployableObjectPrefabName + "\n"); } if (block is StructureComponentDataBlock) { StructureComponentDataBlock block3 = block as StructureComponentDataBlock; File.AppendAllText(FilePath, block3.structureToPlacePrefab.name + "=" + block3.structureToPlaceName + "\n"); } } }
public static void Prefabs() { if (File.Exists(World.FilePath)) { File.Delete(World.FilePath); } ItemDataBlock[] all = DatablockDictionary.All; for (int i = 0; i < all.Length; i++) { ItemDataBlock itemDataBlock = all[i]; if (itemDataBlock is DeployableItemDataBlock) { DeployableItemDataBlock deployableItemDataBlock = itemDataBlock as DeployableItemDataBlock; File.AppendAllText(World.FilePath, deployableItemDataBlock.ObjectToPlace.name + "=" + deployableItemDataBlock.DeployableObjectPrefabName + "\n"); } if (itemDataBlock is StructureComponentDataBlock) { StructureComponentDataBlock structureComponentDataBlock = itemDataBlock as StructureComponentDataBlock; File.AppendAllText(World.FilePath, structureComponentDataBlock.structureToPlacePrefab.name + "=" + structureComponentDataBlock.structureToPlaceName + "\n"); } } }
public static void DeployableItemAction(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info, DeployableItemDataBlock DIDB) { uLink.NetworkPlayer netPlayer = info.sender; PlayerClient playerClient = Array.Find(AllPlayerClients.ToArray(), (PlayerClient pc) => pc.netPlayer == netPlayer); IDeployableItem item; NetCull.VerifyRPC(ref info); if (rep.Item<IDeployableItem>(out item) && (item.uses > 0)) { Vector3 vector3; Quaternion quaternion; TransCarrier carrier; Vector3 origin = stream.ReadVector3(); Vector3 direction = stream.ReadVector3(); Ray ray = new Ray(origin, direction); if (!DIDB.CheckPlacement(ray, out vector3, out quaternion, out carrier)) { Rust.Notice.Popup(info.sender, "", "You can't place that here.", 4f); } else { if (nearZone(vector3) && !buildList.Contains(playerClient.userID.ToString())) { Rust.Notice.Popup(info.sender, "", "You can't place that near safe zones or war zones.", 4f); } else { DeployableObject component = NetCull.InstantiateStatic(DIDB.DeployableObjectPrefabName, vector3, quaternion).GetComponent<DeployableObject>(); // Creates model in world space if (component != null) { try { component.SetupCreator(item.controllable); // Sets object variables such as ownerID DIDB.SetupDeployableObject(stream, rep, ref info, component, carrier); } finally { int count = 1; if (item.Consume(ref count)) { item.inventory.RemoveItem(item.slot); } } } } } } }
public void CheckPlacementResults(Ray ray, out Vector3 pos, out Quaternion rot, out TransCarrier carrier, out DeployableItemDataBlock.DeployPlaceResults results) { results = new DeployableItemDataBlock.DeployPlaceResults(); RaycastHit raycastHit; Vector3 vector3; Vector3 vector31; bool flag; MeshBatchInstance meshBatchInstance; Ray ray1; float single; RaycastHit raycastHit1; bool flag1; MeshBatchInstance meshBatchInstance1; Quaternion quaternion; bool flag2; float single1 = this.placeRange; IDMain dMain = null; bool flag3 = false; bool flag4 = false; bool flag5 = false; DeployableObject deployableObject = null; bool flag6 = false; bool flag7 = false; bool flag8 = this.minCastRadius >= 1.401298E-45f; bool flag9 = (!flag8 ? Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, out raycastHit, single1, -472317957, out flag, out meshBatchInstance) : Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, this.minCastRadius, out raycastHit, single1, -472317957, out flag, out meshBatchInstance)); Vector3 point = ray.GetPoint(single1); if (!flag9) { Vector3 vector32 = point; vector32.y = vector32.y + 0.5f; flag6 = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector32, Vector3.down, out raycastHit, 5f, -472317957, out flag, out meshBatchInstance); } if (flag9 || flag6) { dMain = (!flag ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain); flag5 = (dMain is StructureComponent ? true : dMain is StructureMaster); vector3 = raycastHit.point; vector31 = raycastHit.normal; if (flag5) { flag2 = false; } else { DeployableObject deployableObject1 = dMain as DeployableObject; deployableObject = deployableObject1; flag2 = deployableObject1; } flag3 = flag2; if (this.carrierSphereCastMode == DeployableItemDataBlock.CarrierSphereCastMode.Allowed || !flag9 || !flag8 || DeployableItemDataBlock.NonVariantSphereCast(ray, vector3)) { carrier = ((!dMain ? raycastHit.collider.gameObject : dMain.gameObject)).GetComponent <TransCarrier>(); } else { if (this.carrierSphereCastMode != DeployableItemDataBlock.CarrierSphereCastMode.AdjustedRay) { single = single1 + this.minCastRadius; ray1 = ray; } else { Vector3 vector33 = ray.origin; Vector3 vector34 = raycastHit.point - vector33; single = vector34.magnitude + this.minCastRadius * 2f; ray1 = new Ray(vector33, vector34); Debug.DrawLine(ray.origin, ray.GetPoint(single), Color.cyan); } bool flag10 = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray1, out raycastHit1, single, -472317957, out flag1, out meshBatchInstance1); bool flag11 = flag10; if (!flag10) { Vector3 vector35 = vector3; vector35.y = vector35.y + 0.5f; flag11 = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector35, Vector3.down, out raycastHit1, 5f, -472317957, out flag1, out meshBatchInstance1); } if (!flag11) { carrier = null; } else { IDMain dMain1 = (!flag1 ? IDBase.GetMain(raycastHit1.collider) : meshBatchInstance1.idMain); carrier = (!dMain1 ? raycastHit1.collider.GetComponent <TransCarrier>() : dMain1.GetLocal <TransCarrier>()); } } flag4 = (raycastHit.collider is TerrainCollider ? true : raycastHit.collider.gameObject.layer == 10); flag7 = true; } else { vector3 = point; vector31 = Vector3.up; carrier = null; } bool flag12 = false; Hardpoint hardpointFromRay = null; if (this.hardpointType != Hardpoint.hardpoint_type.None) { hardpointFromRay = Hardpoint.GetHardpointFromRay(ray, this.hardpointType); if (hardpointFromRay) { flag12 = true; vector3 = hardpointFromRay.transform.position; vector31 = hardpointFromRay.transform.up; carrier = hardpointFromRay.GetMaster().GetTransCarrier(); flag7 = true; } } bool flag13 = false; if (this.spacingRadius > 0f) { Collider[] colliderArray = Physics.OverlapSphere(vector3, this.spacingRadius); int num = 0; while (num < (int)colliderArray.Length) { Collider collider = colliderArray[num]; GameObject gameObject = collider.gameObject; IDBase component = collider.gameObject.GetComponent <IDBase>(); if (component != null) { gameObject = component.idMain.gameObject; } if (!gameObject.CompareTag(this.ObjectToPlace.gameObject.tag) || Vector3.Distance(vector3, gameObject.transform.position) >= this.spacingRadius) { num++; } else { flag13 = true; break; } } } bool flag14 = false; if (flag3 && !this.forcePlaceable && deployableObject.cantPlaceOn) { flag14 = true; } pos = vector3; if (this.orientationMode == DeployableOrientationMode.Default) { if (!this.uprightOnly) { this.orientationMode = DeployableOrientationMode.NormalUp; } else { this.orientationMode = DeployableOrientationMode.Upright; } } switch (this.orientationMode) { case DeployableOrientationMode.NormalUp: { quaternion = TransformHelpers.LookRotationForcedUp(ray.direction, vector31); break; } case DeployableOrientationMode.Upright: { quaternion = TransformHelpers.LookRotationForcedUp(ray.direction, Vector3.up); break; } case DeployableOrientationMode.NormalForward: { Vector3 vector36 = Vector3.Cross(ray.direction, Vector3.up); quaternion = TransformHelpers.LookRotationForcedUp(vector36, vector31); break; } case DeployableOrientationMode.HardpointPosRot: { quaternion = (!flag12 ? TransformHelpers.LookRotationForcedUp(ray.direction, Vector3.up) : hardpointFromRay.transform.rotation); break; } default: { throw new NotImplementedException(); } } rot = quaternion * this.ObjectToPlace.transform.localRotation; bool flag15 = false; if (this.checkPlacementZones) { flag15 = NoPlacementZone.ValidPos(pos); } float single2 = Vector3.Angle(vector31, Vector3.up); results.falseFromDeployable = (this.CanStackOnDeployables || !flag3 ? flag14 : true); results.falseFromTerrian = (!this.TerrainOnly ? false : !flag4); results.falseFromClose = (this.spacingRadius <= 0f ? false : flag13); results.falseFromHardpoint = (!this.requireHardpoint ? false : !flag12); results.falseFromAngle = (this.requireHardpoint ? false : single2 >= this.ObjectToPlace.maxSlope); results.falseFromPlacementZone = (!this.checkPlacementZones ? false : !flag15); results.falseFromHittingNothing = !flag7; results.falseFromStructure = (!this.StructureOnly ? false : !flag5); results.falseFromFitRequirements = (this.fitRequirements == null ? false : !this.fitRequirements.Test(pos, (!this.fitTestForcedUp ? rot : TransformHelpers.LookRotationForcedUp(rot, Vector3.up)), this.ObjectToPlace.transform.localScale)); }