Example #1
0
        public void RecieveSerializationData(SerializationData Data)
        {
            // Set the basic Component values
            this.DrawOrder = Data.GetData<int>("Component.DrawOrder");
            this.Visible = Data.GetData<bool>("Component.Visible");
            this.Name = Data.GetData<string>("Component.Name");

            // Get the ServiceData from the data
            ServiceData sd = Data.GetData<ServiceData>("Component.ServiceData");

            // If the conponent was a service
            if (sd.IsService)
            {
                // Get the type back from the serializer
                Type t = Data.GetTypeFromDependency(sd.Type);

                // Add the service to the Engine
                Engine.Services.AddService(t, this);
            }

            // Set the owner GameScreen
            string parent = Data.GetData<string>("Component.ParentScreen");
            this.Parent = Engine.GameScreens[parent];

            // Call the overridable function that allow components to load from data
            LoadFromSerializationData(Data);
        }