mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Use layer util
This commit is contained in:
parent
7a2d3cc893
commit
851b4608c2
@ -1,4 +1,5 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
@ -8,7 +9,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
var airGO = new GameObject("Air");
|
||||
airGO.SetActive(false);
|
||||
airGO.layer = 17;
|
||||
airGO.layer = LayerUtilities.BasicEffectVolume;
|
||||
airGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
|
||||
var sc = airGO.AddComponent<SphereCollider>();
|
||||
|
||||
@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using System.Collections.Generic;
|
||||
using Tessellation;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
@ -118,7 +119,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
GameObject cloudsFluidGO = new GameObject("CloudsFluid");
|
||||
cloudsFluidGO.SetActive(false);
|
||||
cloudsFluidGO.layer = 17;
|
||||
cloudsFluidGO.layer = LayerUtilities.BasicEffectVolume;
|
||||
cloudsFluidGO.transform.parent = cloudsMainGO.transform;
|
||||
|
||||
SphereCollider fluidSC = cloudsFluidGO.AddComponent<SphereCollider>();
|
||||
@ -251,7 +252,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
if (atmo.clouds.unlit)
|
||||
{
|
||||
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
|
||||
cloudsTopGO.layer = LayerUtilities.IgnoreSun;
|
||||
}
|
||||
|
||||
if (atmo.clouds.rotationSpeed != 0f)
|
||||
@ -303,7 +304,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController");
|
||||
tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false);
|
||||
tcrqcGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
tcrqcGO.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var shape = tcrqcGO.AddComponent<SphereShape>();
|
||||
shape.radius = 1;
|
||||
|
||||
@ -8,6 +8,7 @@ using NewHorizons.External.Modules;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.Components.Volumes;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -30,7 +31,7 @@ namespace NewHorizons.Builder.Body
|
||||
ringVolume.transform.localPosition = Vector3.zero;
|
||||
ringVolume.transform.localScale = Vector3.one;
|
||||
ringVolume.transform.localRotation = Quaternion.identity;
|
||||
ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
ringVolume.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var ringShape = ringVolume.AddComponent<RingShape>();
|
||||
ringShape.innerRadius = ring.innerRadius;
|
||||
|
||||
@ -11,6 +11,7 @@ using System.Drawing;
|
||||
using Color = UnityEngine.Color;
|
||||
using NewHorizons.Components.Volumes;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -191,7 +192,7 @@ namespace NewHorizons.Builder.Body
|
||||
if (hasDestructionVolume || targetStarSystem != null)
|
||||
{
|
||||
var destructionVolumeGO = new GameObject("DestructionVolume");
|
||||
destructionVolumeGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
destructionVolumeGO.layer = LayerUtilities.BasicEffectVolume;
|
||||
destructionVolumeGO.transform.parent = singularity.transform;
|
||||
destructionVolumeGO.transform.localScale = Vector3.one;
|
||||
destructionVolumeGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
@ -9,6 +9,7 @@ using OWML.Common;
|
||||
using UnityEngine.InputSystem.XR;
|
||||
using System.Linq;
|
||||
using NewHorizons.Components.Stars;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -122,7 +123,7 @@ namespace NewHorizons.Builder.Body
|
||||
heatVolume.transform.SetParent(starGO.transform, false);
|
||||
heatVolume.transform.localPosition = Vector3.zero;
|
||||
heatVolume.transform.localScale = Vector3.one;
|
||||
heatVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
heatVolume.layer = LayerUtilities.BasicEffectVolume;
|
||||
heatVolume.AddComponent<SphereShape>().radius = 1.1f;
|
||||
heatVolume.AddComponent<OWTriggerVolume>();
|
||||
heatVolume.AddComponent<HeatHazardVolume>()._damagePerSecond = 20f;
|
||||
@ -132,7 +133,7 @@ namespace NewHorizons.Builder.Body
|
||||
deathVolume.transform.SetParent(starGO.transform, false);
|
||||
deathVolume.transform.localPosition = Vector3.zero;
|
||||
deathVolume.transform.localScale = Vector3.one;
|
||||
deathVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
deathVolume.layer = LayerUtilities.BasicEffectVolume;
|
||||
var sphereCollider = deathVolume.AddComponent<SphereCollider>();
|
||||
sphereCollider.radius = 1f;
|
||||
sphereCollider.isTrigger = true;
|
||||
@ -148,7 +149,7 @@ namespace NewHorizons.Builder.Body
|
||||
planetDestructionVolume.transform.SetParent(starGO.transform, false);
|
||||
planetDestructionVolume.transform.localPosition = Vector3.zero;
|
||||
planetDestructionVolume.transform.localScale = Vector3.one;
|
||||
planetDestructionVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
planetDestructionVolume.layer = LayerUtilities.BasicEffectVolume;
|
||||
var planetSphereCollider = planetDestructionVolume.AddComponent<SphereCollider>();
|
||||
planetSphereCollider.radius = 0.8f;
|
||||
planetSphereCollider.isTrigger = true;
|
||||
@ -445,7 +446,7 @@ namespace NewHorizons.Builder.Body
|
||||
supernovaWallAudio.transform.SetParent(supernovaGO.transform, false);
|
||||
supernovaWallAudio.transform.localPosition = Vector3.zero;
|
||||
supernovaWallAudio.transform.localScale = Vector3.one;
|
||||
supernovaWallAudio.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
supernovaWallAudio.layer = LayerUtilities.BasicEffectVolume;
|
||||
var audioSource = supernovaWallAudio.AddComponent<AudioSource>();
|
||||
audioSource.loop = true;
|
||||
audioSource.maxDistance = 2000;
|
||||
|
||||
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
using NewHorizons.External.Modules.VariableSize;
|
||||
using Tessellation;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
// Don't ignore sun when not under clouds
|
||||
waterGO.layer = 0;
|
||||
Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = 15; });
|
||||
Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = LayerUtilities.IgnoreSun; });
|
||||
|
||||
TessellatedSphereRenderer TSR = waterGO.AddComponent<TessellatedSphereRenderer>();
|
||||
TSR.tessellationMeshGroup = ScriptableObject.CreateInstance<MeshGroup>();
|
||||
@ -100,7 +101,7 @@ namespace NewHorizons.Builder.Body
|
||||
var buoyancyObject = new GameObject("WaterVolume");
|
||||
buoyancyObject.transform.parent = waterGO.transform;
|
||||
buoyancyObject.transform.localScale = Vector3.one;
|
||||
buoyancyObject.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
buoyancyObject.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var sphereCollider = buoyancyObject.AddComponent<SphereCollider>();
|
||||
sphereCollider.radius = 1;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
@ -81,7 +82,7 @@ namespace NewHorizons.Builder.General
|
||||
detectorGO.SetActive(false);
|
||||
detectorGO.transform.parent = planetGO.transform;
|
||||
detectorGO.transform.localPosition = Vector3.zero;
|
||||
detectorGO.layer = LayerMask.NameToLayer("BasicDetector");
|
||||
detectorGO.layer = LayerUtilities.BasicDetector;
|
||||
|
||||
ConstantForceDetector forceDetector = detectorGO.AddComponent<ConstantForceDetector>();
|
||||
forceDetector._inheritElement0 = true;
|
||||
@ -90,7 +91,7 @@ namespace NewHorizons.Builder.General
|
||||
// For falling into sun
|
||||
if (!config.Base.invulnerableToSun && config.Star == null && config.FocalPoint == null)
|
||||
{
|
||||
detectorGO.layer = LayerMask.NameToLayer("AdvancedDetector");
|
||||
detectorGO.layer = LayerUtilities.AdvancedDetector;
|
||||
|
||||
var fluidDetector = detectorGO.AddComponent<DynamicFluidDetector>();
|
||||
var sphereCollider = detectorGO.AddComponent<SphereCollider>();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
namespace NewHorizons.Builder.General
|
||||
@ -23,7 +24,7 @@ namespace NewHorizons.Builder.General
|
||||
var gravityGO = new GameObject("GravityWell");
|
||||
gravityGO.transform.parent = planetGO.transform;
|
||||
gravityGO.transform.localPosition = Vector3.zero;
|
||||
gravityGO.layer = 17;
|
||||
gravityGO.layer = LayerUtilities.BasicEffectVolume;
|
||||
gravityGO.SetActive(false);
|
||||
|
||||
var SC = gravityGO.AddComponent<SphereCollider>();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
@ -12,7 +13,7 @@ namespace NewHorizons.Builder.General
|
||||
var rfGO = new GameObject("RFVolume");
|
||||
rfGO.transform.parent = planetGO.transform;
|
||||
rfGO.transform.localPosition = Vector3.zero;
|
||||
rfGO.layer = 19;
|
||||
rfGO.layer = LayerUtilities.ReferenceFrameVolume;
|
||||
rfGO.SetActive(false);
|
||||
|
||||
var SC = rfGO.AddComponent<SphereCollider>();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
@ -17,7 +18,7 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
GameObject spawnGO = new GameObject("PlayerSpawnPoint");
|
||||
spawnGO.transform.parent = planetGO.transform;
|
||||
spawnGO.layer = 8;
|
||||
spawnGO.layer = LayerUtilities.PlayerSafetyCollider;
|
||||
|
||||
spawnGO.transform.localPosition = module.playerSpawnPoint;
|
||||
|
||||
@ -39,7 +40,7 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
GameObject spawnGO = new GameObject("ShipSpawnPoint");
|
||||
spawnGO.transform.parent = planetGO.transform;
|
||||
spawnGO.layer = 8;
|
||||
spawnGO.layer = LayerUtilities.PlayerSafetyCollider;
|
||||
|
||||
spawnGO.transform.localPosition = module.shipSpawnPoint;
|
||||
|
||||
@ -70,7 +71,7 @@ namespace NewHorizons.Builder.General
|
||||
Logger.LogVerbose("Overriding player spawn to be inside ship");
|
||||
GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint");
|
||||
playerSpawnGO.transform.parent = ship.transform;
|
||||
playerSpawnGO.layer = 8;
|
||||
playerSpawnGO.layer = LayerUtilities.PlayerSafetyCollider;
|
||||
|
||||
playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0);
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
@ -103,7 +104,7 @@ namespace NewHorizons.Builder.Props
|
||||
var conversationZone = new GameObject("ConversationZone");
|
||||
conversationZone.SetActive(false);
|
||||
|
||||
conversationZone.layer = LayerMask.NameToLayer("Interactible");
|
||||
conversationZone.layer = LayerUtilities.Interactible;
|
||||
|
||||
var sphere = conversationZone.AddComponent<SphereCollider>();
|
||||
sphere.radius = info.radius;
|
||||
@ -259,7 +260,7 @@ namespace NewHorizons.Builder.Props
|
||||
var playerTrackingZone = new GameObject("PlayerTrackingZone");
|
||||
playerTrackingZone.SetActive(false);
|
||||
|
||||
playerTrackingZone.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
playerTrackingZone.layer = LayerUtilities.BasicEffectVolume;
|
||||
playerTrackingZone.SetActive(false);
|
||||
|
||||
var sphereCollider = playerTrackingZone.AddComponent<SphereCollider>();
|
||||
|
||||
@ -2,7 +2,7 @@ using HarmonyLib;
|
||||
using NewHorizons.Components.Quantum;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.UnityUtilities;
|
||||
using NewHorizons.Utility.Geometry;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.Linq;
|
||||
@ -86,7 +87,7 @@ namespace NewHorizons.Builder.Props
|
||||
if (_shareStonePrefab == null)
|
||||
{
|
||||
GameObject stone = new GameObject("ShareStoneFallback");
|
||||
stone.layer = LayerMask.NameToLayer("Interactible");
|
||||
stone.layer = LayerUtilities.Interactible;
|
||||
stone.SetActive(false);
|
||||
SphereCollider sc = stone.AddComponent<SphereCollider>();
|
||||
sc.center = Vector3.zero;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System.Collections.Generic;
|
||||
@ -130,7 +131,7 @@ namespace NewHorizons.Builder.Props
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) signalGO.transform.localPosition = pos;
|
||||
else signalGO.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||
signalGO.layer = LayerUtilities.AdvancedEffectVolume;
|
||||
|
||||
var source = signalGO.AddComponent<AudioSource>();
|
||||
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
using NewHorizons.Utility.UnityUtilities;
|
||||
using System.Collections;
|
||||
using NewHorizons.Utility.Geometry;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
public class NomaiTextArcArranger : MonoBehaviour {
|
||||
public class NomaiTextArcArranger : MonoBehaviour
|
||||
{
|
||||
private static int MAX_MOVE_DISTANCE = 2;
|
||||
|
||||
public List<SpiralManipulator> spirals = new List<SpiralManipulator>();
|
||||
@ -77,10 +76,10 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
// push away from the edges
|
||||
var MAX_EDGE_PUSH_FORCE = 1;
|
||||
force += new Vector2(0, -1) * Mathf.Max(0, (s1.transform.localPosition.y + maxY)*(MAX_EDGE_PUSH_FORCE / maxY) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(0, 1) * Mathf.Max(0, (s1.transform.localPosition.y + minY)*(MAX_EDGE_PUSH_FORCE / minY) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(-1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + maxX)*(MAX_EDGE_PUSH_FORCE / maxX) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + minX)*(MAX_EDGE_PUSH_FORCE / minX) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(0, -1) * Mathf.Max(0, (s1.transform.localPosition.y + maxY) * (MAX_EDGE_PUSH_FORCE / maxY) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(0, 1) * Mathf.Max(0, (s1.transform.localPosition.y + minY) * (MAX_EDGE_PUSH_FORCE / minY) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(-1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + maxX) * (MAX_EDGE_PUSH_FORCE / maxX) - MAX_EDGE_PUSH_FORCE);
|
||||
force += new Vector2(1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + minX) * (MAX_EDGE_PUSH_FORCE / minX) - MAX_EDGE_PUSH_FORCE);
|
||||
|
||||
// push up just to make everything a little more pretty (this is not neccessary to get an arrangement that simply has no overlap/spirals exiting the bounds)
|
||||
force += new Vector2(0, 1) * 1;
|
||||
@ -88,7 +87,7 @@ namespace NewHorizons.Builder.Props
|
||||
// renormalize the force magnitude (keeps force sizes reasonable, and improves stability in the case of small forces)
|
||||
var avg = 1; // the size of vector required to get a medium push
|
||||
var scale = 0.75f;
|
||||
force = force.normalized * scale * (1 / (1 + Mathf.Exp(avg-force.magnitude)) - 1 / (1 + Mathf.Exp(avg))); // apply a sigmoid-ish smoothing operation, so only giant forces actually move the spirals
|
||||
force = force.normalized * scale * (1 / (1 + Mathf.Exp(avg - force.magnitude)) - 1 / (1 + Mathf.Exp(avg))); // apply a sigmoid-ish smoothing operation, so only giant forces actually move the spirals
|
||||
|
||||
// if this is the root spiral, then rotate it instead of trying to move it
|
||||
if (s1.parent == null)
|
||||
@ -96,7 +95,7 @@ namespace NewHorizons.Builder.Props
|
||||
// this is the root spiral, so rotate instead of moving
|
||||
var finalAngle = Mathf.Atan2(force.y, force.x); // root spiral is always at 0, 0
|
||||
var currentAngle = Mathf.Atan2(s1.center.y, s1.center.x); // root spiral is always at 0, 0
|
||||
s1.transform.localEulerAngles = new Vector3(0, 0, finalAngle-currentAngle);
|
||||
s1.transform.localEulerAngles = new Vector3(0, 0, finalAngle - currentAngle);
|
||||
s1.UpdateChildren();
|
||||
|
||||
continue;
|
||||
@ -118,7 +117,8 @@ namespace NewHorizons.Builder.Props
|
||||
point = spiral.parent.transform.TransformPoint(point);
|
||||
|
||||
var dist = Vector2.Distance(point, idealPoint);
|
||||
if (dist < bestPointDistance) {
|
||||
if (dist < bestPointDistance)
|
||||
{
|
||||
bestPointDistance = dist;
|
||||
bestPointIndex = j;
|
||||
}
|
||||
@ -165,12 +165,12 @@ namespace NewHorizons.Builder.Props
|
||||
Queue<SpiralManipulator> frontierQueue = new Queue<SpiralManipulator>();
|
||||
frontierQueue.Enqueue(root);
|
||||
|
||||
while(frontierQueue.Count > 0)
|
||||
while (frontierQueue.Count > 0)
|
||||
{
|
||||
var spiral = frontierQueue.Dequeue();
|
||||
reverseToposortedSpirals.Add(spiral);
|
||||
|
||||
foreach(var child in spiral.children) frontierQueue.Enqueue(child);
|
||||
foreach (var child in spiral.children) frontierQueue.Enqueue(child);
|
||||
}
|
||||
|
||||
reverseToposortedSpirals.Reverse();
|
||||
@ -208,7 +208,7 @@ namespace NewHorizons.Builder.Props
|
||||
foreach (var s2 in spirals)
|
||||
{
|
||||
jndex++;
|
||||
if (SpiralsOverlap(s1, s2)) return new Vector2Int(index, jndex);;
|
||||
if (SpiralsOverlap(s1, s2)) return new Vector2Int(index, jndex); ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,11 +229,11 @@ namespace NewHorizons.Builder.Props
|
||||
if (s1.parent == s2) s1Points.RemoveAt(0); // don't consider the base points so that we can check if children overlap their parents
|
||||
if (s2.parent == s1) s2Points.RemoveAt(0); // (note: the base point of a child is always exactly overlapping with one of the parent's points)
|
||||
|
||||
foreach(var p1 in s1Points)
|
||||
foreach (var p1 in s1Points)
|
||||
{
|
||||
foreach(var p2 in s2Points)
|
||||
foreach (var p2 in s2Points)
|
||||
{
|
||||
if (Vector3.SqrMagnitude(p1-p2) <= thresholdForOverlap) return true; // s1 and s2 overlap
|
||||
if (Vector3.SqrMagnitude(p1 - p2) <= thresholdForOverlap) return true; // s1 and s2 overlap
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +251,8 @@ namespace NewHorizons.Builder.Props
|
||||
.Select(p => spiral.transform.parent.InverseTransformPoint(p))
|
||||
.ToList();
|
||||
|
||||
foreach(var point in points) {
|
||||
foreach (var point in points)
|
||||
{
|
||||
if (point.x < minX || point.x > maxX ||
|
||||
point.y < minY || point.y > maxY)
|
||||
{
|
||||
@ -264,19 +265,19 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
private bool AttemptToPushSpiralInBounds(SpiralManipulator s1, int start)
|
||||
{
|
||||
var range = Mathf.Max(start-SpiralManipulator.MIN_PARENT_POINT, SpiralManipulator.MAX_PARENT_POINT-start);
|
||||
var range = Mathf.Max(start - SpiralManipulator.MIN_PARENT_POINT, SpiralManipulator.MAX_PARENT_POINT - start);
|
||||
|
||||
for (var i = 1; i <= range; i++)
|
||||
{
|
||||
if (start-i >= SpiralManipulator.MIN_PARENT_POINT)
|
||||
if (start - i >= SpiralManipulator.MIN_PARENT_POINT)
|
||||
{
|
||||
s1.PlaceOnParentPoint(start-i);
|
||||
s1.PlaceOnParentPoint(start - i);
|
||||
if (!OutsideBounds(s1)) return true;
|
||||
}
|
||||
|
||||
if (start+i <= SpiralManipulator.MAX_PARENT_POINT)
|
||||
if (start + i <= SpiralManipulator.MAX_PARENT_POINT)
|
||||
{
|
||||
s1.PlaceOnParentPoint(start+i);
|
||||
s1.PlaceOnParentPoint(start + i);
|
||||
if (!OutsideBounds(s1)) return true;
|
||||
}
|
||||
}
|
||||
@ -296,7 +297,8 @@ namespace NewHorizons.Builder.Props
|
||||
#endregion bounds handling
|
||||
}
|
||||
|
||||
public class SpiralManipulator : MonoBehaviour {
|
||||
public class SpiralManipulator : MonoBehaviour
|
||||
{
|
||||
public SpiralManipulator parent;
|
||||
public List<SpiralManipulator> children = new List<SpiralManipulator>();
|
||||
|
||||
@ -336,7 +338,8 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
#endregion properties
|
||||
|
||||
public SpiralManipulator AddChild(NomaiTextArcBuilder.SpiralProfile profile) {
|
||||
public SpiralManipulator AddChild(NomaiTextArcBuilder.SpiralProfile profile)
|
||||
{
|
||||
var child = NomaiTextArcArranger.CreateSpiral(profile, this.transform.parent.gameObject);
|
||||
|
||||
var index = Random.Range(MIN_PARENT_POINT, MAX_PARENT_POINT);
|
||||
@ -356,17 +359,17 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
public void UpdateChildren()
|
||||
{
|
||||
foreach(var child in this.children)
|
||||
foreach (var child in this.children)
|
||||
{
|
||||
child.PlaceOnParentPoint(child._parentPointIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public int PlaceOnParentPoint(int parentPointIndex, bool updateChildren=true)
|
||||
public int PlaceOnParentPoint(int parentPointIndex, bool updateChildren = true)
|
||||
{
|
||||
// validate
|
||||
var _points = parent.GetComponent<NomaiTextLine>().GetPoints();
|
||||
parentPointIndex = Mathf.Max(0, Mathf.Min(parentPointIndex, _points.Length-1));
|
||||
parentPointIndex = Mathf.Max(0, Mathf.Min(parentPointIndex, _points.Length - 1));
|
||||
|
||||
// track occupied points
|
||||
if (this._parentPointIndex != -1) parent.pointsOccupiedByChildren.Remove(this._parentPointIndex);
|
||||
@ -374,7 +377,7 @@ namespace NewHorizons.Builder.Props
|
||||
parent.pointsOccupiedByChildren.Add(parentPointIndex);
|
||||
|
||||
// calculate the normal
|
||||
var normal = _points[Mathf.Min(parentPointIndex+1, _points.Length-1)] - _points[Mathf.Max(parentPointIndex-1, 0)];
|
||||
var normal = _points[Mathf.Min(parentPointIndex + 1, _points.Length - 1)] - _points[Mathf.Max(parentPointIndex - 1, 0)];
|
||||
if (parent.transform.localScale.x < 0) normal = new Vector3(normal.x, -normal.y, -normal.z);
|
||||
float rot = Mathf.Atan2(normal.y, normal.x) * Mathf.Rad2Deg;
|
||||
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using NewHorizons.Utility.Geometry;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using Newtonsoft.Json;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using UnityEngine;
|
||||
using Enum = System.Enum;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using Random = UnityEngine.Random;
|
||||
using OWML.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.UnityUtilities;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.Components.Achievement;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
@ -122,7 +123,7 @@ namespace NewHorizons.Builder.ShipLog
|
||||
|
||||
private static void MakeObservable(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod)
|
||||
{
|
||||
go.layer = LayerMask.NameToLayer("Interactible");
|
||||
go.layer = LayerUtilities.Interactible;
|
||||
|
||||
var sphere = go.AddComponent<SphereCollider>();
|
||||
sphere.radius = info.radius;
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.StarSystem
|
||||
{
|
||||
public static class SkyboxBuilder
|
||||
{
|
||||
private static readonly int _skyboxLayer = LayerMask.NameToLayer("Skybox");
|
||||
private static readonly Shader _unlitShader = Shader.Find("Unlit/Texture");
|
||||
|
||||
public static void Make(StarSystemConfig.SkyboxModule module, IModBehaviour mod)
|
||||
@ -33,7 +33,7 @@ namespace NewHorizons.Builder.StarSystem
|
||||
|
||||
var skySphere = new GameObject("Sky Sphere");
|
||||
skySphere.transform.SetParent(skybox.transform, false);
|
||||
skySphere.layer = _skyboxLayer;
|
||||
skySphere.layer = LayerUtilities.Skybox;
|
||||
skySphere.transform.localScale = Vector3.one * 5f;
|
||||
|
||||
BuildSkySphereFace(skySphere, "Right", Quaternion.Euler(0f, 90f, 0f), mesh, rightTex);
|
||||
@ -56,7 +56,7 @@ namespace NewHorizons.Builder.StarSystem
|
||||
|
||||
var go = new GameObject(name)
|
||||
{
|
||||
layer = _skyboxLayer
|
||||
layer = LayerUtilities.Skybox
|
||||
};
|
||||
|
||||
var mf = go.AddComponent<MeshFilter>();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
@ -42,7 +43,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
go.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||
go.layer = LayerUtilities.AdvancedEffectVolume;
|
||||
|
||||
var audioSource = go.AddComponent<AudioSource>();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
@ -39,7 +40,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
go.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var shape = go.AddComponent<SphereShape>();
|
||||
shape.radius = info.radius;
|
||||
@ -74,7 +75,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var detectorGO = new GameObject("ConstantFluidDetector");
|
||||
detectorGO.transform.parent = go.transform;
|
||||
detectorGO.transform.localPosition = Vector3.zero;
|
||||
detectorGO.layer = LayerMask.NameToLayer("BasicDetector");
|
||||
detectorGO.layer = LayerUtilities.BasicDetector;
|
||||
var detector = detectorGO.AddComponent<ConstantFluidDetector>();
|
||||
detector._onlyDetectableFluid = water;
|
||||
detector._buoyancy.boundingRadius = 1;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -42,7 +43,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
go.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var shape = go.AddComponent<SphereShape>();
|
||||
shape.radius = info.radius;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
@ -35,7 +36,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
go.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var collider = go.AddComponent<SphereCollider>();
|
||||
collider.isTrigger = true;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
@ -35,7 +36,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
||||
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
go.layer = LayerUtilities.BasicEffectVolume;
|
||||
|
||||
var shape = go.AddComponent<SphereShape>();
|
||||
shape.radius = info.radius;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NewHorizons.OtherMods.AchievementsPlus;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -20,7 +21,7 @@ namespace NewHorizons.Components.Achievement
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
gameObject.layer = LayerMask.NameToLayer("Interactible");
|
||||
gameObject.layer = LayerUtilities.Interactible;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components;
|
||||
@ -38,7 +39,7 @@ public class AddPhysics : MonoBehaviour
|
||||
var owRigidbody = bodyGo.AddComponent<OWRigidbody>();
|
||||
owRigidbody._simulateInSector = Sector;
|
||||
|
||||
bodyGo.layer = LayerMask.NameToLayer("PhysicalDetector");
|
||||
bodyGo.layer = LayerUtilities.PhysicalDetector;
|
||||
bodyGo.tag = "DynamicPropDetector";
|
||||
// this collider is not included in groups. oh well
|
||||
bodyGo.AddComponent<SphereCollider>().radius = Radius;
|
||||
|
||||
@ -16,6 +16,8 @@ using NewHorizons.OtherMods.VoiceActing;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.DebugMenu;
|
||||
using NewHorizons.Utility.DebugUtilities;
|
||||
using NewHorizons.Utility.OWMLUtilities;
|
||||
using NewHorizons.Utility.OWUtilities;
|
||||
using OWML.Common;
|
||||
using OWML.ModHelper;
|
||||
using OWML.Utils;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility.UnityUtilities;
|
||||
using NewHorizons.Utility.Geometry;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@ -80,13 +78,13 @@ namespace NewHorizons.Utility.DebugUtilities
|
||||
var normText = Vector3ToString(data.norm);
|
||||
var rotText = Vector3ToString(data.rot.eulerAngles);
|
||||
|
||||
if(_surfaceSphere != null) GameObject.Destroy(_surfaceSphere);
|
||||
if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
|
||||
if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
|
||||
if(_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere );
|
||||
if(_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere );
|
||||
if(_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere );
|
||||
if(_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere);
|
||||
if (_surfaceSphere != null) GameObject.Destroy(_surfaceSphere);
|
||||
if (_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
|
||||
if (_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
|
||||
if (_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere);
|
||||
if (_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere);
|
||||
if (_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere);
|
||||
if (_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere);
|
||||
|
||||
_surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green);
|
||||
_normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red);
|
||||
@ -100,17 +98,17 @@ namespace NewHorizons.Utility.DebugUtilities
|
||||
var planeSize = 0.5f;
|
||||
var planePointSize = 0.05f;
|
||||
_planeUpRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.green);
|
||||
_planeUpLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan) ;
|
||||
_planeDownLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.blue) ;
|
||||
_planeDownRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan) ;
|
||||
_planeUpLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan);
|
||||
_planeDownLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.blue);
|
||||
_planeDownRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan);
|
||||
|
||||
_planeUpRightSphere .transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*1*planeSize;
|
||||
_planeUpLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*1*planeSize;
|
||||
_planeDownLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*-1*planeSize;
|
||||
_planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*-1*planeSize;
|
||||
_planeUpRightSphere.transform.localPosition = data.plane.origin + data.plane.u * 1 * planeSize + data.plane.v * 1 * planeSize;
|
||||
_planeUpLeftSphere.transform.localPosition = data.plane.origin + data.plane.u * -1 * planeSize + data.plane.v * 1 * planeSize;
|
||||
_planeDownLeftSphere.transform.localPosition = data.plane.origin + data.plane.u * -1 * planeSize + data.plane.v * -1 * planeSize;
|
||||
_planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u * 1 * planeSize + data.plane.v * -1 * planeSize;
|
||||
|
||||
Logger.Log($"Raycast hit\n\n\"position\": {posText},\n\"rotation\": {rotText},\n\"normal\": {normText}\n\non collider [{data.colliderPath}] " +
|
||||
(data.bodyPath != null? $"at rigidbody [{data.bodyPath}]" : "not attached to a rigidbody"));
|
||||
(data.bodyPath != null ? $"at rigidbody [{data.bodyPath}]" : "not attached to a rigidbody"));
|
||||
}
|
||||
internal DebugRaycastData Raycast()
|
||||
{
|
||||
@ -163,10 +161,10 @@ namespace NewHorizons.Utility.DebugUtilities
|
||||
|
||||
// stackoverflow.com/a/9605695
|
||||
// I don't know exactly how this works, but I'm projecting a point that is located above the plane's origin, relative to the planet, onto the plane. this gets us our v vector
|
||||
var q = (2*U)-R;
|
||||
var q = (2 * U) - R;
|
||||
var dist = Vector3.Dot(N, q);
|
||||
var v_raw = 2*U - dist*N;
|
||||
var v = (R-v_raw).normalized;
|
||||
var v_raw = 2 * U - dist * N;
|
||||
var v = (R - v_raw).normalized;
|
||||
|
||||
var u = Vector3.Cross(N, v);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Utility.UnityUtilities
|
||||
namespace NewHorizons.Utility.Geometry
|
||||
{
|
||||
public static class AddDebugShape
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user