diff --git a/TouchEffect.cs b/TouchEffect.cs new file mode 100644 index 0000000..4fef4fe --- /dev/null +++ b/TouchEffect.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WeArt.Core; + +namespace WeArt.Components +{ + /// + /// Internal class used to create the haptic effet on collision. + /// + class TouchEffect : IWeArtEffect + { + /// + /// Defines the OnUpdate. + /// + public event Action OnUpdate; + + /// + /// Gets the Temperature. + /// + public Temperature Temperature { get; private set; } = Temperature.Default; + + /// + /// Gets the Force. + /// + public Force Force { get; private set; } = Force.Default; + + /// + /// Gets the Texture. + /// + public Texture Texture { get; private set; } = Texture.Default; + + /// + /// The Set. + /// + /// The temperature. + /// The force. + /// The texture. + public void Set(Temperature temperature, Force force, Texture texture) + { + // Need to clone these, or the internal arrays will point to the same data + force = (Force)force.Clone(); + texture = (Texture)texture.Clone(); + + + bool changed = false; + + // Temperature + changed |= !Temperature.Equals(temperature); + Temperature = temperature; + + // Force + changed |= !Force.Equals(force); + Force = force; + + // Texture + texture.Velocity = 0.5f; + + changed |= !Texture.Equals(texture); + Texture = texture; + + if (changed) + OnUpdate?.Invoke(); + } + + } +} \ No newline at end of file