-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from ExtendRealityLtd/more-features
More features
- Loading branch information
Showing
27 changed files
with
1,611 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
namespace Zinnia.Cast.Event.Proxy | ||
{ | ||
using System; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using Zinnia.Event.Proxy; | ||
using Zinnia.Extension; | ||
|
||
/// <summary> | ||
/// Emits a <see cref="UnityEvent"/> with a <see cref="PointsCast.EventData"/> payload whenever <see cref="SingleEventProxyEmitter{TValue,TEvent}.Receive"/> is called. | ||
/// </summary> | ||
public class PointsCastEventProxyEmitter : RestrictableSingleEventProxyEmitter<PointsCast.EventData, PointsCastEventProxyEmitter.UnityEvent> | ||
{ | ||
/// <summary> | ||
/// The types of <see cref="GameObject"/> that can be used for the rule source. | ||
/// </summary> | ||
public enum RuleSourceType | ||
{ | ||
/// <summary> | ||
/// Use the actual <see cref="Collider"/> hit as the source for the rule. | ||
/// </summary> | ||
Collider, | ||
/// <summary> | ||
/// Use the parent <see cref="Rigidbody"/> hit as the target for the rule. | ||
/// </summary> | ||
Rigidbody | ||
} | ||
|
||
[Tooltip("The source GameObject to apply to the RestrictableSingleEventProxyEmitter.ReceiveValidity.")] | ||
[SerializeField] | ||
private RuleSourceType ruleSource; | ||
/// <summary> | ||
/// The source <see cref="GameObject"/> to apply to the <see cref="RestrictableSingleEventProxyEmitter.ReceiveValidity"/>. | ||
/// </summary> | ||
public RuleSourceType RuleSource | ||
{ | ||
get | ||
{ | ||
return ruleSource; | ||
} | ||
set | ||
{ | ||
ruleSource = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Defines the event with the specified state. | ||
/// </summary> | ||
[Serializable] | ||
public class UnityEvent : UnityEvent<PointsCast.EventData> { } | ||
|
||
/// <inheritdoc /> | ||
protected override object GetTargetToCheck() | ||
{ | ||
if (Payload == null || Payload.HitData == null) | ||
{ | ||
return null; | ||
} | ||
|
||
RaycastHit hitData = (RaycastHit)Payload.HitData; | ||
switch (RuleSource) | ||
{ | ||
case RuleSourceType.Collider: | ||
return hitData.collider.gameObject; | ||
case RuleSourceType.Rigidbody: | ||
return hitData.collider.GetContainingTransform().gameObject; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Cast/Event/Proxy/PointsCastEventProxyEmitter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.