100 lines
2.8 KiB
C#
100 lines
2.8 KiB
C#
|
using Cal;
|
|||
|
using MongoDB.Bson.Serialization.Attributes;
|
|||
|
using Sirenix.OdinInspector;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using UnityEngine;
|
|||
|
using XNode;
|
|||
|
|
|||
|
[NodeWidth(250)]
|
|||
|
public class ModifierNode : SkillNode
|
|||
|
{
|
|||
|
|
|||
|
// Use this for initialization
|
|||
|
protected override void Init()
|
|||
|
{
|
|||
|
base.Init();
|
|||
|
modifier = modifier ?? new ModifierConfig();
|
|||
|
}
|
|||
|
[LabelText("操作")]
|
|||
|
[PropertyOrder(0)]
|
|||
|
[BsonIgnore]
|
|||
|
[Input] public float input;
|
|||
|
[PropertySpace(0, 15)]
|
|||
|
[PropertyOrder(1)]
|
|||
|
[BsonIgnore]
|
|||
|
[LabelText("modifier事件条件")]
|
|||
|
[Output] public float result;
|
|||
|
[BsonIgnore]
|
|||
|
[ShowInInspector]
|
|||
|
[PropertyOrder(2)]
|
|||
|
public string modifierId => $"{modifier?.Id.Value / 100}+{modifier?.Id.Value % 100}";
|
|||
|
[PropertyOrder(3)]
|
|||
|
[SerializeField]
|
|||
|
public ModifierConfig modifier;
|
|||
|
|
|||
|
// GetValue should be overridden to return a value for any specified output port
|
|||
|
public override object GetValue(NodePort port)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
public override void OnCreateConnection(NodePort from, NodePort to)
|
|||
|
{
|
|||
|
if (to.node == this)
|
|||
|
{
|
|||
|
if (!(from.node is SkillOptionBase))
|
|||
|
{
|
|||
|
from.Disconnect(to);
|
|||
|
return;
|
|||
|
}
|
|||
|
Type type = from.node.GetType();
|
|||
|
foreach (var fieldInfo in type.GetFields())
|
|||
|
{
|
|||
|
if(fieldInfo.FieldType == typeof(ModifierId))
|
|||
|
{
|
|||
|
modifier.Id = (ModifierId)fieldInfo.GetValue(from.node);
|
|||
|
}
|
|||
|
else
|
|||
|
if (fieldInfo.FieldType == typeof(ModifierId[]))
|
|||
|
{
|
|||
|
var arr = (ModifierId[])fieldInfo.GetValue(from.node);
|
|||
|
HashSet<ModifierId> set = new HashSet<ModifierId>();
|
|||
|
foreach (var item in arr)
|
|||
|
{
|
|||
|
set.Add(item);
|
|||
|
}
|
|||
|
foreach (ModifierNode item in skillGraph.nodes.FindAll(t=>t is ModifierNode))
|
|||
|
{
|
|||
|
if (item != this)
|
|||
|
{
|
|||
|
if (set.Contains(item.modifier.Id))
|
|||
|
set.Remove(item.modifier.Id);
|
|||
|
}
|
|||
|
}
|
|||
|
if (set.Count==0)
|
|||
|
{
|
|||
|
ET.Log.Error($"modifier Id = {modifierId}不能配对");
|
|||
|
return;
|
|||
|
}
|
|||
|
modifier.Id = set.First();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
if (!(to.node is ModifierEventConditionNode))
|
|||
|
{
|
|||
|
from.Disconnect(to);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#if UNITY
|
|||
|
public override void CheckData()
|
|||
|
{
|
|||
|
modifier.CheckData();
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
}
|