Skip to content

Commit

Permalink
Merge pull request #507 from ExtendRealityLtd/feat/more-features
Browse files Browse the repository at this point in the history
Feat/more features
  • Loading branch information
thestonefox authored Jul 11, 2020
2 parents e2ca087 + 98ae181 commit dcead0d
Show file tree
Hide file tree
Showing 169 changed files with 2,634 additions and 332 deletions.
4 changes: 4 additions & 0 deletions Editor/Data/Attribute/MinMaxRangeAttributeDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
{
Undo.RecordObject(property.serializedObject.targetObject, property.displayName);
property.SetValue(new FloatRange(output));
if (property.isInstantiatedPrefab)
{
PrefabUtility.RecordPrefabInstancePropertyModifications(property.serializedObject.targetObject);
}
}

foundGeneric = true;
Expand Down
30 changes: 28 additions & 2 deletions Runtime/Action/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Data.Attribute;
using Zinnia.Data.Type;

/// <summary>
Expand Down Expand Up @@ -65,7 +66,11 @@ protected set
/// </summary>
public abstract void EmitActivationState();
/// <summary>
/// Makes the action receive its own default value.
/// Makes the action receive its own initial value to reset it back to when it was first created.
/// </summary>
public abstract void ReceiveInitialValue();
/// <summary>
/// Makes the action receive its own default value to set it back to inactive.
/// </summary>
public abstract void ReceiveDefaultValue();

Expand All @@ -88,7 +93,13 @@ protected virtual bool CanEmit()
public abstract class Action<TSelf, TValue, TEvent> : Action where TSelf : Action<TSelf, TValue, TEvent> where TEvent : UnityEvent<TValue>, new()
{
/// <summary>
/// The initial value of the action.
/// The initial value upon creation of the component.
/// </summary>
[Serialized]
[field: DocumentedByXml, Restricted(RestrictedAttribute.Restrictions.ReadOnlyAtRunTime)]
public TValue InitialValue { get; protected set; }
/// <summary>
/// The value that is considered the inactive value.
/// </summary>
[Serialized]
[field: DocumentedByXml]
Expand Down Expand Up @@ -180,6 +191,13 @@ public override void EmitActivationState()
}
}

/// <inheritdoc />
[RequiresBehaviourState]
public override void ReceiveInitialValue()
{
Receive(InitialValue);
}

/// <inheritdoc />
[RequiresBehaviourState]
public override void ReceiveDefaultValue()
Expand Down Expand Up @@ -213,6 +231,14 @@ protected virtual void OnEnable()
SubscribeToSources();
}

protected virtual void Start()
{
if (!IsValueEqual(InitialValue))
{
ProcessValue(InitialValue);
}
}

