protected override void SetVerticesDirty() { base.SetVerticesDirty(); _lastKeepAspectRatio = m_KeepAspectRatio; _lastEffectArea = m_EffectArea; }
private static void RemoveForceFieldForPrivateArea(PrivateArea pa) { Plugin.Log("RemoveForceFieldForPrivateArea called"); List <SphereCollider> forceFields = GetForceFieldsInRange(pa.transform.position, 2); foreach (SphereCollider forceField in forceFields) { EffectArea noMonstersArea = forceField.GetComponent <EffectArea>(); if (null != noMonstersArea) { // destroy the colliders SphereCollider[] colliders = noMonstersArea.GetComponents <SphereCollider>(); for (int i = 0; i < colliders.Length; i++) { Plugin.Log("RemoveForceFieldForPrivateArea - Destroying SphereCollider"); GameObject.Destroy(colliders[i]); } // destroy the object Plugin.Log("RemoveForceFieldForPrivateArea - Destroying EffectArea"); GameObject.Destroy(noMonstersArea); } Plugin.Log("RemoveForceFieldForPrivateArea - Destroying forceField"); GameObject.Destroy(forceField); } }
public GameObject CreatePrefab() { GameObject gameObject = CreateOilFloater(ID, PHO_STRINGS.VARIANT_OWO.NAME, PHO_STRINGS.VARIANT_OWO.DESC, base_kanim_id, false); DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>(); decorProvider.SetValues(TUNING.DECOR.BONUS.TIER5); EffectArea owoEffect = gameObject.AddComponent <EffectArea>(); owoEffect.EffectName = "OwO_effect"; owoEffect.Area = 5; EntityTemplates.ExtendEntityToFertileCreature(gameObject, EGG_ID, PHO_STRINGS.VARIANT_OWO.EGG_NAME, PHO_STRINGS.VARIANT_OWO.DESC, egg_kanim_id, OilFloaterTuning.EGG_MASS, ID + "Baby", 45, 20f, EGG_CHANCES_OWO, EGG_SORT_ORDER, true, false, true, 1f); return(gameObject); }
protected override void SetVerticesDirty() { base.SetVerticesDirty(); _lastRotation = m_Rotation; _lastEffectArea = m_EffectArea; }
/// <summary> /// Gets effect for area. /// </summary> public static Rect GetEffectArea(this EffectArea area, VertexHelper vh, Graphic graphic) { switch (area) { case EffectArea.RectTransform: return(graphic.rectTransform.rect); case EffectArea.Character: return(rectForCharacter); case EffectArea.Fit: { // Fit to contents. Rect rect = default(Rect); UIVertex vertex = default(UIVertex); rect.xMin = rect.yMin = float.MaxValue; rect.xMax = rect.yMax = float.MinValue; for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); rect.xMin = Mathf.Min(rect.xMin, vertex.position.x); rect.yMin = Mathf.Min(rect.yMin, vertex.position.y); rect.xMax = Mathf.Max(rect.xMax, vertex.position.x); rect.yMax = Mathf.Max(rect.yMax, vertex.position.y); } return(rect); } default: return(graphic.rectTransform.rect); } }
// Token: 0x06000478 RID: 1144 RVA: 0x000241D0 File Offset: 0x000223D0 private void PlaceOne() { Vector3 vector; if (this.GetRandomPoint(base.transform.position, this.m_totalRadius, out vector)) { int num = 0; float num2 = 6.2831855f / (float)this.m_rays; for (int i = 0; i < this.m_rays; i++) { float angle = (float)i * num2; if ((double)this.GetPointOnEdge(vector, angle, this.m_testRadius).y < (double)vector.y - 0.1) { num++; } } if (num > this.m_rays / 4) { return; } if (EffectArea.IsPointInsideArea(vector, EffectArea.Type.Fire, this.m_testRadius)) { return; } ParticleSystem.EmitParams emitParams = default(ParticleSystem.EmitParams); emitParams.position = vector + Vector3.up * this.m_placeOffset; this.m_psystem.Emit(emitParams, 1); } }
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); }
private void ResetEffect(EffectArea efArea) { if (efArea.spriteRendererHolder != null) { efArea.spriteRendererHolder.GetComponent <SpriteRenderer>().sprite = null; } }
// Check for access to object private static bool isValidRayCastTarget() { bool hitValid = true; if (HitPiece.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(HitPiece.transform.position, EffectArea.Type.Teleport, 0f)) { // Not in Teleport Area hitValid = false; } if (!HitPiece.m_allowedInDungeons && (HitPiece.transform.position.y > 3000f)) { // Not in dungeon hitValid = false; } if (Location.IsInsideNoBuildLocation(HitPiece.transform.position)) { // No build zone hitValid = false; } float radius = HitPiece.GetComponent <PrivateArea>() ? HitPiece.GetComponent <PrivateArea>().m_radius : 0f; if (!PrivateArea.CheckAccess(HitPiece.transform.position, radius, true)) { // private zone hitValid = false; } return(hitValid); }
// Token: 0x0600067A RID: 1658 RVA: 0x00036428 File Offset: 0x00034628 private void CheckFire() { this.m_haveFire = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Burning, 0.25f); if (this.m_haveFireObject) { this.m_haveFireObject.SetActive(this.m_haveFire); } }
// Token: 0x06000C65 RID: 3173 RVA: 0x00059063 File Offset: 0x00057263 private bool CheckFire(Player human) { if (!EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Heat, 0f)) { human.Message(MessageHud.MessageType.Center, "$msg_bednofire", 0, null); return(false); } return(true); }
/// <summary> /// Gets effect for area. /// </summary> public static Rect GetEffectArea(this EffectArea area, VertexHelper vh, Rect rectangle, float aspectRatio = -1) { Rect rect = default(Rect); switch (area) { case EffectArea.RectTransform: rect = rectangle; break; case EffectArea.Character: rect = rectForCharacter; break; case EffectArea.Fit: // Fit to contents. UIVertex vertex = default(UIVertex); float xMin = float.MaxValue; float yMin = float.MaxValue; float xMax = float.MinValue; float yMax = float.MinValue; for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); float x = vertex.position.x; float y = vertex.position.y; xMin = Mathf.Min(xMin, x); yMin = Mathf.Min(yMin, y); xMax = Mathf.Max(xMax, x); yMax = Mathf.Max(yMax, y); } rect.Set(xMin, yMin, xMax - xMin, yMax - yMin); break; default: rect = rectangle; break; } if (0 < aspectRatio) { if (rect.width < rect.height) { rect.width = rect.height * aspectRatio; } else { rect.height = rect.width / aspectRatio; } } return(rect); }
public bool AvoidFire(float dt) { EffectArea effectArea2 = EffectArea.IsPointInsideArea(Instance.transform.position, EffectArea.Type.Burning, 2f); if ((bool)effectArea2) { Invoke <BaseAI>(Instance, "RandomMovementArroundPoint", dt, effectArea2.transform.position, effectArea2.GetRadius() + 3f, true); return(true); } return(false); }
static bool AvoidFire(MonsterAI instance, float dt, Vector3 targetPosition) { EffectArea effectArea2 = EffectArea.IsPointInsideArea(instance.transform.position, EffectArea.Type.Burning, 2f); if ((bool)effectArea2) { typeof(MonsterAI).GetMethod("RandomMovementArroundPoint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(instance, new object[] { dt, effectArea2.transform.position, effectArea2.GetRadius() + 3f, true }); return(true); } return(false); }
/// <summary> /// Normalize vertex position by local matrix. /// </summary> public static void GetNormalizedFactor(this EffectArea area, int index, Matrix2x3 matrix, Vector2 position, bool isText, out Vector2 nomalizedPos) { if (isText && area == EffectArea.Character) { nomalizedPos = matrix * splitedCharacterPosition [(index + 3) % 4]; } else { nomalizedPos = matrix * position; } }
// Token: 0x060000EF RID: 239 RVA: 0x0000714C File Offset: 0x0000534C private void UpdateSpawner() { if (!this.m_nview.IsOwner()) { return; } ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("spawn_id"); if (this.m_respawnTimeMinuts <= 0f && !zdoid.IsNone()) { return; } if (!zdoid.IsNone() && ZDOMan.instance.GetZDO(zdoid) != null) { this.m_nview.GetZDO().Set("alive_time", ZNet.instance.GetTime().Ticks); return; } if (this.m_respawnTimeMinuts > 0f) { DateTime time = ZNet.instance.GetTime(); DateTime d = new DateTime(this.m_nview.GetZDO().GetLong("alive_time", 0L)); if ((time - d).TotalMinutes < (double)this.m_respawnTimeMinuts) { return; } } if (!this.m_spawnAtDay && EnvMan.instance.IsDay()) { return; } if (!this.m_spawnAtNight && EnvMan.instance.IsNight()) { return; } bool requireSpawnArea = this.m_requireSpawnArea; if (!this.m_spawnInPlayerBase && EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.PlayerBase, 0f)) { return; } if (this.m_triggerNoise > 0f) { if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance, this.m_triggerNoise)) { return; } } else if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance)) { return; } this.Spawn(); }
/// <summary> /// Gets position factor for area. /// </summary> public void GetPositionFactor(EffectArea area, int index, Rect rect, Vector2 position, out float x, out float y) { if (area == EffectArea.Fit) { x = Mathf.Clamp01((position.x - rect.xMin) / rect.width); y = Mathf.Clamp01((position.y - rect.yMin) / rect.height); } else { x = Mathf.Clamp01(position.x / rect.width + 0.5f); y = Mathf.Clamp01(position.y / rect.height + 0.5f); } }
/// <summary> /// 得到特效的矩形区域 /// </summary> /// <param name="area">矩形区域的枚举</param> /// <param name="vh">UI的顶点</param> /// <param name="graphic">UI基础类型</param> /// <param name="aspectRatio">宽度/高度的比例</param> /// <returns>矩形区域</returns> public static Rect GetEffectArea(this EffectArea area, VertexHelper vh, Graphic graphic, float aspectRatio = -1) { Rect rect = default(Rect); switch (area) { case EffectArea.RectTransform: rect = graphic.rectTransform.rect; break; case EffectArea.Character: rect = rectForCharacter; break; case EffectArea.Fit: // Fit to contents. UIVertex vertex = default; rect.xMin = rect.yMin = float.MaxValue; rect.xMax = rect.yMax = float.MinValue; for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); rect.xMin = Mathf.Min(rect.xMin, vertex.position.x); rect.yMin = Mathf.Min(rect.yMin, vertex.position.y); rect.xMax = Mathf.Max(rect.xMax, vertex.position.x); rect.yMax = Mathf.Max(rect.yMax, vertex.position.y); } break; default: rect = graphic.rectTransform.rect; break; } if (aspectRatio > 0) { if (rect.height > rect.width) { rect.width = rect.height * aspectRatio; } else { rect.height = rect.width / aspectRatio; } } return(rect); }
// Token: 0x06000CF9 RID: 3321 RVA: 0x0005CCEC File Offset: 0x0005AEEC public static EffectArea IsPointInsideArea(Vector3 p, EffectArea.Type type, float radius = 0f) { int num = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.m_characterMask); for (int i = 0; i < num; i++) { EffectArea component = EffectArea.m_tempColliders[i].GetComponent <EffectArea>(); if (component && (component.m_type & type) != (EffectArea.Type) 0) { return(component); } } return(null); }
// Token: 0x06000CFA RID: 3322 RVA: 0x0005CD3C File Offset: 0x0005AF3C public static int GetBaseValue(Vector3 p, float radius) { int num = 0; int num2 = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.m_characterMask); for (int i = 0; i < num2; i++) { EffectArea component = EffectArea.m_tempColliders[i].GetComponent <EffectArea>(); if (component && (component.m_type & EffectArea.Type.PlayerBase) != (EffectArea.Type) 0) { num++; } } return(num); }
/// <summary> /// Resize child EffectArea's collision that matches the specified type(s). /// </summary> public static void ResizeChildEffectArea(MonoBehaviour parent, EffectArea.Type includedTypes, float newRadius) { if (parent != null) { EffectArea effectArea = parent.GetComponentInChildren <EffectArea>(); if (effectArea != null) { if ((effectArea.m_type & includedTypes) != 0) { SphereCollider collision = effectArea.GetComponent <SphereCollider>(); if (collision != null) { collision.radius = newRadius; } } } } }
/// <summary> /// Gets position factor for area. /// </summary> public static void GetPositionFactor(this EffectArea area, int index, Rect rect, Vector2 position, bool isText, bool isTMPro, out float x, out float y) { if (isText && area == EffectArea.Character) { index = isTMPro ? (index + 3) % 4 : index % 4; x = splitedCharacterPosition [index].x; y = splitedCharacterPosition [index].y; } else if (area == EffectArea.Fit) { x = Mathf.Clamp01((position.x - rect.xMin) / rect.width); y = Mathf.Clamp01((position.y - rect.yMin) / rect.height); } else { x = Mathf.Clamp01(position.x / rect.width + 0.5f); y = Mathf.Clamp01(position.y / rect.height + 0.5f); } }
private static void UpdateForceField(PrivateArea pa, bool enabled) { Plugin.Log($"UpdateForceField called: {enabled}"); // if the ward behavior is set to original or ward is not enabled, then attempt to remove any wards... if (!enabled || Settings.WardBehavior.Value == Plugin.WardBehavior.Original) { RemoveForceFieldForPrivateArea(pa); } else { SphereCollider sphere = GetAForceFieldForPrivateArea(pa); EffectArea NoMonsters = sphere.GetComponent <EffectArea>(); if (null != NoMonsters) { Plugin.Log($"UpdateForceField Got NoMonsterArea"); // NoMonsters keeps monsters from "attempting" to navigate inside // Playerbase ensures that creatures don't spawn within the radius // however you can't build when it's enabled. NoMonsters.enabled = enabled; NoMonsters.m_type = enabled ? (EffectArea.Type.NoMonsters | EffectArea.Type.PlayerBase) : EffectArea.Type.None; // layer modelled after the ForceField in the Vendor_BlackForest scene. NoMonsters.gameObject.layer = 14; SphereCollider collider = NoMonsters.GetComponent <SphereCollider>(); if (null != collider) { collider.enabled = enabled; collider.radius = pa.m_radius; collider.name = Plugin.SphereColliderName; } } } }
// Token: 0x060006C9 RID: 1737 RVA: 0x000383BC File Offset: 0x000365BC private bool IsInsideBase() { return(base.transform.position.y > ZoneSystem.instance.m_waterLevel + -2f && EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.PlayerBase, 0f)); }
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); }
// Token: 0x0600036D RID: 877 RVA: 0x0001D5F4 File Offset: 0x0001B7F4 protected override void UpdateAI(float dt) { base.UpdateAI(dt); if (!this.m_nview.IsOwner()) { return; } if (this.IsSleeping()) { this.UpdateSleep(dt); return; } this.m_aiStatus = ""; Humanoid humanoid = this.m_character as Humanoid; bool flag; bool flag2; this.UpdateTarget(humanoid, dt, out flag, out flag2); if (this.m_avoidLand && !this.m_character.IsSwiming()) { this.m_aiStatus = "Move to water"; base.MoveToWater(dt, 20f); return; } if (((this.DespawnInDay() && EnvMan.instance.IsDay()) || (this.IsEventCreature() && !RandEventSystem.HaveActiveEvent())) && (this.m_targetCreature == null || !flag2)) { base.MoveAwayAndDespawn(dt, true); this.m_aiStatus = "Trying to despawn "; return; } if (this.m_fleeIfNotAlerted && !this.HuntPlayer() && this.m_targetCreature && !base.IsAlerted() && Vector3.Distance(this.m_targetCreature.transform.position, base.transform.position) - this.m_targetCreature.GetRadius() > this.m_alertRange) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Avoiding conflict"; return; } if (this.m_fleeIfLowHealth > 0f && this.m_character.GetHealthPercentage() < this.m_fleeIfLowHealth && this.m_timeSinceHurt < 20f && this.m_targetCreature != null) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Low health, flee"; return; } if ((this.m_afraidOfFire || this.m_avoidFire) && base.AvoidFire(dt, this.m_targetCreature, this.m_afraidOfFire)) { if (this.m_afraidOfFire) { this.m_targetStatic = null; this.m_targetCreature = null; } this.m_aiStatus = "Avoiding fire"; return; } if (this.m_circleTargetInterval > 0f && this.m_targetCreature) { if (this.m_targetCreature) { this.m_pauseTimer += dt; if (this.m_pauseTimer > this.m_circleTargetInterval) { if (this.m_pauseTimer > this.m_circleTargetInterval + this.m_circleTargetDuration) { this.m_pauseTimer = 0f; } base.RandomMovementArroundPoint(dt, this.m_targetCreature.transform.position, this.m_circleTargetDistance, base.IsAlerted()); this.m_aiStatus = "Attack pause"; return; } } else { this.m_pauseTimer = 0f; } } if (this.m_targetCreature != null) { if (EffectArea.IsPointInsideArea(this.m_targetCreature.transform.position, EffectArea.Type.NoMonsters, 0f)) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Avoid no-monster area"; return; } } else { EffectArea effectArea = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.NoMonsters, 15f); if (effectArea != null) { base.Flee(dt, effectArea.transform.position); this.m_aiStatus = "Avoid no-monster area"; return; } } if (this.m_fleeIfHurtWhenTargetCantBeReached && this.m_targetCreature != null && !this.m_havePathToTarget && this.m_timeSinceHurt < 20f) { this.m_aiStatus = "Hide from unreachable target"; base.Flee(dt, this.m_targetCreature.transform.position); return; } if ((!base.IsAlerted() || (this.m_targetStatic == null && this.m_targetCreature == null)) && this.UpdateConsumeItem(humanoid, dt)) { this.m_aiStatus = "Consume item"; return; } ItemDrop.ItemData itemData = this.SelectBestAttack(humanoid, dt); bool flag3 = itemData != null && Time.time - itemData.m_lastAttackTime > itemData.m_shared.m_aiAttackInterval && Time.time - this.m_lastAttackTime > this.m_minAttackInterval && !base.IsTakingOff(); if ((this.m_character.IsFlying() ? this.m_circulateWhileChargingFlying : this.m_circulateWhileCharging) && (this.m_targetStatic != null || this.m_targetCreature != null) && itemData != null && !flag3 && !this.m_character.InAttack()) { this.m_aiStatus = "Move around target weapon ready:" + flag3.ToString(); if (itemData != null) { this.m_aiStatus = this.m_aiStatus + " Weapon:" + itemData.m_shared.m_name; } Vector3 point = this.m_targetCreature ? this.m_targetCreature.transform.position : this.m_targetStatic.transform.position; base.RandomMovementArroundPoint(dt, point, this.m_randomMoveRange, base.IsAlerted()); return; } if ((!(this.m_targetStatic == null) || !(this.m_targetCreature == null)) && itemData != null) { if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Enemy) { if (this.m_targetStatic) { Vector3 vector = this.m_targetStatic.FindClosestPoint(base.transform.position); if (Vector3.Distance(vector, base.transform.position) >= itemData.m_shared.m_aiAttackRange || !base.CanSeeTarget(this.m_targetStatic)) { this.m_aiStatus = "Move to static target"; base.MoveTo(dt, vector, 0f, base.IsAlerted()); return; } base.LookAt(this.m_targetStatic.GetCenter()); if (base.IsLookingAt(this.m_targetStatic.GetCenter(), itemData.m_shared.m_aiAttackMaxAngle) && flag3) { this.m_aiStatus = "Attacking piece"; this.DoAttack(null, false); return; } base.StopMoving(); return; } else if (this.m_targetCreature) { if (flag || flag2 || (this.HuntPlayer() && this.m_targetCreature.IsPlayer())) { this.m_beenAtLastPos = false; this.m_lastKnownTargetPos = this.m_targetCreature.transform.position; float num = Vector3.Distance(this.m_lastKnownTargetPos, base.transform.position) - this.m_targetCreature.GetRadius(); float num2 = this.m_alertRange * this.m_targetCreature.GetStealthFactor(); if ((flag2 && num < num2) || this.HuntPlayer()) { this.SetAlerted(true); } bool flag4 = num < itemData.m_shared.m_aiAttackRange; if (!flag4 || !flag2 || itemData.m_shared.m_aiAttackRangeMin < 0f || !base.IsAlerted()) { this.m_aiStatus = "Move closer"; Vector3 velocity = this.m_targetCreature.GetVelocity(); Vector3 vector2 = velocity * this.m_interceptTime; Vector3 vector3 = this.m_lastKnownTargetPos; if (num > vector2.magnitude / 4f) { vector3 += velocity * this.m_interceptTime; } if (base.MoveTo(dt, vector3, 0f, base.IsAlerted())) { flag4 = true; } } else { base.StopMoving(); } if (flag4 && flag2 && base.IsAlerted()) { this.m_aiStatus = "In attack range"; base.LookAt(this.m_targetCreature.GetTopPoint()); if (flag3 && base.IsLookingAt(this.m_lastKnownTargetPos, itemData.m_shared.m_aiAttackMaxAngle)) { this.m_aiStatus = "Attacking creature"; this.DoAttack(this.m_targetCreature, false); return; } } } else { this.m_aiStatus = "Searching for target"; if (this.m_beenAtLastPos) { base.RandomMovement(dt, this.m_lastKnownTargetPos); return; } if (base.MoveTo(dt, this.m_lastKnownTargetPos, 0f, base.IsAlerted())) { this.m_beenAtLastPos = true; return; } } } } else if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt || itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Friend) { this.m_aiStatus = "Helping friend"; Character character = (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt) ? base.HaveHurtFriendInRange(this.m_viewRange) : base.HaveFriendInRange(this.m_viewRange); if (character) { if (Vector3.Distance(character.transform.position, base.transform.position) >= itemData.m_shared.m_aiAttackRange) { base.MoveTo(dt, character.transform.position, 0f, base.IsAlerted()); return; } if (flag3) { base.StopMoving(); base.LookAt(character.transform.position); this.DoAttack(character, true); return; } base.RandomMovement(dt, character.transform.position); return; } else { base.RandomMovement(dt, base.transform.position); } } return; } if (this.m_follow) { base.Follow(this.m_follow, dt); this.m_aiStatus = "Follow"; return; } this.m_aiStatus = string.Concat(new object[] { "Random movement (weapon: ", (itemData != null) ? itemData.m_shared.m_name : "none", ") (targetpiece: ", this.m_targetStatic, ") (target: ", this.m_targetCreature ? this.m_targetCreature.gameObject.name : "none", ")" }); base.IdleMovement(dt); }
/// <summary> /// Normalize vertex position by local matrix. /// </summary> public void GetNormalizedFactor(EffectArea area, int index, Matrix2x3 matrix, Vector2 position, out Vector2 normalizedPos) { normalizedPos = matrix * position; }
static void Postfix(CookingStation __instance, ZNetView ___m_nview) { if (!modEnabled.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || !EffectArea.IsPointInsideArea(__instance.transform.position, EffectArea.Type.Burning, 0.25f)) { return; } for (int i = 0; i < __instance.m_slots.Length; i++) { string itemName = ___m_nview.GetZDO().GetString("slot" + i, ""); float num = ___m_nview.GetZDO().GetFloat("slot" + i, 0f); if (itemName != "" && itemName != __instance.m_overCookedItem.name && itemName != null) { CookingStation.ItemConversion itemConversion = Traverse.Create(__instance).Method("GetItemConversion", new object[] { itemName }).GetValue <CookingStation.ItemConversion>(); if (num > itemConversion.m_cookTime && itemName == itemConversion.m_to.name) { if (autoPop.Value) { Traverse.Create(__instance).Method("SpawnItem", new object[] { itemName }).GetValue(); ___m_nview.GetZDO().Set("slot" + i, ""); ___m_nview.GetZDO().Set("slot" + i, 0f); ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[] { i, "" }); } else if (preventBurning.Value) { ___m_nview.GetZDO().Set("slot" + i, itemConversion.m_cookTime); } } } } }
protected static IEnumerator GetRandomPointInBiome(Heightmap.Biome biome, AdventureSaveData saveData, Action <bool, Vector3, Vector3> onComplete) { const int maxRangeIncreases = 10; const int maxPointsInRange = 15; MerchantPanel.ShowInputBlocker(true); var rangeTries = 0; var radiusRange = GetTreasureMapSpawnRadiusRange(biome, saveData); while (rangeTries < maxRangeIncreases) { rangeTries++; var tries = 0; while (tries < maxPointsInRange) { tries++; var randomPoint = UnityEngine.Random.insideUnitCircle; var mag = randomPoint.magnitude; var normalized = randomPoint.normalized; var actualMag = Mathf.Lerp(radiusRange.Item1, radiusRange.Item2, mag); randomPoint = normalized * actualMag; var spawnPoint = new Vector3(randomPoint.x, 0, randomPoint.y); var zoneId = ZoneSystem.instance.GetZone(spawnPoint); while (!ZoneSystem.instance.SpawnZone(zoneId, ZoneSystem.SpawnMode.Client, out _)) { EpicLoot.LogWarning($"Spawning Zone ({zoneId})..."); yield return(null); } ZoneSystem.instance.GetGroundData(ref spawnPoint, out var normal, out var foundBiome, out _, out _); var groundHeight = spawnPoint.y; EpicLoot.Log($"Checking biome at ({randomPoint}): {foundBiome} (try {tries})"); if (foundBiome != biome) { // Wrong biome continue; } var solidHeight = ZoneSystem.instance.GetSolidHeight(spawnPoint); var offsetFromGround = Math.Abs(solidHeight - groundHeight); if (offsetFromGround > 5) { // Don't place too high off the ground (on top of tree or something? EpicLoot.Log($"Spawn Point rejected: too high off of ground (groundHeight:{groundHeight}, solidHeight:{solidHeight})"); continue; } // But also don't place inside rocks spawnPoint.y = solidHeight; var placedNearPlayerBase = EffectArea.IsPointInsideArea(spawnPoint, EffectArea.Type.PlayerBase, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius); if (placedNearPlayerBase) { // Don't place near player base EpicLoot.Log("Spawn Point rejected: too close to player base"); continue; } EpicLoot.Log($"Wards: {PrivateArea.m_allAreas.Count}"); var tooCloseToWard = PrivateArea.m_allAreas.Any(x => x.IsInside(spawnPoint, AdventureDataManager.Config.TreasureMap.MinimapAreaRadius)); if (tooCloseToWard) { EpicLoot.Log("Spawn Point rejected: too close to player ward"); continue; } var waterLevel = ZoneSystem.instance.m_waterLevel; if (waterLevel > groundHeight + 1.0f) { // Too deep, try again EpicLoot.Log($"Spawn Point rejected: too deep underwater (waterLevel:{waterLevel}, groundHeight:{groundHeight})"); continue; } EpicLoot.Log($"Success! (ground={groundHeight} water={waterLevel} placed={spawnPoint.y})"); onComplete?.Invoke(true, spawnPoint, normal); MerchantPanel.ShowInputBlocker(false); yield break; } radiusRange = new Tuple <float, float>(radiusRange.Item1 + 500, radiusRange.Item2 + 500); } onComplete?.Invoke(false, new Vector3(), new Vector3()); MerchantPanel.ShowInputBlocker(false); }
private static void Postfix(Player __instance) { if (Settings.isEnabled("AdvancedEditingMode")) { if (isInAEM && __instance.InPlaceMode()) { DelayedStop = true; HitPiece.transform.position = InitialPosition; HitPiece.transform.rotation = InitialRotation; } if (Input.GetKeyDown(Settings.getHotkey("enterAdvancedEditingMode")) && !isInAEM && !__instance.InPlaceMode()) { if (!AdvancedBuildingMode.isInABM) { int layerMask = __instance.m_placeRayMask; Character PlayerCharacter = Helper.getPlayerCharacter(); if (Physics.Raycast( GameCamera.instance.transform.position, GameCamera.instance.transform.forward, out raycastHit, 50f, layerMask ) && raycastHit.collider && !raycastHit.collider.attachedRigidbody && Vector3.Distance(PlayerCharacter.m_eye.position, raycastHit.point) < __instance.m_maxPlaceDistance) { HitPoint = raycastHit.point; HitNormal = raycastHit.normal; HitPiece = raycastHit.collider.GetComponentInParent <Piece>(); HitObject = raycastHit.collider.gameObject; HitHeightmap = raycastHit.collider.GetComponent <Heightmap>(); InitialRotation = HitPiece.transform.rotation; InitialPosition = HitPiece.transform.position; } else { HitPoint = Vector3.zero; HitNormal = Vector3.zero; HitObject = null; HitPiece = null; HitHeightmap = null; } if (HitPiece != null) { Boolean hitValid = true; if (HitPiece.m_onlyInTeleportArea && !EffectArea.IsPointInsideArea(HitPiece.transform.position, EffectArea.Type.Teleport, 0f)) { // Not in Teleport Area hitValid = false; } if (!HitPiece.m_allowedInDungeons && (HitPiece.transform.position.y > 3000f)) { // Not in dungeon hitValid = false; } if (Location.IsInsideNoBuildLocation(HitPiece.transform.position)) { // No build zone hitValid = false; } float radius = HitPiece.GetComponent <PrivateArea>() ? HitPiece.GetComponent <PrivateArea>().m_radius : 0f; if (!PrivateArea.CheckAccess(HitPiece.transform.position, radius, true)) { // private zone hitValid = false; } // Initialize AEM if (hitValid) { isInAEM = true; HitExsists = true; } } } } try { // check to see if the hit object still exsists if (isInAEM) { exsistenceCheck = HitPiece.transform.position; HitExsists = true; } } catch (Exception e) { HitExsists = false; } if (DelayedStop || (!HitExsists && isInAEM)) { isInAEM = false; HitPoint = Vector3.zero; HitNormal = Vector3.zero; HitObject = null; HitPiece = null; HitHeightmap = null; DelayedStop = false; InitialRotation = new Quaternion(); InitialPosition = new Vector3(); } if (isInAEM && !AdvancedBuildingMode.isInABM) { // stop and reset object when entering building mode float rX = 0; float rZ = 0; float rY = 0; if (Input.GetKeyDown(Settings.getHotkey("resetAdvancedEditingMode"))) { HitPiece.transform.position = InitialPosition; HitPiece.transform.rotation = InitialRotation; } if (Input.GetKeyDown(Settings.getHotkey("abortAndExitAdvancedEditingMode"))) { HitPiece.transform.position = InitialPosition; HitPiece.transform.rotation = InitialRotation; DelayedStop = true; } if (Input.GetKeyDown(Settings.getHotkey("confirmPlacementOfAdvancedEditingMode"))) { GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(HitPiece.gameObject, HitPiece.transform.position, HitPiece.transform.rotation); HitPiece.m_placeEffect.Create(HitPiece.transform.position, HitPiece.transform.rotation, gameObject2.transform, 1f); ZNetScene.instance.Destroy(HitPiece.gameObject); DelayedStop = true; } 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; } // 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 = HitPiece; // Maximum distance between player and placed piece if (Vector3.Distance(__instance.transform.position, component.transform.position) > 25) { HitPiece.transform.position = InitialPosition; HitPiece.transform.rotation = InitialRotation; 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); } } } }