Exemple #1
0
        private static void Postfix(PlayerManager __instance, ref MeshLocationCategory __result)
        {
            GameObject gameObject = __instance.GetObjectToPlace();

            if (__result != MeshLocationCategory.Valid && Input.GetKey(KeyCode.L))
            {
                BetterPlacing.RestoreLastValidTransform(gameObject);
                __result = MeshLocationCategory.Valid;
            }

            if (__result == MeshLocationCategory.Valid)
            {
                BetterPlacing.StoreValidTransform(gameObject);

                if (Input.GetKey(KeyCode.P))
                {
                    BetterPlacing.SnapToPositionBelow(gameObject);
                }
            }

            if (Input.GetKey(KeyCode.R))
            {
                BetterPlacing.SnapToRotationBelow(gameObject);
            }

            float yAngle = GetRotation();

            if (yAngle != 0)
            {
                BetterPlacing.Rotate(gameObject, yAngle);
            }
        }
Exemple #2
0
        private static bool Prefix(BreakDown __instance, string text)
        {
            if (text == null || !BetterPlacing.IsPlacableFurniture(__instance))
            {
                return(true);
            }

            ModBreakDownSaveData saveData = Utils.DeserializeObject <ModBreakDownSaveData>(text);

            if (saveData.m_HasBeenBrokenDown)
            {
                return(true);
            }

            __instance.gameObject.SetActive(true);
            BetterPlacing.PreparePlacableFurniture(__instance.gameObject);

            GameObject root = BetterPlacing.getFurnitureRoot(__instance.gameObject);

            root.transform.position = saveData.m_Position;
            if (saveData.m_Rotation.x != 0 || saveData.m_Rotation.y != 0 || saveData.m_Rotation.z != 0)
            {
                root.transform.rotation = Quaternion.Euler(saveData.m_Rotation);
            }

            return(false);
        }
Exemple #3
0
 public static void Prefix(BreakDown __instance, GameObject go)
 {
     if (BetterPlacing.IsStackableGearItem(go))
     {
         BetterPlacing.AddGearItemsToPhysicalCollisionMask();
     }
 }
Exemple #4
0
        public static bool Prefix(BreakDown __instance, ref bool __result)
        {
            if (BetterPlacing.IsBlockedFromAbove(__instance.gameObject))
            {
                BetterPlacing.SignalItemBlocked();
                __result = false;
                return(false);
            }

            return(true);
        }
Exemple #5
0
        private static bool Prefix(GearItem pickupItem, ref bool __result)
        {
            if (BetterPlacing.IsBlockedFromAbove(pickupItem.gameObject))
            {
                BetterPlacing.SignalItemBlocked();
                __result = false;
                return(false);
            }

            return(true);
        }
Exemple #6
0
        public static void Prefix(PlayerManager __instance)
        {
            var gameObject = __instance.GetObjectToPlace();

            if (BetterPlacing.IsStackableGearItem(gameObject))
            {
                BetterPlacing.AddGearItemsToPhysicalCollisionMask();
            }
            else if (BetterPlacing.IsPlaceableFurniture(gameObject))
            {
                BetterPlacing.RemoveFurnitureFromPhysicalCollisionMask();
            }
        }
Exemple #7
0
        private static void Postfix(PlayerManager __instance, GameObject objectToPlace, bool __result)
        {
            if (__result)
            {
                BetterPlacing.InitializeRotation(__instance);

                if (BetterPlacing.IsStackableGearItem(objectToPlace))
                {
                    objectToPlace.layer = vp_Layer.NPC;
                }
                else if (BetterPlacing.IsPlaceableFurniture(objectToPlace))
                {
                    vp_Layer.Set(objectToPlace, vp_Layer.NPC, true);
                }
            }
        }
Exemple #8
0
        public static bool Prefix(PlayerManager __instance)
        {
            var gameObject = __instance.m_InteractiveObjectUnderCrosshair;

            if (BetterPlacing.IsPlaceableFurniture(gameObject))
            {
                BetterPlacing.PreparePlacableFurniture(gameObject);

                GameObject root = BetterPlacing.getFurnitureRoot(gameObject);
                __instance.StartPlaceMesh(root, 5f, PlaceMeshFlags.None);

                return(false);
            }

            return(true);
        }