protected virtual void OnDisable()
{
ProcessValue(DefaultValue);
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Action/BooleanAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class BooleanAction : Action<BooleanAction, bool, BooleanAction.UnityEven
/// Defines the event with the <see cref="bool"/> state.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<bool>
{
}
public class UnityEvent : UnityEvent<bool> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Action/FloatAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public class FloatAction : Action<FloatAction, float, FloatAction.UnityEvent>
/// Defines the event with the <see cref="float"/> state.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<float>
{
}
public class UnityEvent : UnityEvent<float> { }

/// <summary>
/// The tolerance of equality between two <see cref="float"/> values.
Expand Down
29 changes: 28 additions & 1 deletion Runtime/Action/SurfaceChangeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,34 @@ public class SurfaceChangeAction : BooleanAction
protected SurfaceData previousData;

/// <summary>
/// Digests <see cref="SurfaceData"/> and compares the current surface to the previous surface to determine if a change has occured.
/// Sets the <see cref="CheckAxis"/> x value.
/// </summary>
/// <param name="value">The value to set to.</param>
public virtual void SetCheckAxisX(bool value)
{
CheckAxis = new Vector3State(value, CheckAxis.yState, CheckAxis.zState);
}

/// <summary>
/// Sets the <see cref="CheckAxis"/> y value.
/// </summary>
/// <param name="value">The value to set to.</param>
public virtual void SetCheckAxisY(bool value)
{
CheckAxis = new Vector3State(CheckAxis.xState, value, CheckAxis.zState);
}

/// <summary>
/// Sets the <see cref="CheckAxis"/> z value.
/// </summary>
/// <param name="value">The value to set to.</param>
public virtual void SetCheckAxisZ(bool value)
{
CheckAxis = new Vector3State(CheckAxis.xState, CheckAxis.yState, value);
}

/// <summary>
/// Digests <see cref="SurfaceData"/> and compares the current surface to the previous surface to determine if a change has occurred.
/// </summary>
/// <param name="surfaceData">The <see cref="SurfaceData"/> to check on.</param>
[RequiresBehaviourState]
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Action/Vector2Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public class Vector2Action : Action<Vector2Action, Vector2, Vector2Action.UnityE
/// Defines the event with the <see cref="Vector2"/> state.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Vector2>
{
}
public class UnityEvent : UnityEvent<Vector2> { }

/// <summary>
/// The tolerance of equality between two <see cref="Vector2"/> values.
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Action/Vector3Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public class Vector3Action : Action<Vector3Action, Vector3, Vector3Action.UnityE
/// Defines the event with the <see cref="Vector3"/> state.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Vector3>
{
}
public class UnityEvent : UnityEvent<Vector3> { }

/// <summary>
/// The tolerance of equality between two <see cref="Vector3"/> values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class GameObjectsAssociationObservableList : DefaultObservableList<GameOb
/// Defines the event with the <see cref="GameObjectsAssociation"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<GameObjectsAssociation>
{
}
public class UnityEvent : UnityEvent<GameObjectsAssociation> { }
}
}
18 changes: 18 additions & 0 deletions Runtime/Cast/ParabolicLineCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ public class ParabolicLineCast : PointsCast
/// </summary>
protected readonly List<Vector3> curvePoints = new List<Vector3>();

/// <summary>
/// Sets the <see cref="MaximumLength"/> x value.
/// </summary>
/// <param name="value">The value to set to.</param>
public virtual void SetMaximumLengthX(float value)
{
MaximumLength = new Vector2(value, MaximumLength.y);
}

/// <summary>
/// Sets the <see cref="MaximumLength"/> y value.
/// </summary>
/// <param name="value">The value to set to.</param>
public virtual void SetMaximumLengthY(float value)
{
MaximumLength = new Vector2(MaximumLength.x, value);
}

