new-horizons/NewHorizons/General/SectorBuilder.cs
Nick J. Connors c977cb5333 Decluttered logs and added asteroid belts
Also includes some basic proc gen
2021-12-19 02:37:52 -05:00

38 lines
1.1 KiB
C#

using NewHorizons.External;
using OWML.Utils;
using System.Collections.Generic;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Body
{
static class MakeSector
{
public static Sector Make(GameObject body, OWRigidbody rigidbody, float sphereOfInfluence)
{
GameObject sectorGO = new GameObject("Sector");
sectorGO.SetActive(false);
sectorGO.transform.parent = body.transform;
SphereShape SS = sectorGO.AddComponent<SphereShape>();
SS.SetCollisionMode(Shape.CollisionMode.Volume);
SS.SetLayer(Shape.Layer.Sector);
SS.layerMask = -1;
SS.pointChecksOnly = true;
SS.radius = sphereOfInfluence + 10;
SS.center = Vector3.zero;
sectorGO.AddComponent<OWTriggerVolume>();
Sector S = sectorGO.AddComponent<Sector>();
S.SetValue("_name", Sector.Name.Unnamed);
S.SetValue("_attachedOWRigidbody", rigidbody);
S.SetValue("_subsectors", new List<Sector>());
sectorGO.SetActive(true);
return S;
}
}
}