| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public class StickersController : MonoBehaviour |
| | 6 | | { |
| | 7 | | private StickersFactory stickersFactory; |
| | 8 | | private bool isInHideArea; |
| | 9 | |
|
| 2022 | 10 | | private void Awake() { stickersFactory = Resources.Load<StickersFactory>("StickersFactory"); } |
| | 11 | |
|
| | 12 | | public void PlaySticker(string id) |
| | 13 | | { |
| 0 | 14 | | PlaySticker(id, transform.position, Vector3.zero, true); |
| 0 | 15 | | } |
| | 16 | |
|
| | 17 | | public void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform) |
| | 18 | | { |
| 19 | 19 | | if (stickersFactory == null || !stickersFactory.TryGet(id, out GameObject prefab) || isInHideArea) |
| 0 | 20 | | return; |
| | 21 | |
|
| | 22 | | // TODO(Brian): Mock this system properly through our service locators or plugin system |
| 19 | 23 | | if (DCL.Configuration.EnvironmentSettings.RUNNING_TESTS) |
| 19 | 24 | | return; |
| | 25 | |
|
| 0 | 26 | | GameObject emoteGameObject = Instantiate(prefab); |
| 0 | 27 | | emoteGameObject.transform.position += position; |
| 0 | 28 | | emoteGameObject.transform.rotation = Quaternion.Euler(prefab.transform.rotation.eulerAngles + direction); |
| | 29 | |
|
| 0 | 30 | | if (followTransform) |
| | 31 | | { |
| 0 | 32 | | FollowObject emoteFollow = emoteGameObject.AddComponent<FollowObject>(); |
| 0 | 33 | | emoteFollow.target = transform; |
| 0 | 34 | | emoteFollow.offset = prefab.transform.position; |
| | 35 | | } |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public void ToggleHideArea(bool entered) |
| | 39 | | { |
| 0 | 40 | | isInHideArea = entered; |
| 0 | 41 | | } |
| | 42 | | } |
| | 43 | | } |