Ejemplo n.º 1
0
        private void LoadOptions()
        {
#if UNITY_EDITOR //* If the application is in the editor.
            if (!Application.isPlaying)
            {
                var behaviours = transform.root.GetComponentsInChildren <NeutronBehaviour>(); //* Get all.......
                if (behaviours.Length <= byte.MaxValue)
                {
                    if (Id == 0)
                    {
                        _id = (byte)Helper.GetAvailableId(behaviours, x => x.Id, byte.MaxValue); //* If the object id is 0, get the available id.
                    }
                    else
                    {
                        if (!(Id >= byte.MaxValue))
                        {
                            //* If the object id is not 0 and less than the maximum value, check if the id is available.
                            int count = behaviours.Count(x => x.Id == Id); //* find duplicate id.
                            if (count > 1)
                            {
                                Reset(); //* If the id is already in use, reset the id.
                            }
                        }
                        else
                        {
                            LogHelper.Error("Max Neutron Behaviours reached in this Neutron View!");
                        }
                    }
                }
                else
                {
                    throw new Exception("Only 255 instances of \"NeutronBehaviour\" can exist per network object(NeutronView).");
                }
            }

            #region Reflection
            if (!Application.isPlaying)
            {
                NeutronBehaviour instance = this; //* Get local instance.
                if (instance != null)
                {
                    var method = ReflectionHelper.GetMethod("OnAutoSynchronization", instance); //* Get the virtual auto-sync method.
                    if (method != null)
                    {
                        _hasOnAutoSynchronization = method.DeclaringType != typeof(NeutronBehaviour); //* If the method is not null, check if the method is not from the base class.
                    }
                    else
                    {
                        _hasOnAutoSynchronization = false;
                    }

                    (iRPCAttribute[], MethodInfo)[] multiplesMethods = ReflectionHelper.GetMultipleAttributesWithMethod <iRPCAttribute>(instance); //* Get all the methods marked with iRPC attribute.
Ejemplo n.º 2
0
 public void HandledBy(NeutronBehaviour neutronBehaviour)
 {
     _authority          = AuthorityMode.Handled;
     _authorityHandledBy = neutronBehaviour;
 }