2018-10-30 15:05:06 -04:00
|
|
|
using UnityEngine;
|
2019-04-07 10:03:16 -04:00
|
|
|
using UnityEngine.Serialization;
|
2018-10-30 15:05:06 -04:00
|
|
|
|
|
|
|
namespace UnityAtoms
|
|
|
|
{
|
2019-10-15 14:44:25 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Base class for all SetVariableValue Actions. Inherits from `VoidAction`.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">The type of the Variable to set.</typeparam>
|
|
|
|
/// <typeparam name="V">A Variable class of type `type` to set.</typeparam>
|
2019-10-16 12:02:08 -04:00
|
|
|
/// <typeparam name="C">A Constant class of type `type` to set.</typeparam>
|
2019-10-15 14:44:25 -04:00
|
|
|
/// <typeparam name="R">A Reference of type `type`.</typeparam>
|
|
|
|
/// <typeparam name="E1">An Event of type `type`.</typeparam>
|
|
|
|
/// <typeparam name="E2">An Event x 2 of type `type`.</typeparam>
|
2020-02-16 06:44:46 -05:00
|
|
|
/// <typeparam name="F">A Function x 2 of type `type`.</typeparam>
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
/// <typeparam name="VI">A Variable Instancer of type `type`.</typeparam>
|
|
|
|
public abstract class SetVariableValue<T, V, C, R, E1, E2, F, VI> : VoidAction
|
2019-09-25 15:05:06 -04:00
|
|
|
where E1 : AtomEvent<T>
|
|
|
|
where E2 : AtomEvent<T, T>
|
2020-02-16 06:44:46 -05:00
|
|
|
where F : AtomFunction<T, T>
|
|
|
|
where V : AtomVariable<T, E1, E2, F>
|
2019-10-16 12:02:08 -04:00
|
|
|
where C : AtomBaseVariable<T>
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
where R : AtomReference<T, C, V, E1, E2, F, VI>
|
|
|
|
where VI : AtomVariableInstancer<V, T, E1, E2, F>
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-10-15 14:44:25 -04:00
|
|
|
/// <summary>
|
|
|
|
/// The Variable to set.
|
|
|
|
/// </summary>
|
2018-10-30 15:05:06 -04:00
|
|
|
[SerializeField]
|
2019-04-08 10:14:50 -04:00
|
|
|
private V _variable = null;
|
2018-10-30 15:05:06 -04:00
|
|
|
|
2019-10-15 14:44:25 -04:00
|
|
|
/// <summary>
|
|
|
|
/// The value to set.
|
|
|
|
/// </summary>
|
2018-10-30 15:05:06 -04:00
|
|
|
[SerializeField]
|
2019-04-08 10:14:50 -04:00
|
|
|
private R _value = null;
|
2018-10-30 15:05:06 -04:00
|
|
|
|
2019-10-15 14:44:25 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Perform the action.
|
|
|
|
/// </summary>
|
2018-10-30 15:05:06 -04:00
|
|
|
public override void Do()
|
|
|
|
{
|
2019-04-07 10:03:16 -04:00
|
|
|
_variable.Value = _value.Value;
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
}
|
2019-03-17 18:43:20 -04:00
|
|
|
}
|