Exemplo n.º 1
0
        private void Awake()
        {
            Ownable = GetComponent <OwnableObject>();

            stateFieldsByMonoBehaviour = new List <KeyValuePair <MonoBehaviour, List <PropertyInfo> > >();

            MonoBehaviour[] monoBehaviours = GetComponentsInChildren <MonoBehaviour>();

            foreach (MonoBehaviour monoBehaviour in monoBehaviours)
            {
                if (monoBehaviour is OwnableObject)
                {
                    continue;
                }

                List <PropertyInfo> propertyInfos = null;

                Type type = monoBehaviour.GetType();

                foreach (PropertyInfo propertyInfo in
                         type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    if (typeof(IStateField).IsAssignableFrom(propertyInfo.PropertyType))
                    {
                        if (propertyInfos == null)
                        {
                            propertyInfos = new List <PropertyInfo>();
                        }

                        propertyInfos.Add(propertyInfo);
                    }
                }

                if (propertyInfos != null)
                {
                    stateFieldsByMonoBehaviour.Add(new KeyValuePair <MonoBehaviour, List <PropertyInfo> >(monoBehaviour, propertyInfos));
                }
            }
        }
Exemplo n.º 2
0
 private void Ownable_OnAuthorityChanged(OwnableObject o, int authority)
 {
     o.GetComponent <StatefulObject>().SetControl(authorityArbiter.CanWrite(authority));
 }