116 lines
3.2 KiB
C#
116 lines
3.2 KiB
C#
|
using ET;
|
|||
|
using MongoDB.Bson.Serialization.Attributes;
|
|||
|
using Sirenix.OdinInspector;
|
|||
|
using System;
|
|||
|
using UnityEngine;
|
|||
|
#if UNITY_EDITOR
|
|||
|
using XNode;
|
|||
|
#endif
|
|||
|
|
|||
|
namespace Cal
|
|||
|
{
|
|||
|
[System.Serializable]
|
|||
|
#if UNITY_EDITOR
|
|||
|
[BsonIgnoreExtraElements]
|
|||
|
[NodeWidth(300)]
|
|||
|
public abstract class SkillOptionBase : SkillNode
|
|||
|
#else
|
|||
|
[BsonIgnoreExtraElements]
|
|||
|
public abstract class SkillOptionBase
|
|||
|
#endif
|
|||
|
{
|
|||
|
[LabelText("操作类型")]
|
|||
|
[ShowInInspector]
|
|||
|
public abstract SkillOptionType optionType { get; }
|
|||
|
|
|||
|
#if SERVER
|
|||
|
#endif
|
|||
|
#if UNITY_EDITOR
|
|||
|
[LabelText("输入")]
|
|||
|
[BsonIgnore]
|
|||
|
[Input] public float input;
|
|||
|
[PropertySpace(0, 15)]
|
|||
|
[LabelText("Modifier")]
|
|||
|
[BsonIgnore]
|
|||
|
[Output] public float result;
|
|||
|
// Use this for initialization
|
|||
|
protected override void Init()
|
|||
|
{
|
|||
|
base.Init();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// 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)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
if ((to.node is SkillOptionBase))
|
|||
|
{
|
|||
|
//from.Disconnect(to);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal virtual void Clear()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public SkillOptionBase Clone(SkillOptionBase node)
|
|||
|
{
|
|||
|
Type type = this.GetType();
|
|||
|
var arr = type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
|||
|
foreach (var fieldInfo in arr)
|
|||
|
{
|
|||
|
if (fieldInfo.DeclaringType == type)
|
|||
|
{
|
|||
|
fieldInfo.SetValue(node, fieldInfo.GetValue(this));
|
|||
|
}
|
|||
|
}
|
|||
|
return node;
|
|||
|
}
|
|||
|
public void DeepClone(SkillOptionBase node)
|
|||
|
{
|
|||
|
Type type = this.GetType();
|
|||
|
var arr =ReflectionHelper.GetFields( type,System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
|||
|
foreach (var fieldInfo in arr)
|
|||
|
{
|
|||
|
fieldInfo.SetValue(node, fieldInfo.GetValue(this));
|
|||
|
}
|
|||
|
}
|
|||
|
public virtual NodePort GetNodePort(string fieldName)
|
|||
|
{
|
|||
|
return GetOutputPort("result");
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 填充字段
|
|||
|
/// </summary>
|
|||
|
public virtual void Serilize(SkillOptionBase skillOption)
|
|||
|
{
|
|||
|
}
|
|||
|
public override void CheckData()
|
|||
|
{
|
|||
|
base.CheckData();
|
|||
|
Type type = this.GetType();
|
|||
|
var arr = type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
|||
|
foreach (var fieldInfo in arr)
|
|||
|
{
|
|||
|
if (fieldInfo.DeclaringType == type && fieldInfo.FieldType == typeof(SelectMultiTarget))
|
|||
|
{
|
|||
|
SelectMultiTarget selectMultiTarget = fieldInfo.GetValue(this) as SelectMultiTarget;
|
|||
|
selectMultiTarget.CheckData();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
}
|
|||
|
}
|