protected override void OnEnable()
{
base.OnEnable();
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Cast/PointsCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class EventData
public bool IsValid { get; set; }

/// <summary>
/// The points along the the most recent cast.
/// The points along the most recent cast.
/// </summary>
public HeapAllocationFreeReadOnlyList<Vector3> Points { get; set; }

Expand Down Expand Up @@ -108,12 +108,12 @@ public class UnityEvent : UnityEvent<EventData> { }
/// </summary>
public bool IsTargetHitValid { get; protected set; }
/// <summary>
/// The points along the the most recent cast.
/// The points along the most recent cast.
/// </summary>
public HeapAllocationFreeReadOnlyList<Vector3> Points => points;

/// <summary>
/// The points along the the most recent cast.
/// The points along the most recent cast.
/// </summary>
protected readonly List<Vector3> points = new List<Vector3>();
/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Data/Attribute/UnityFlagsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
/// <summary>
/// Defines the <c>[UnityFlags]</c> attribute.
/// </summary>
public class UnityFlagsAttribute : PropertyAttribute
{
}
public class UnityFlagsAttribute : PropertyAttribute { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class GameObjectObservableCounter : ObservableCounter<GameObject, GameObj
/// Defines the event with the <see cref="GameObject"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<GameObject>
{
}
public class UnityEvent : UnityEvent<GameObject> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/GameObjectRelations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public class GameObjectRelations : MonoBehaviour
/// Defines the event for the output <see cref="GameObject"/>.
/// </summary>
[Serializable]
public class GameObjectUnityEvent : UnityEvent<GameObject>
{
}
public class GameObjectUnityEvent : UnityEvent<GameObject> { }

/// <summary>
/// The collection of relations.
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/BehaviourObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class BehaviourObservableList : DefaultObservableList<Behaviour, Behaviou
/// Defines the event with the <see cref="Behaviour"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Behaviour>
{
}
public class UnityEvent : UnityEvent<Behaviour> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/CameraObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class CameraObservableList : DefaultObservableList<Camera, CameraObservab
/// Defines the event with the <see cref="Camera"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Camera>
{
}
public class UnityEvent : UnityEvent<Camera> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/FloatObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class FloatObservableList : DefaultObservableList<float, FloatObservableL
/// Defines the event with the <see cref="float"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<float>
{
}
public class UnityEvent : UnityEvent<float> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/GameObjectObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class GameObjectObservableList : DefaultObservableList<GameObject, GameOb
/// Defines the event with the <see cref="GameObject"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<GameObject>
{
}
public class UnityEvent : UnityEvent<GameObject> { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class Relation
/// Defines the event with the <see cref="Relation"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Relation>
{
}
public class UnityEvent : UnityEvent<Relation> { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class SerializableTypeBehaviourObservableList : ObservableList<Serializab
/// Defines the event with the <see cref="SerializableType"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<SerializableType>
{
}
public class UnityEvent : UnityEvent<SerializableType> { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class SerializableTypeComponentObservableList : ObservableList<Serializab
/// Defines the event with the <see cref="SerializableType"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<SerializableType>
{
}
public class UnityEvent : UnityEvent<SerializableType> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/StringObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class StringObservableList : DefaultObservableList<string, StringObservab
/// Defines the event with the <see cref="string"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<string>
{
}
public class UnityEvent : UnityEvent<string> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/UnityObjectObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class UnityObjectObservableList : DefaultObservableList<Object, UnityObje
/// Defines the event with the <see cref="Object"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Object>
{
}
public class UnityEvent : UnityEvent<Object> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/Vector2ObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class Vector2ObservableList : DefaultObservableList<Vector2, Vector2Obser
/// Defines the event with the <see cref="Vector2"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Vector2>
{
}
public class UnityEvent : UnityEvent<Vector2> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/List/Vector3ObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class Vector3ObservableList : DefaultObservableList<Vector3, Vector3Obser
/// Defines the event with the <see cref="Vector3"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<Vector3>
{
}
public class UnityEvent : UnityEvent<Vector3> { }
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Collection/Stack/GameObjectObservableStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public class GameObjectElementEvents : ObservableStackElementEvents<GameObject,
/// Defines the event with the <see cref="GameObject"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<GameObject>
{
}
public class UnityEvent : UnityEvent<GameObject> { }
}
}
}
4 changes: 1 addition & 3 deletions Runtime/Data/Operation/Cache/FloatCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public class FloatCache : ValueCache<float, FloatCache.UnityEvent>
/// Defines the event with the specified <see cref="float"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<float>
{
}
public class UnityEvent : UnityEvent<float> { }

/// <summary>
/// The tolerance to consider the current value and the cached value equal.
Expand Down
4 changes: 1 addition & 3 deletions Runtime/Data/Operation/Cache/GameObjectCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class GameObjectCache : ValueCache<GameObject, GameObjectCache.UnityEvent
/// Defines the event with the specified <see cref="GameObject"/>.
/// </summary>
[Serializable]
public class UnityEvent : UnityEvent<GameObject>
{
}
public class UnityEvent : UnityEvent<GameObject> { }
}
}
Loading

0 comments on commit dcead0d

Please sign in to comment.