You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.3 KiB
71 lines
1.3 KiB
10 years ago
|
using UnityEngine;
|
||
10 years ago
|
using System;
|
||
|
using System.Collections;
|
||
10 years ago
|
using System.Collections.Generic;
|
||
10 years ago
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
|
public enum VariableScope
|
||
|
{
|
||
10 years ago
|
Private,
|
||
|
Public
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
public class VariableInfoAttribute : Attribute
|
||
|
{
|
||
|
public VariableInfoAttribute(string category, string variableType, int order = 0)
|
||
|
{
|
||
|
this.Category = category;
|
||
|
this.VariableType = variableType;
|
||
|
this.Order = order;
|
||
|
}
|
||
|
|
||
|
public string Category { get; set; }
|
||
|
public string VariableType { get; set; }
|
||
|
public int Order { get; set; }
|
||
|
}
|
||
|
|
||
10 years ago
|
public class VariablePropertyAttribute : PropertyAttribute
|
||
|
{
|
||
|
public VariablePropertyAttribute (params System.Type[] variableTypes)
|
||
|
{
|
||
|
this.VariableTypes = variableTypes;
|
||
|
}
|
||
|
|
||
|
public System.Type[] VariableTypes { get; set; }
|
||
|
}
|
||
|
|
||
10 years ago
|
[RequireComponent(typeof(Flowchart))]
|
||
10 years ago
|
public abstract class Variable : MonoBehaviour
|
||
10 years ago
|
{
|
||
|
public VariableScope scope;
|
||
10 years ago
|
|
||
10 years ago
|
public string key = "";
|
||
10 years ago
|
|
||
10 years ago
|
public abstract void OnReset();
|
||
|
}
|
||
|
|
||
|
public abstract class VariableBase<T> : Variable
|
||
|
{
|
||
|
public T value;
|
||
|
|
||
|
protected T startValue;
|
||
|
|
||
|
public override void OnReset()
|
||
|
{
|
||
|
value = startValue;
|
||
|
}
|
||
|
|
||
|
public override string ToString()
|
||
|
{
|
||
|
return value.ToString();
|
||
|
}
|
||
|
|
||
|
protected virtual void Start()
|
||
|
{
|
||
|
// Remember the initial value so we can reset later on
|
||
|
startValue = value;
|
||
|
}
|
||
10 years ago
|
}
|
||
|
}
|