コード例 #1
0
ファイル: MonitorComponent.cs プロジェクト: Hengle/clapotis
        public MonitorComponent(string path, ServerComponent component) : base(path, MonitorComponent.GetClosureComponent(component.component))
        {
            this.component            = component;
            this.gameObjectInstanceID = this.component.component.gameObject.GetInstanceID();
            this.instanceID           = this.component.instanceID;

            this.children = new List <MonitorData>(this.component.fields.Length);

            for (int i = 0; i < this.component.fields.Length; i++)
            {
                CustomMonitorData customMonitor = MonitorDataManager.CreateMonitorData(this.component.fields[i].Type, this.path + NGServerScene.ValuePathSeparator + i, getInstance, this.component.fields[i]);

                if (customMonitor != null)
                {
                    this.children.Add(customMonitor);
                }
                else if (this.component.fields[i].Type.IsUnityArray() == true)
                {
                    this.children.Add(new MonitorArray(this.path + NGServerScene.ValuePathSeparator + i, this.component.fields[i], getInstance));
                }
                else if (this.component.fields[i] is FieldModifier)
                {
                    this.children.Add(new MonitorField(this.path + NGServerScene.ValuePathSeparator + i, getInstance, (this.component.fields[i] as FieldModifier).fieldInfo));
                }
                else if (this.component.fields[i] is PropertyModifier)
                {
                    this.children.Add(new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + i, getInstance, (this.component.fields[i] as PropertyModifier).propertyInfo));
                }
            }
        }
コード例 #2
0
        public override void    CollectUpdates(List <MonitorData> updates)
        {
            if (this.gameObject.gameObject == null)
            {
                updates.Add(this);
                return;
            }

            // Remove destroyed components.
            for (int i = 5; i < this.children.Count; i++)
            {
                if (this.children[i].ToDelete == true)
                {
                    this.children.RemoveAt(i--);
                }
            }

            bool inList = false;

            // Add new components.
            Component[] components = this.gameObject.gameObject.GetComponents <Component>();
            for (int i = 0; i < components.Length; i++)
            {
                int j = 0;

                for (; j < this.children.Count; j++)
                {
                    if (object.Equals(components[i], this.children[j].Instance) == true)
                    {
                        break;
                    }
                }

                if (j == this.children.Count)
                {
                    ServerComponent newComponent = new ServerComponent(components[i]);
                    this.gameObject.components.Add(newComponent);
                    this.newComponents.Add(newComponent);

                    this.children.Add(new MonitorComponent(this.path + NGServerScene.ValuePathSeparator + components[i].GetInstanceID().ToString(), newComponent));

                    inList = true;
                }
            }

            if (inList == true)
            {
                updates.Add(this);
            }

            for (int i = 0; i < this.children.Count; i++)
            {
                this.children[i].CollectUpdates(updates);
            }
        }
コード例 #3
0
ファイル: ServerGameObject.cs プロジェクト: Hengle/clapotis
        public ServerComponent  AddComponent(Type behaviourType)
        {
            Component newComponent = this.gameObject.AddComponent(behaviourType);

            if (newComponent != null)
            {
                ServerComponent component = new ServerComponent(newComponent);
                this.components.Add(component);

                return(component);
            }

            return(null);
        }
コード例 #4
0
ファイル: NetComponent.cs プロジェクト: Hengle/clapotis
        public static void      Serialize(ByteBuffer buffer, ServerComponent component)
        {
            using (SafeWrapByteBuffer.Get(buffer))
            {
                Type componentType = component.component.GetType();

                buffer.Append(component.instanceID);
                buffer.Append(Utility.IsComponentEnableable(component.component),
                              (component.component is Transform) == false);                             // Deletable
                buffer.AppendUnicodeString(componentType.GetShortAssemblyType());
                buffer.AppendUnicodeString(componentType.Name);
                buffer.Append(component.fields.Length);

                for (int i = 0; i < component.fields.Length; i++)
                {
                    try
                    {
                        NetField.Serialize(buffer, component.component, component.fields[i]);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("Component \"" + componentType.Name + "\" failed on field \"" + component.fields[i].Name + "\" (" + (i + 1) + "/" + component.fields.Length + ").", ex);
                        throw;
                    }
                }

                buffer.Append(component.methods.Length);

                for (int i = 0; i < component.methods.Length; i++)
                {
                    try
                    {
                        NetMethod.Serialize(buffer, component.methods[i]);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("Component \"" + componentType.Name + "\" failed on method \"" + component.methods[i].methodInfo.Name + "\" (" + (i + 1) + "/" + component.methods.Length + ").", ex);
                        throw;
                    }
                }
            }
        }
コード例 #5
0
 public NotifyComponentAddedPacket(int gameObjectInstanceID, ServerComponent serverComponent)
 {
     this.gameObjectInstanceID = gameObjectInstanceID;
     this.serverComponent      = serverComponent;
 }