Exemple #9
0
        public static bool Prefix(BreakDown __instance, ref string __result)
        {
            if (!BetterPlacing.IsPlacableFurniture(__instance))
            {
                return(true);
            }

            ModBreakDownSaveData saveData = new ModBreakDownSaveData();

            saveData.m_Position          = __instance.transform.position;
            saveData.m_Rotation          = __instance.transform.rotation.eulerAngles;
            saveData.m_HasBeenBrokenDown = !__instance.gameObject.activeSelf;
            saveData.m_Guid = Utils.GetGuidFromGameObject(__instance.gameObject);

            __result = Utils.SerializeObject(saveData);
            return(false);
        }
Exemple #10
0
        public static bool Prefix(PlayerManager __instance, ref Collider __result)
        {
            BetterPlacing.AddNpcToPhysicalCollisionMask();

            var gameObject = __instance.GetObjectToPlace();

            if (!BetterPlacing.IsPlaceableFurniture(gameObject))
            {
                return(true);
            }

            Collider[] colliders = gameObject.GetComponentsInChildren <Collider>();
            foreach (var eachCollider in colliders)
            {
                Collider[] otherColliders = Physics.OverlapSphere(eachCollider.bounds.center, eachCollider.bounds.size.magnitude / 2, 918016);
                foreach (var eachOtherCollider in otherColliders)
                {
                    if (!eachOtherCollider.gameObject.activeInHierarchy)
                    {
                        continue;
                    }

                    if (eachOtherCollider.transform.IsChildOf(gameObject.transform))
                    {
                        continue;
                    }

                    Vector3 direction;
                    float   distance;

                    if (Physics.ComputePenetration(eachCollider, eachCollider.transform.position, eachCollider.transform.rotation, eachOtherCollider, eachOtherCollider.transform.position, eachOtherCollider.transform.rotation, out direction, out distance))
                    {
                        __result = eachOtherCollider;
                        return(false);
                    }
                }
            }

            __result = null;
            return(false);
        }
Exemple #11
0
        private static bool Prefix(PlayerManager __instance, GameObject objectToPlace, ref bool __result)
        {
            if (BetterPlacing.IsBlockedFromAbove(objectToPlace))
            {
                BetterPlacing.SignalItemBlocked();
                __result = false;
                return(false);
            }

            CookingPotItem[] items = Object.FindObjectsOfType <CookingPotItem>();
            foreach (var eachItem in items)
            {
                if (eachItem.AttachedFireIsBurning())
                {
                    vp_Layer.Set(eachItem.gameObject, vp_Layer.NPC, true);
                }
            }

            InterfaceManager.m_Panel_ActionsRadial.DisableRadial(true);
            return(true);
        }
Exemple #12
0
        private static void Prefix(PlayerManager __instance)
        {
            var gameObject = __instance.GetObjectToPlace();

            if (BetterPlacing.IsStackableGearItem(gameObject))
            {
                BetterPlacing.RemoveGearItemsFromPhysicalCollisionMask();
            }
            else if (BetterPlacing.IsPlaceableFurniture(gameObject))
            {
                BetterPlacing.AddFurnitureToPhysicalCollisionMask();
                BetterPlacing.RestoreFurnitureLayers(gameObject);
            }

            CookingPotItem[] items = Object.FindObjectsOfType <CookingPotItem>();
            foreach (var eachItem in items)
            {
                vp_Layer.Set(eachItem.gameObject, vp_Layer.Gear, true);
            }

            InterfaceManager.m_Panel_ActionsRadial.DisableRadial(false);
        }
Exemple #13
0
 public static void Postfix()
 {
     BetterPlacing.RemoveGearItemsFromPhysicalCollisionMask();
 }
Exemple #14
0
 public static void Prefix()
 {
     BetterPlacing.AddGearItemsToPhysicalCollisionMask();
 }
Exemple #15
0
 public static void Postfix()
 {
     BetterPlacing.RemoveNpcFromPhysiclaCollisionMask();
 }
Exemple #16
0
 internal static void Postfix(Campfire __instance)
 {
     BetterPlacing.ChangeLayer(__instance.gameObject, vp_Layer.Gear, vp_Layer.NPC);
 }
Exemple #17
0
 public static void Prefix(GearItem gi)
 {
     BetterPlacing.FixBoxCollider(gi.gameObject);
     BetterPlacing.RemovePickupHelper(gi.gameObject);
 }