Skip to content
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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Editor/UI/MenuItems/TeleportMenuItem.cs
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();
}
}
}

11 changes: 11 additions & 0 deletions Editor/UI/MenuItems/TeleportMenuItem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions Runtime/Conditions/PositionalConditions/TeleportCondition.cs
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"/>.
Copy link
Contributor

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

Copy link
Contributor

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

/// </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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of having a set value, why dont we use events?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we do, the events set that property to true.
The flag is required to know that the event was fired.

}
}

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.

26 changes: 26 additions & 0 deletions Runtime/Properties/ITeleportProperty.cs
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();
}
}
11 changes: 11 additions & 0 deletions Runtime/Properties/ITeleportProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.