EISA46SXVFL3UEYJBHVU4RFWKRU5ZJNN7Q7ATAYKCTSAMSPLL7RAC
IXGU2SOXBCQYBV3S5EHZFEFJKSCVUQPVZ3NY7KPG2UHWTEVGRZCAC
JAZ27QX53QXAN4JVMMX2KYKN4GCULWFMXYSPFZ5HWW4T7FUB5EHAC
3UN6NREN32ZBQW4EWI7ED4WVQILCU2EIE7DQGFWZR3OUDCO3ZSPQC
FXM5KEZSKC2Z4LH4SEM6SSXN7WXH7B35MO4PQ4HMW5CFYFTCSNPQC
XTNHXKSQ4PQS6CN3ATENRI7JUXU7DYZMRW4PBSEABN4S4VQHFUMAC
D4K77RTIZUI46DIDLVOR42DW3EP6IOMEAASAPZQ5XA2J7GEYFQIAC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
}
public bool FromData(PortData portData, Dictionary<string, EffectStepNode> guidToNode) {
DisplayName = portData.DisplayName;
var connectedNodeGuid = portData.ConnectedNodesGuid.FirstOrDefault();
if (connectedNodeGuid != null) {
TryConnect(guidToNode.GetValueOrDefault(connectedNodeGuid));
}
return true;
}
public bool FromData(PortData portData, Dictionary<string, EffectStepNode> guidToNode) {
DisplayName = portData.DisplayName;
foreach (var connectedNodeGuid in portData.ConnectedNodesGuid.Where(guid => guid != null)) {
TryConnect(guidToNode.GetValueOrDefault(connectedNodeGuid));
}
return true;
public interface IPort
[System.Serializable]
public class PortData
{
public CareBoo.Serially.SerializableType Type;
public string DisplayName;
public List<string> ConnectedNodesGuid;
}
public interface IPortData
{
public PortData ToData();
public bool FromData(PortData portData, Dictionary<string, EffectStepNode> guidToNode);
}
public interface IPort : IPortData
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
// effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
// Register = effectStepNodeData.Register;
return true;
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Const = _const;
effectStepNodeData.Operator = Operator;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
_const = effectStepNodeData.Const ?? new();
Operator = effectStepNodeData.Operator;
return true;
///
///
[System.Serializable]
public class EffectStepNodeData
{
public CareBoo.Serially.SerializableType SerializedType;
public string Guid;
public Vector2 Position;
public List<PortData> PortsData;
public List<double> Const;
[UnityEngine.SerializeReference]
public IResourceOperator Operator;
public CareBoo.Serially.SerializableType Resource;
public CareBoo.Serially.SerializableType Register;
public EffectStepNodeData(System.Type type, string guid, Vector2 position, List<PortData> portsData) {
SerializedType = new(type);
Guid = guid;
Position = position;
PortsData = portsData;
}
}
public interface IEffectStepNodeData
{
public EffectStepNodeData ToData();
public bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode);
}
public virtual EffectStepNodeData ToData() {
return new(GetType(), Guid, Position, Inputs.Select(input => input.ToData()).ToList());
}
public virtual bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
name = effectStepNodeData.SerializedType.Type.Name;
Guid = effectStepNodeData.Guid;
Position = effectStepNodeData.Position;
foreach (var (input, data) in Inputs.Zip(effectStepNodeData.PortsData, (input, data) => (input, data))) {
input.FromData(data, guidToNode);
}
return true;
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
Register = effectStepNodeData.Register;
return true;
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
Register = effectStepNodeData.Register;
return true;
--- !u!114 &-8227769925427620265
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4585b32f67d50794cad3c057a0f091a1, type: 3}
m_Name: e27d0db8-224c-4166-bb89-5253c668df10
m_EditorClassIdentifier:
Guid: e27d0db8-224c-4166-bb89-5253c668df10
_nodes: []
Center = Vector2.zero;
foreach (var nodeData in nodesData.Nodes) {
var newNode = ScriptableObject.CreateInstance(nodeData.SerializedType.Type) as EffectStepNode;
Nodes.Add(newNode);
guidToNode.TryAdd(nodeData.Guid, newNode);
}
foreach (var (node, data) in Nodes.Zip(nodesData.Nodes, (node, data) => (node, data))) {
node.FromData(data, guidToNode);
}
Center = nodesData.Center;
public EffectStepNodeGraph(IEnumerable<EffectStepNodeView> nodes) {
Nodes = nodes.Select(nodeView => nodeView.Node).ToList();
Center = new Vector2(nodes.Select(node => node.layout.center.x).Average(), nodes.Select(node => node.layout.center.y).Average());
[Serializable]
public class EffectStepNodeGraphData
{
public List<EffectStepNodeData> Nodes;
public Vector2 Center;
public EffectStepNodeGraphData() {
Nodes = new();
Center = Vector2.zero;
public override string ToString() {
return string.Join(",", Nodes.Select(n => n.ToString()));
public EffectStepNodeGraphData(IEnumerable<EffectStepNodeView> nodes) {
Nodes = nodes.Select(nodeView => nodeView.Node.ToData()).ToList();
Center = new Vector2(nodes.Select(node => node.layout.center.x).Average(), nodes.Select(node => node.layout.center.y).Average());
foreach (var node in graph.Nodes) {
var newNode = ScriptableObject.Instantiate(node);
newNode.name = node.name;
newNode.Guid = Guid.NewGuid().ToString();
newNode.Position = node.Position - graph.Center + mousePositionOnGraph;
clonedGraph.Nodes.Add(newNode);
clonedSteps.TryAdd(node.Guid, newNode);
foreach (var node in dataGraph.Nodes) {
var newGuid = Guid.NewGuid().ToString();
originalToNewGuid.TryAdd(node.Guid, newGuid);
node.Guid = newGuid;
node.Position = node.Position - dataGraph.Center + mousePositionOnGraph;
foreach (var input in clonedGraph.Nodes.SelectMany(node => node.Inputs)) {
var newNodeConnections = input.Connections().Select(c => clonedSteps.GetValueOrDefault(c.Guid)).Where(step => step != null).ToList();
input.DisconnectAll();
foreach (var newNodeConnection in newNodeConnections) {
input.TryConnect(newNodeConnection);
}
foreach (var port in dataGraph.Nodes.SelectMany(node => node.PortsData)) {
port.ConnectedNodesGuid = port.ConnectedNodesGuid.Select(origGuid => originalToNewGuid.GetValueOrDefault(origGuid)).ToList();