party (#15)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Resolves #6.
Updates #3.

Co-authored-by: Branden J Brown <zephyrtronium@gmail.com>
Reviewed-on: #15
Reviewed-by: madxmike <madxmike@noreply.localhost>
This commit is contained in:
2023-08-07 11:34:42 -05:00
parent 81c1c0de0e
commit a67aee24aa
12 changed files with 266 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine;
[CreateAssetMenu(fileName = "HeroParty", menuName = "Hero Party")]
public class HeroPartySO : ScriptableObject
{
[SerializeField]
private List<HeroUnit> unitList = new List<HeroUnit>();
public ReadOnlyCollection<HeroUnit> UnitList => unitList.AsReadOnly();
public void Add(HeroUnit unit) { unitList.Add(unit); }
public void Remove(HeroUnit unit) { unitList.Remove(unit); }
public int Count => unitList.Count;
}

11
Assets/Scripts/HeroPartySO.cs.meta generated Normal file
View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0603cf6e7f1d884e89c3eb6a478a96c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,6 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("TestsPlaymode")]
/// <summary>
/// Component that makes a duder a duder.
@@ -13,4 +17,17 @@ public class HeroUnit : MonoBehaviour
[SerializeField] private long level;
[SerializeField] private long xp;
[SerializeField] private HeroAttributesSO attrs;
[SerializeField] private HeroPartySO _party;
internal HeroPartySO party => _party;
private void OnEnable()
{
Assert.IsNotNull(_party);
_party.Add(this);
}
private void OnDisable()
{
_party.Remove(this);
}
}