| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | public class EntityListView : ListView<BIWEntity> |
| | 4 | | { |
| | 5 | | [SerializeField] internal EntityListAdapter entityListAdapter; |
| | 6 | | [SerializeField] internal DynamicScrollSensitivity dynamicScrollSensitivity; |
| | 7 | |
|
| | 8 | | public System.Action<EntityAction, BIWEntity, EntityListAdapter> OnActionInvoked; |
| | 9 | | public System.Action<BIWEntity, string> OnEntityRename; |
| | 10 | |
|
| 1 | 11 | | public bool isActive => gameObject.activeSelf; |
| | 12 | |
|
| | 13 | | public override void AddAdapters() |
| | 14 | | { |
| 0 | 15 | | base.AddAdapters(); |
| | 16 | |
|
| 0 | 17 | | foreach (BIWEntity entity in contentList) |
| | 18 | | { |
| 0 | 19 | | if (entity.isFloor) |
| | 20 | | continue; |
| 0 | 21 | | EntityListAdapter adapter = Instantiate(entityListAdapter, contentPanelTransform).GetComponent<EntityListAda |
| 0 | 22 | | adapter.SetContent(entity); |
| 0 | 23 | | adapter.OnActionInvoked += EntityActionInvoked; |
| 0 | 24 | | adapter.OnEntityRename += EntityRename; |
| | 25 | | } |
| | 26 | |
|
| 0 | 27 | | if (dynamicScrollSensitivity != null) |
| 0 | 28 | | dynamicScrollSensitivity.RecalculateSensitivity(); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | public override void RemoveAdapters() |
| | 32 | | { |
| 0 | 33 | | for (int i = 0; i < contentPanelTransform.transform.childCount; i++) |
| | 34 | | { |
| 0 | 35 | | EntityListAdapter toRemove = contentPanelTransform.transform.GetChild(i).gameObject.GetComponent<EntityListA |
| 0 | 36 | | if (toRemove != null) |
| | 37 | | { |
| 0 | 38 | | toRemove.OnActionInvoked -= EntityActionInvoked; |
| 0 | 39 | | toRemove.OnEntityRename -= EntityRename; |
| | 40 | | } |
| 0 | 41 | | Destroy(toRemove.gameObject); |
| | 42 | | } |
| | 43 | |
|
| 0 | 44 | | if (dynamicScrollSensitivity != null) |
| 0 | 45 | | dynamicScrollSensitivity.RecalculateSensitivity(); |
| 0 | 46 | | } |
| | 47 | |
|
| 0 | 48 | | public void EntityActionInvoked(EntityAction action, BIWEntity entityToApply, EntityListAdapter adapter) { OnActionI |
| | 49 | |
|
| 0 | 50 | | public void EntityRename(BIWEntity entity, string newName) { OnEntityRename?.Invoke(entity, newName); } |
| | 51 | |
|
| 0 | 52 | | public void SetActive(bool isActive) { gameObject.SetActive(isActive); } |
| | 53 | | } |