Ejemplo n.º 1
0
        static bool Prefix(Gravsphere __instance, Collider collider)
        {
            float range   = __instance.GetComponent <GravTrapMK2.Tag>()? Main.config.mk2Range: 17f;
            float distSqr = (__instance.transform.position - collider.transform.position).sqrMagnitude;                                                                     $"Gravsphere_OnTriggerExit_Patch: object: {collider.name} distance: {Mathf.Sqrt(distSqr)}".logDbg();

            return(distSqr > range * range);
        }
Ejemplo n.º 2
0
        static void Gravsphere_DestroyEffect_Postfix(Gravsphere __instance, int index)
        {
            var rigidBody = __instance.attractableList[index];

            if (rigidBody)
            {
                __instance.GetComponent <GravTrapObjectsType>().handleAttracted(rigidBody.gameObject, false);
            }
        }
        public void InitialiseFromExisting(Gravsphere G)
        {
            this.mainCollider           = G.mainCollider;
            this.mainCollider.isTrigger = true;

            this.trigger = G.trigger;
            if (this.trigger is SphereCollider s)
            {
                s.radius = magnetRadius;
            }
        }
Ejemplo n.º 4
0
        public static void updateRange(Gravsphere gravsphere)
        {
            if (!gravsphere.GetComponent <GravTrapMK2.Tag>())
            {
                return;
            }

            if (gravsphere.gameObject.GetComponents <SphereCollider>()?.FirstOrDefault(s => s.radius > 10) is SphereCollider sphere)
            {
                sphere.radius = Main.config.mk2Range;
            }
        }
Ejemplo n.º 5
0
        internal static void PostStart(Gravsphere __instance)
        {
            var obj = __instance.gameObject;

            var ping = __instance.gameObject.EnsureComponent <PingInstance>();

            ping.pingType = PingType.Signal; // u can make one with SML
            ping.origin   = obj.transform;
            ping.SetLabel("GravTrap");

            // Gravtraps default to the Near celllevel, so if we want the ping to be visible from a distance greater than 50m, we need to change that.
            var lwe = __instance.gameObject.EnsureComponent <LargeWorldEntity>();

            lwe.cellLevel        = Main.GravCellLevel;
            lwe.initialCellLevel = Main.GravCellLevel;
        }
Ejemplo n.º 6
0
 static void patchMaxRadius(Gravsphere __instance)
 {
     updateRange(__instance);
 }
Ejemplo n.º 7
0
 static bool Gravsphere_IsValidTarget_Prefix(Gravsphere __instance, GameObject obj, ref bool __result)
 {
     __result = __instance.GetComponent <GravTrapObjectsType>().isValidTarget(obj);
     return(false);
 }
Ejemplo n.º 8
0
 static void Gravsphere_AddAttractable_Postfix(Gravsphere __instance, Rigidbody r)
 {
     $"Gravsphere.AddAttractable: {r.gameObject.name} mass: {r.mass}".logDbg();
     __instance.GetComponent <GravTrapObjectsType>().handleAttracted(r.gameObject, true);
 }
Ejemplo n.º 9
0
 static void Gravsphere_Start_Postfix(Gravsphere __instance)
 {
     __instance.gameObject.ensureComponent <GravTrapObjectsType>();
 }
Ejemplo n.º 10
0
 static void Postfix(Gravsphere __instance, Rigidbody r) =>
 __instance.GetComponent <GravTrapObjectsType>().handleAttracted(r.gameObject, true);
Ejemplo n.º 11
0
 static void Postfix(Gravsphere __instance) => __instance.gameObject.ensureComponent <GravTrapObjectsType>();
Ejemplo n.º 12
0
 static void Postfix(Gravsphere __instance) => __instance.effects.ForEach(ray => ray.Value.enabled = false);
Ejemplo n.º 13
0
 static void Postfix(Gravsphere __instance) =>
 __instance.gameObject.GetComponent <LargeWorldEntity>().cellLevel = Main.config._changeTrapCellLevel;