-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teleport condition TRNG-102 #40
Changes from 1 commit
0dae7a4
fb4a478
0614d6f
adcc2fc
b08d3fb
2c58f16
f33768e
f133f3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Innoactive.Creator.Core.Conditions; | ||
using Innoactive.CreatorEditor.UI.StepInspector.Menu; | ||
|
||
namespace Innoactive.CreatorEditor.UI.Conditions | ||
{ | ||
/// <inheritdoc /> | ||
public class TeleportMenuItem : MenuItem<ICondition> | ||
{ | ||
/// <inheritdoc /> | ||
public override string DisplayedName { get; } = "Teleport"; | ||
|
||
/// <inheritdoc /> | ||
public override ICondition GetNewItem() | ||
{ | ||
return new TeleportCondition(); | ||
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System.Runtime.Serialization; | ||
using Innoactive.Creator.Core.Attributes; | ||
using Innoactive.Creator.Core.Properties; | ||
using Innoactive.Creator.Core.SceneObjects; | ||
using Innoactive.Creator.Core.Utils; | ||
using Innoactive.Creator.Core.Validation; | ||
|
||
namespace Innoactive.Creator.Core.Conditions | ||
{ | ||
/// <summary> | ||
/// Condition which is completed when an 'XR Rig' gets teleported into the referenced <see cref="ITeleportProperty"/>. | ||
/// </summary> | ||
[DataContract(IsReference = true)] | ||
public class TeleportCondition : Condition<TeleportCondition.EntityData> | ||
{ | ||
[DisplayName("Teleport")] | ||
[DataContract(IsReference = true)] | ||
public class EntityData : IConditionData | ||
{ | ||
[DataMember] | ||
[DisplayName("Teleport Point")] | ||
#if CREATOR_PRO | ||
[CheckForCollider] | ||
#endif | ||
tomwim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public ScenePropertyReference<ITeleportProperty> TeleportPoint { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public bool IsCompleted { get; set; } | ||
|
||
/// <inheritdoc /> | ||
[DataMember] | ||
[HideInTrainingInspector] | ||
public string Name { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public Metadata Metadata { get; set; } | ||
} | ||
|
||
public TeleportCondition() : this("", "") | ||
{ | ||
} | ||
|
||
// ReSharper disable once SuggestBaseTypeForParameter | ||
public TeleportCondition(ColliderWithTriggerProperty teleportPoint, string name = null) | ||
: this(TrainingReferenceUtils.GetNameFrom(teleportPoint), name) | ||
{ | ||
Gusinuhe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public TeleportCondition(string teleportPoint, string name = "Dummy") | ||
{ | ||
Data.TeleportPoint = new ScenePropertyReference<ITeleportProperty>(teleportPoint); | ||
Data.Name = name; | ||
} | ||
|
||
private class ActiveProcess : BaseActiveProcessOverCompletable<EntityData> | ||
{ | ||
public ActiveProcess(EntityData data) : base(data) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override bool CheckIfCompleted() | ||
{ | ||
return Data.TeleportPoint.Value.WasUsedToTeleport; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of having a set value, why dont we use events? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, we do, the events set that property to true. |
||
} | ||
} | ||
|
||
private class EntityAutocompleter : Autocompleter<EntityData> | ||
{ | ||
public EntityAutocompleter(EntityData data) : base(data) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Complete() | ||
{ | ||
Data.TeleportPoint.Value.FastForwardTeleport(); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override IProcess GetActiveProcess() | ||
{ | ||
return new ActiveProcess(Data); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override IAutocompleter GetAutocompleter() | ||
{ | ||
return new EntityAutocompleter(Data); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using Innoactive.Creator.Core.SceneObjects; | ||
|
||
namespace Innoactive.Creator.Core.Properties | ||
{ | ||
/// <summary> | ||
/// Interface for <see cref="ISceneObject"/>s that can be used for teleport into. | ||
Gusinuhe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// </summary> | ||
public interface ITeleportProperty : ISceneObjectProperty, ILockable | ||
{ | ||
/// <summary> | ||
/// Emitted when an 'XR Rig' gets teleported into this <see cref="ISceneObject"/>. | ||
Gusinuhe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// </summary> | ||
event EventHandler<EventArgs> Teleported; | ||
|
||
/// <summary> | ||
/// Is object currently used. | ||
Gusinuhe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// </summary> | ||
bool WasUsedToTeleport { get; } | ||
|
||
/// <summary> | ||
/// Instantaneously simulate that the object was used. | ||
/// </summary> | ||
void FastForwardTeleport(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not have to be an XR Rig, could also be something else, like a regular camera or trainee object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same in the ITeleportProperty, but those are just details