JojikYT

InteractableLoot

Jan 26th, 2023
2,961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | Source Code | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class InteractableLoot : Interactable
  6. {
  7.     public override void Start()
  8.     {
  9.         base.Start();
  10.     }
  11.     protected override void Interaction()
  12.     {
  13.         base.Interaction();
  14.  
  15.         print("Unfortunately you can't take my loot yet.");
  16.         DisableCollider();
  17.         Destroy(this);
  18.  
  19.         //OpenLoot();
  20.     }
  21.     void OpenLoot()
  22.     {
  23.         //GetComponent<ItemContainer>().SetLoot();
  24.         //Events.ShowLoot(true);
  25.  
  26.         //Events.OnShowLoot += TriggerLoot;
  27.     }
  28.     void TriggerLoot(bool openLoot)
  29.     {
  30.         if (openLoot)
  31.         {
  32.             //GetComponent<ItemContainer>().SetLoot();
  33.             //Events.ShowLoot(true);
  34.         }
  35.         else
  36.         {
  37.             //GetComponent<ItemContainer>().ResetLoot();
  38.             //Events.OnShowLoot -= TriggerLoot;
  39.         }
  40.     }
  41.  
  42.     void DisableCollider()
  43.     {
  44.         if (TryGetComponent(out BoxCollider boxCollider))
  45.         {
  46.             boxCollider.enabled = false;
  47.         }
  48.         else if (TryGetComponent(out CapsuleCollider capsCollider))
  49.         {
  50.             capsCollider.enabled = false;
  51.         }
  52.         else
  53.         {
  54.             print("Error, no collider found!");
  55.         }
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment