Esempio n. 1
0
        //DOOR
        public static bool Prefix(bool newOpen, InteractableDoor __instance, ref bool ____isOpen, ref Transform ___barrierTransform,
                                  ref BoxCollider ___placeholderCollider)
        {
            ____isOpen = newOpen;

            AudioSource r = __instance.GetComponent <AudioSource>();

            r.pitch = 1.25f;
            r.Play();

            ___barrierTransform.gameObject.SetActive(!newOpen);

            Animation x = __instance.GetComponent <Animation>();

            x["Open"].speed  = 2f;
            x["Close"].speed = 2f;

            if (newOpen)
            {
                x.Play("Open");
            }
            else
            {
                x.Play("Close");
            }

            return(false);
        }
Esempio n. 2
0
    /// <summary>
    /// Gets the closest door to worldOrigin on the path from worldOrigin to targetPos (if there is one)
    /// Assumes that
    /// </summary>
    /// <param name="worldOrigin">Origin World position to check from. This is required because e.g. Windoors may not appear closed from certain positions.</param>
    /// <param name="targetPos">target world position to check</param>
    /// <returns>The DoorTrigger of the closed door object specified in the summary, null if no such object
    /// exists at that location</returns>
    public static InteractableDoor GetClosedDoorAt(Vector3Int worldOrigin, Vector3Int targetPos, bool isServer)
    {
        // Check door on the local tile first
        Vector3Int       localTarget = Instance.WorldToLocalInt(targetPos, AtPoint(targetPos, isServer).Matrix);
        InteractableDoor originDoor  = Instance.GetFirst <InteractableDoor>(worldOrigin, isServer);

        if (originDoor && !originDoor.GetComponent <RegisterDoor>().IsPassableTo(localTarget, isServer))
        {
            return(originDoor);
        }

        // No closed door on local tile, check target tile
        Vector3Int       localOrigin = Instance.WorldToLocalInt(worldOrigin, AtPoint(worldOrigin, isServer).Matrix);
        InteractableDoor targetDoor  = Instance.GetFirst <InteractableDoor>(targetPos, isServer);

        if (targetDoor && !targetDoor.GetComponent <RegisterDoor>().IsPassable(localOrigin, isServer))
        {
            return(targetDoor);
        }

        // No closed doors on either tile
        return(null);
    }