private static Boolean isValidPlacement() { bool water = component.m_waterPiece || component.m_noInWater; PlayerInstance.m_placementStatus = 0; if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly) { PlayerInstance.m_placementMarkerInstance.SetActive(false); } StationExtension component2 = component.GetComponent <StationExtension>(); if (component2 != null) { CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position); if (craftingStation) { component2.StartConnectionEffect(craftingStation); } else { component2.StopConnectionEffect(); PlayerInstance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; // Missing Station } if (component2.OtherExtensionInRange(component.m_spaceRequirement)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.MoreSpace; // More Space } } if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NoTeleportArea; } if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NotInDungeon; } if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NoBuildZone; } float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f; if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, radius, true)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.PrivateZone; } if (PlayerInstance.m_placementStatus != 0) { component.SetInvalidPlacementHeightlight(true); } else { component.SetInvalidPlacementHeightlight(false); } return(true); }
// Token: 0x06000680 RID: 1664 RVA: 0x00036680 File Offset: 0x00034880 private List <StationExtension> GetExtensions() { if (this.m_updateExtensionTimer > 2f) { this.m_updateExtensionTimer = 0f; this.m_attachedExtensions.Clear(); StationExtension.FindExtensions(this, base.transform.position, this.m_attachedExtensions); } return(this.m_attachedExtensions); }
// Token: 0x06000F59 RID: 3929 RVA: 0x0006D4D8 File Offset: 0x0006B6D8 private static bool ExtensionInList(List <StationExtension> extensions, StationExtension extension) { using (List <StationExtension> .Enumerator enumerator = extensions.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.GetExtensionName() == extension.GetExtensionName()) { return(true); } } } return(false); }
public static void StationExtensionAwake_Patch(StationExtension __instance) { string extensionName = __instance.GetComponent <Piece>().m_name; StationExtension netExtension = __instance.GetComponent <ZNetView>().GetComponent <StationExtension>(); if (!customExtensionRange.Value) { return; } foreach (var itemRange in customExtRanges) { if (extensionName == itemRange.Key && netExtension.m_maxStationDistance != itemRange.Value) { netExtension.m_maxStationDistance = itemRange.Value; } } }
private static Boolean Prefix(Player __instance, bool flashGuardStone) { Player PlayerInstance = __instance; if (PlayerInstance == null) { return(true); } if (!Settings.isEnabled("AdvancedBuildingMode") || !__instance.InPlaceMode()) { return(true); } KeyCode enter = Settings.getHotkey("enterAdvancedBuildingMode"); KeyCode exit = Settings.getHotkey("exitAdvancedBuildingMode"); // Error Handling/Detection for Hoe & Terrain Tool if (PlayerInstance.m_buildPieces != null) { GameObject selectedPrefab = PlayerInstance.m_buildPieces.GetSelectedPrefab(); if (selectedPrefab == null || IsHoeOrTerrainTool(selectedPrefab)) { return(true); } } // Prevent cross usage of ABM & ABE if (AdvancedEditingMode.isInAEM) { return(true); } // Delayed function stop to place the object at the right location (if we would immediatly stop, it would be placed at cursor location) if (DelayedStop) { isInABM = false; DelayedStop = false; BlockRefresh = false; return(true); } // Error Handling and removal of left over placement marker if (!PlayerInstance.InPlaceMode() || PlayerInstance.m_placementGhost == null || PlayerInstance.m_buildPieces == null) { DelayedStop = false; BlockRefresh = false; if (PlayerInstance.m_placementMarkerInstance != null) { PlayerInstance.m_placementMarkerInstance.SetActive(false); } return(true); } float rX = 0; float rZ = 0; float rY = 0; if (Input.GetKeyDown(enter)) { isInABM = true; DelayedStop = false; BlockRefresh = true; } if (Input.GetKeyDown(exit)) { DelayedStop = true; PlayerInstance.m_placeRotation = 0; } float distance = 2; float scrollDistance = 2; // TODO ADD INCREASE / DECREASE HOTKEYS // TODO ADD HOTKEY TO SAVE / LOAD ROTATION // CONTROL PRESSED if (Input.GetKeyDown(KeyCode.LeftControl)) { controlFlag = true; } if (Input.GetKeyUp(KeyCode.LeftControl)) { controlFlag = false; } // Detect hotkey presses for hotbar to reduce potential issues if (Input.GetKeyDown(KeyCode.Alpha1)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha2)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha3)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha4)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha5)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha6)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha7)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha8)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha9)) { DelayedStop = true; } if (Input.GetKeyDown(KeyCode.Alpha0)) { DelayedStop = true; } // SHIFT PRESSED if (Input.GetKeyDown(KeyCode.LeftShift)) { shiftFlag = true; } if (Input.GetKeyUp(KeyCode.LeftShift)) { shiftFlag = false; } if (shiftFlag) { distance = 2 * 3; scrollDistance = 2 * 3; } else { distance = 2; scrollDistance = 2; } // LEFT ALT PRESSED if (Input.GetKeyDown(KeyCode.LeftAlt)) { altFlag = true; } if (Input.GetKeyUp(KeyCode.LeftAlt)) { altFlag = false; } Piece component = PlayerInstance.m_placementGhost.GetComponent <Piece>(); // Maximum distance between player and placed piece if (Vector3.Distance(__instance.transform.position, component.transform.position) > 25) { DelayedStop = true; } if (Input.GetAxis("Mouse ScrollWheel") > 0f) { Quaternion rotation; if (controlFlag) { rX++; rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards } else { if (altFlag) { rZ++; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal } else { rY++; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right } } component.transform.rotation = rotation; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { Quaternion rotation; if (controlFlag) { rX--; rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards } else { if (altFlag) { rZ--; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal } else { rY--; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right } } component.transform.rotation = rotation; } if (Input.GetKeyDown(KeyCode.UpArrow)) { if (controlFlag) { component.transform.Translate(Vector3.up * distance * Time.deltaTime); } else { component.transform.Translate(Vector3.forward * distance * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.DownArrow)) { if (controlFlag) { component.transform.Translate(Vector3.down * distance * Time.deltaTime); } else { component.transform.Translate(Vector3.back * distance * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.LeftArrow)) { component.transform.Translate(Vector3.left * distance * Time.deltaTime); } if (Input.GetKeyDown(KeyCode.RightArrow)) { component.transform.Translate(Vector3.right * distance * Time.deltaTime); } bool water = component.m_waterPiece || component.m_noInWater; PlayerInstance.m_placementStatus = 0; if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly) { PlayerInstance.m_placementMarkerInstance.SetActive(false); } StationExtension component2 = component.GetComponent <StationExtension>(); if (component2 != null) { CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position); if (craftingStation) { component2.StartConnectionEffect(craftingStation); } else { component2.StopConnectionEffect(); PlayerInstance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; // Missing Station } if (component2.OtherExtensionInRange(component.m_spaceRequirement)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.MoreSpace; // More Space } } if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NoTeleportArea; } if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NotInDungeon; } if (Location.IsInsideNoBuildLocation(PlayerInstance.m_placementGhost.transform.position)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.NoBuildZone; } float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f; if (!PrivateArea.CheckAccess(PlayerInstance.m_placementGhost.transform.position, radius, flashGuardStone)) { PlayerInstance.m_placementStatus = Player.PlacementStatus.PrivateZone; } if (PlayerInstance.m_placementStatus != 0) { component.SetInvalidPlacementHeightlight(true); } else { component.SetInvalidPlacementHeightlight(false); } if (Input.GetKeyDown(KeyCode.Mouse0)) { // Stop with the next iteration of the function and place the piece DelayedStop = true; } return(!BlockRefresh); }
// almost copy of original UpdatePlacementGhost with modified calculation of Quaternion quaternion = Quaternion.Euler(rotation); // need to be re-calculated in Postfix for correct work of auto-attachment of placementGhost after change rotation private static void UpdatePlacementGhost(Player __instance, bool flashGuardStone) { if ((UnityEngine.Object)__instance.m_placementGhost == (UnityEngine.Object)null) { if (!(bool)(UnityEngine.Object)__instance.m_placementMarkerInstance) { return; } __instance.m_placementMarkerInstance.SetActive(false); } else { bool flag = ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltPlace"); Piece component1 = __instance.m_placementGhost.GetComponent <Piece>(); bool water = component1.m_waterPiece || component1.m_noInWater; Vector3 point; Vector3 normal; Piece piece; Heightmap heightmap; Collider waterSurface; if (__instance.PieceRayTest(out point, out normal, out piece, out heightmap, out waterSurface, water)) { __instance.m_placementStatus = Player.PlacementStatus.Valid; if ((UnityEngine.Object)__instance.m_placementMarkerInstance == (UnityEngine.Object)null) { __instance.m_placementMarkerInstance = UnityEngine.Object.Instantiate <GameObject>(__instance.m_placeMarker, point, Quaternion.identity); } __instance.m_placementMarkerInstance.SetActive(true); __instance.m_placementMarkerInstance.transform.position = point; __instance.m_placementMarkerInstance.transform.rotation = Quaternion.LookRotation(normal); if (component1.m_groundOnly || component1.m_groundPiece || component1.m_cultivatedGroundOnly) { __instance.m_placementMarkerInstance.SetActive(false); } WearNTear wearNtear = (UnityEngine.Object)piece != (UnityEngine.Object)null ? piece.GetComponent <WearNTear>() : (WearNTear)null; StationExtension component2 = component1.GetComponent <StationExtension>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { CraftingStation closestStationInRange = component2.FindClosestStationInRange(point); if ((bool)(UnityEngine.Object)closestStationInRange) { component2.StartConnectionEffect(closestStationInRange); } else { component2.StopConnectionEffect(); __instance.m_placementStatus = Player.PlacementStatus.ExtensionMissingStation; } if (component2.OtherExtensionInRange(component1.m_spaceRequirement)) { __instance.m_placementStatus = Player.PlacementStatus.MoreSpace; } } if ((bool)(UnityEngine.Object)wearNtear && !wearNtear.m_supports) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_waterPiece && (UnityEngine.Object)waterSurface == (UnityEngine.Object)null && !flag) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_noInWater && (UnityEngine.Object)waterSurface != (UnityEngine.Object)null) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_groundPiece && (UnityEngine.Object)heightmap == (UnityEngine.Object)null) { __instance.m_placementGhost.SetActive(false); __instance.m_placementStatus = Player.PlacementStatus.Invalid; return; } if (component1.m_groundOnly && (UnityEngine.Object)heightmap == (UnityEngine.Object)null) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_cultivatedGroundOnly && ((UnityEngine.Object)heightmap == (UnityEngine.Object)null || !heightmap.IsCultivated(point))) { __instance.m_placementStatus = Player.PlacementStatus.NeedCultivated; } if (component1.m_notOnWood && (bool)(UnityEngine.Object)piece && (bool)(UnityEngine.Object)wearNtear && (wearNtear.m_materialType == WearNTear.MaterialType.Wood || wearNtear.m_materialType == WearNTear.MaterialType.HardWood)) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_notOnTiltingSurface && (double)normal.y < 0.800000011920929) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_inCeilingOnly && (double)normal.y > -0.5) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_notOnFloor && (double)normal.y > 0.100000001490116) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } if (component1.m_onlyInTeleportArea && !(bool)(UnityEngine.Object)EffectArea.IsPointInsideArea(point, EffectArea.Type.Teleport, 0.0f)) { __instance.m_placementStatus = Player.PlacementStatus.NoTeleportArea; } if (!component1.m_allowedInDungeons && __instance.InInterior()) { __instance.m_placementStatus = Player.PlacementStatus.NotInDungeon; } if ((bool)(UnityEngine.Object)heightmap) { normal = Vector3.up; } __instance.m_placementGhost.SetActive(true); var rotation = PlayersData.ContainsKey(__instance) ? PlayersData[__instance].PlaceRotation : __instance.m_placeRotation * 22.5f * Vector3.up; Quaternion quaternion = Quaternion.Euler(rotation); if ((component1.m_groundPiece || component1.m_clipGround) && (bool)(UnityEngine.Object)heightmap || component1.m_clipEverything) { if ((bool)(UnityEngine.Object)__instance.m_buildPieces.GetSelectedPrefab() .GetComponent <TerrainModifier>() && component1.m_allowAltGroundPlacement && (component1.m_groundPiece && !ZInput.GetButton("AltPlace")) && !ZInput.GetButton("JoyAltPlace")) { float groundHeight = ZoneSystem.instance.GetGroundHeight(__instance.transform.position); point.y = groundHeight; } __instance.m_placementGhost.transform.position = point; __instance.m_placementGhost.transform.rotation = quaternion; } else { Collider[] componentsInChildren = __instance.m_placementGhost.GetComponentsInChildren <Collider>(); if (componentsInChildren.Length != 0) { __instance.m_placementGhost.transform.position = point + normal * 50f; __instance.m_placementGhost.transform.rotation = quaternion; Vector3 vector3_1 = Vector3.zero; float num1 = 999999f; foreach (Collider collider in componentsInChildren) { if (!collider.isTrigger && collider.enabled) { MeshCollider meshCollider = collider as MeshCollider; if (!((UnityEngine.Object)meshCollider != (UnityEngine.Object)null) || meshCollider.convex) { Vector3 a = collider.ClosestPoint(point); float num2 = Vector3.Distance(a, point); if ((double)num2 < (double)num1) { vector3_1 = a; num1 = num2; } } } } Vector3 vector3_2 = __instance.m_placementGhost.transform.position - vector3_1; if (component1.m_waterPiece) { vector3_2.y = 3f; } __instance.m_placementGhost.transform.position = point + vector3_2; __instance.m_placementGhost.transform.rotation = quaternion; } } if (!flag) { __instance.m_tempPieces.Clear(); Transform a; Transform b; if (__instance.FindClosestSnapPoints(__instance.m_placementGhost.transform, 0.5f, out a, out b, __instance.m_tempPieces)) { Vector3 position = b.parent.position; Vector3 p = b.position - (a.position - __instance.m_placementGhost.transform.position); if (!__instance.IsOverlapingOtherPiece(p, __instance.m_placementGhost.transform.rotation, __instance.m_placementGhost.name, __instance.m_tempPieces, component1.m_allowRotatedOverlap)) { __instance.m_placementGhost.transform.position = p; } } } if (Location.IsInsideNoBuildLocation(__instance.m_placementGhost.transform.position)) { __instance.m_placementStatus = Player.PlacementStatus.NoBuildZone; } if (!PrivateArea.CheckAccess(__instance.m_placementGhost.transform.position, (bool)(UnityEngine.Object)component1.GetComponent <PrivateArea>() ? component1.GetComponent <PrivateArea>().m_radius : 0.0f, flashGuardStone)) { __instance.m_placementStatus = Player.PlacementStatus.PrivateZone; } if (__instance.CheckPlacementGhostVSPlayers()) { __instance.m_placementStatus = Player.PlacementStatus.BlockedbyPlayer; } if (component1.m_onlyInBiome != Heightmap.Biome.None && (Heightmap.FindBiome(__instance.m_placementGhost.transform.position) & component1.m_onlyInBiome) == Heightmap.Biome.None) { __instance.m_placementStatus = Player.PlacementStatus.WrongBiome; } if (component1.m_noClipping && __instance.TestGhostClipping(__instance.m_placementGhost, 0.2f)) { __instance.m_placementStatus = Player.PlacementStatus.Invalid; } } else { if ((bool)(UnityEngine.Object)__instance.m_placementMarkerInstance) { __instance.m_placementMarkerInstance.SetActive(false); } __instance.m_placementGhost.SetActive(false); __instance.m_placementStatus = Player.PlacementStatus.Invalid; } __instance.SetPlacementGhostValid(__instance.m_placementStatus == Player.PlacementStatus.Valid); } }
// Token: 0x06000F58 RID: 3928 RVA: 0x0006D44C File Offset: 0x0006B64C public static void FindExtensions(CraftingStation station, Vector3 pos, List <StationExtension> extensions) { foreach (StationExtension stationExtension in StationExtension.m_allExtensions) { if (Vector3.Distance(stationExtension.transform.position, pos) < stationExtension.m_maxStationDistance && stationExtension.m_craftingStation.m_name == station.m_name && !StationExtension.ExtensionInList(extensions, stationExtension)) { extensions.Add(stationExtension); } } }
private static Boolean Prefix(ref Player __instance, ref Int32 ___m_placementStatus, ref GameObject ___m_placementGhost, ref GameObject ___m_placementMarkerInstance, ref int ___m_placeRotation) { if (Conf.AdvancedBuildingMode != null) { return(true); } KeyCode enter = Conf.AdvancedBuildingMode.EnterAdvancedBuildingMode; KeyCode exit = Conf.AdvancedBuildingMode.ExitAdvancedBuildingMode; // Error Handling and removal of left over placement marker if (!__instance.InPlaceMode() || ___m_placementGhost == null) { DelayedStop = false; BlockRefresh = false; ___m_placementMarkerInstance.SetActive(false); return(true); } // Delayed function stop to place the object at the right location (if we would immediatly stop, it would be placed at cursor location) if (DelayedStop) { DelayedStop = false; BlockRefresh = false; return(true); } float rX = 0; float rZ = 0; float rY = 0; Piece component = ___m_placementGhost.GetComponent <Piece>(); if (Input.GetKeyDown(enter)) { BlockRefresh = true; } if (Input.GetKeyDown(exit)) { BlockRefresh = false; ___m_placeRotation = 0; } float distance = 2; float scrollDistance = 2; // TODO ADD INCREASE / DECREASE HOTKEYS // TODO ADD HOTKEY TO SAVE / LOAD ROTATION if (Input.GetKeyDown(KeyCode.LeftControl)) { controlFlag = true; } if (Input.GetKeyUp(KeyCode.LeftControl)) { controlFlag = false; } if (Input.GetKeyDown(KeyCode.LeftShift)) { shiftFlag = true; } if (Input.GetKeyUp(KeyCode.LeftShift)) { shiftFlag = false; } if (shiftFlag) { distance = 6; scrollDistance = 6; } else { distance = 2; scrollDistance = 2; } if (Input.GetKeyDown(KeyCode.LeftAlt)) { altFlag = true; } if (Input.GetKeyUp(KeyCode.LeftAlt)) { altFlag = false; } if (Input.GetAxis("Mouse ScrollWheel") > 0f) { Quaternion rotation; if (controlFlag) { rX++; rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards } else { if (altFlag) { rZ++; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal } else { rY++; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right } } component.transform.rotation = rotation; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { Quaternion rotation; if (controlFlag) { rX--; rotation = Quaternion.Euler(component.transform.eulerAngles.x + (scrollDistance * (float)rX), component.transform.eulerAngles.y, component.transform.eulerAngles.z); // forward to backwards } else { if (altFlag) { rZ--; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y, component.transform.eulerAngles.z + (scrollDistance * (float)rZ)); // diagonal } else { rY--; rotation = Quaternion.Euler(component.transform.eulerAngles.x, component.transform.eulerAngles.y + (scrollDistance * (float)rY), component.transform.eulerAngles.z); // left<->right } } component.transform.rotation = rotation; } if (Input.GetKeyDown(KeyCode.UpArrow)) { if (controlFlag) { component.transform.Translate(Vector3.up * distance * Time.deltaTime); } else { component.transform.Translate(Vector3.forward * distance * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.DownArrow)) { if (controlFlag) { component.transform.Translate(Vector3.down * distance * Time.deltaTime); } else { component.transform.Translate(Vector3.back * distance * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.LeftArrow)) { component.transform.Translate(Vector3.left * distance * Time.deltaTime); } if (Input.GetKeyDown(KeyCode.RightArrow)) { component.transform.Translate(Vector3.right * distance * Time.deltaTime); } // ToDo, add a custom additional downwards raycast from the position of the component to the ground to add the rest of the placement restrictions bool water = component.m_waterPiece || component.m_noInWater; ___m_placementStatus = 0; // VALID if (component.m_groundOnly || component.m_groundPiece || component.m_cultivatedGroundOnly) { ___m_placementMarkerInstance.SetActive(false); } StationExtension component2 = component.GetComponent <StationExtension>(); if (component2 != null) { CraftingStation craftingStation = component2.FindClosestStationInRange(component.transform.position); if (craftingStation) { component2.StartConnectionEffect(craftingStation); } else { component2.StopConnectionEffect(); ___m_placementStatus = 7; // Missing Station } if (component2.OtherExtensionInRange(component.m_spaceRequirement)) { ___m_placementStatus = 5; // More Space } } if (component.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(component.transform.position, EffectArea.Type.Teleport, 0f)) { ___m_placementStatus = 6; } if (!component.m_allowedInDungeons && (component.transform.position.y > 3000f)) { ___m_placementStatus = 10; } if (Location.IsInsideNoBuildLocation(___m_placementGhost.transform.position)) { ___m_placementStatus = 3; } float radius = component.GetComponent <PrivateArea>() ? component.GetComponent <PrivateArea>().m_radius : 0f; if (!PrivateArea.CheckAccess(___m_placementGhost.transform.position, radius, true)) { ___m_placementStatus = 4; } if (___m_placementStatus != 0) { component.SetInvalidPlacementHeightlight(true); } else { component.SetInvalidPlacementHeightlight(false); } if (Input.GetKeyDown(KeyCode.Mouse0)) { // Stop with the next iteration of the function and place the piece DelayedStop = true; } return(!BlockRefresh); }
private static void GenerateReferenceLists() { //Start surfing through all items foreach (GameObject go in ObjectDB.instance.m_items) { //Add to reference lists if not in their already MyReferences.TryAddToItemList(go); ItemDrop id = go.GetComponent <ItemDrop>(); if (id != null) { //var s = id.m_itemData.m_shared; //Log.LogMessage($"{id.name},{s.m_weight},{s.m_attackForce}"); ParticleSystemRenderer ps = go.GetComponent <ParticleSystemRenderer>(); if (ps != null) { if (!MyReferences.listOfMaterials.ContainsKey("item_particle".GetStableHashCode())) { MyReferences.TryAddToMaterialList(ps.sharedMaterial, "item_particle"); } } var shared = id.m_itemData.m_shared; //Start looking for weapon effects (fx, sfx, vfx) if (shared.m_itemType == ItemDrop.ItemData.ItemType.OneHandedWeapon || shared.m_itemType == ItemDrop.ItemData.ItemType.TwoHandedWeapon || shared.m_itemType == ItemDrop.ItemData.ItemType.Bow) { if (!MyReferences.listOfMaterials.ContainsKey("club_trail".GetStableHashCode())) { Transform thing = RecursiveSearchFunctions.ChildNodeFinderBreadthFirst(go.transform, "attach"); if (thing != null) { thing = RecursiveSearchFunctions.ChildNodeFinderBreadthFirst(thing, "equiped"); if (thing != null) { Transform trail = RecursiveSearchFunctions.ChildNodeFinderDepthFirst(thing, "trail"); if (trail != null) { MeleeWeaponTrail mwt = trail.gameObject.GetComponent <MeleeWeaponTrail>(); MyReferences.TryAddToMaterialList(mwt._material, "club_trail"); } } } } MyReferences.TryExtractEffectsFromItemDropShared(shared); } //Check to see if item can also build things if (shared.m_buildPieces != null) { var pieceTable = shared.m_buildPieces.m_pieces; if (pieceTable != null) { foreach (var pieceTableItem in pieceTable) { MyReferences.TryAddToPieceList(pieceTableItem); //One off capture of a station extension's line effect StationExtension stationExtension = pieceTableItem.GetComponent <StationExtension>(); if (stationExtension != null && !MyReferences.listOfEffects.ContainsKey(stationExtension.m_connectionPrefab.name.GetStableHashCode())) { MyReferences.listOfEffects.Add(stationExtension.m_connectionPrefab.name.GetStableHashCode(), stationExtension.m_connectionPrefab); } //Collect this for items and pieces, for proper referencing CraftingStation craftingStation = pieceTableItem.GetComponent <CraftingStation>(); if (craftingStation != null && !MyReferences.listOfCraftingStations.ContainsKey(pieceTableItem.name.GetStableHashCode())) { MyReferences.listOfCraftingStations.Add(pieceTableItem.name.GetStableHashCode(), craftingStation); } CookingStation cookingStation = pieceTableItem.GetComponent <CookingStation>(); if (cookingStation != null && !MyReferences.listOfCookingStations.ContainsKey(pieceTableItem.name.GetStableHashCode())) { MyReferences.listOfCookingStations.Add(pieceTableItem.name.GetStableHashCode(), cookingStation); } //Extracting any Piece Placement Effects var PieceScript = pieceTableItem.GetComponent <Piece>(); if (PieceScript != null) { ExtractEffectsFromPiece(PieceScript.m_placeEffect); } //Extracting WearNTear effects var WearNTearScript = pieceTableItem.GetComponent <WearNTear>(); if (WearNTearScript != null) { ExtractEffectsFromPiece(WearNTearScript.m_destroyedEffect); ExtractEffectsFromPiece(WearNTearScript.m_hitEffect); ExtractEffectsFromPiece(WearNTearScript.m_switchEffect); } } } } } } }