mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Nodes - Added event value cycle node
This commit is contained in:
1 parent
02f4609eae
commit
8413b8d6db
13 files changed
+195
-74
No files matched your search
@@ -130,8 +130,11 @@ namespace Artemis.Core
|
||||
/// at all
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int ScoreCastability(this Type to, Type from)
|
||||
public static int ScoreCastability(this Type to, Type? from)
|
||||
{
|
||||
if (from == null)
|
||||
return 0;
|
||||
|
||||
if (to == from)
|
||||
return 5;
|
||||
if (to.TypeIsNumber() && from.TypeIsNumber())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -31,4 +32,38 @@ namespace Artemis.Core
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public sealed class InputPinCollection : PinCollection
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public override PinDirection Direction => PinDirection.Input;
|
||||
public override Type Type { get; }
|
||||
|
||||
public new IEnumerable<InputPin> Pins => base.Pins.Cast<InputPin>();
|
||||
|
||||
public IEnumerable Values => Pins.Select(p => p.Value);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal InputPinCollection(INode node, Type type, string name, int initialCount)
|
||||
: base(node, name, 0)
|
||||
{
|
||||
this.Type = type;
|
||||
|
||||
// Can't do this in the base constructor because the type won't be set yet
|
||||
for (int i = 0; i < initialCount; i++)
|
||||
AddPin();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override IPin CreatePin() => new InputPin(Node, Type, string.Empty);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,6 @@ namespace Artemis.Core
|
||||
|
||||
void ConnectTo(IPin pin);
|
||||
void DisconnectFrom(IPin pin);
|
||||
void DisconnectAll();
|
||||
}
|
||||
}
|
||||
@@ -130,6 +130,14 @@ namespace Artemis.Core
|
||||
return pin;
|
||||
}
|
||||
|
||||
protected InputPinCollection CreateInputPinCollection(Type type, string name = "", int initialCount = 1)
|
||||
{
|
||||
InputPinCollection pin = new(this, type, name, initialCount);
|
||||
_pinCollections.Add(pin);
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
return pin;
|
||||
}
|
||||
|
||||
protected OutputPinCollection<T> CreateOutputPinCollection<T>(string name = "", int initialCount = 1)
|
||||
{
|
||||
OutputPinCollection<T> pin = new(this, name, initialCount);
|
||||
@@ -138,6 +146,19 @@ namespace Artemis.Core
|
||||
return pin;
|
||||
}
|
||||
|
||||
protected bool RemovePinCollection(PinCollection pinCollection)
|
||||
{
|
||||
bool isRemoved = _pinCollections.Remove(pinCollection);
|
||||
if (isRemoved)
|
||||
{
|
||||
foreach (IPin pin in pinCollection)
|
||||
pin.DisconnectAll();
|
||||
OnPropertyChanged(nameof(PinCollections));
|
||||
}
|
||||
|
||||
return isRemoved;
|
||||
}
|
||||
|
||||
public virtual void Initialize(INodeScript script)
|
||||
{ }
|
||||
|
||||
|
||||
Reference in new issue
Block a user