Пример #1
0
                // Grabs a PQSMod of type T from a parameter with a given PQS
                public override void Create(PQSMod_HeightColorMap2 _mod, PQS pqsVersion)
                {
                    base.Create(_mod, pqsVersion);

                    // Create the callback list
                    landClasses = new CallbackList <LandClassLoader> ((e) =>
                    {
                        mod.landClasses = landClasses.Where(landClass => !landClass.delete)
                                          .Select(landClass => landClass.Value).ToArray();
                        mod.lcCount = mod.landClasses.Length;
                    });

                    // Load LandClasses
                    if (mod.landClasses != null)
                    {
                        for (Int32 i = 0; i < mod.landClasses.Length; i++)
                        {
                            // Only activate the callback if we are adding the last loader
                            landClasses.Add(new LandClassLoader(mod.landClasses[i]), i == mod.landClasses.Length - 1);
                        }
                    }
                    else
                    {
                        mod.landClasses = new PQSMod_HeightColorMap2.LandClass[mod.lcCount = 0];
                    }
                }
Пример #2
0
 public StoreGet(Simulation environment, Action <Event> callback)
     : base(environment)
 {
     CallbackList.Add(callback);
     Time  = environment.Now;
     Owner = environment.ActiveProcess;
 }
Пример #3
0
 public StoreGet(Environment environment, Action <Event> callback)
     : base(environment)
 {
     CallbackList.Add(callback);
     Time    = environment.Now;
     Process = environment.ActiveProcess;
 }
Пример #4
0
        public void Load(XElement root)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            if (m_suppressibleValueChanged.Suppressed)
            {
                throw new InternalLogicException("Can't load config while there are unsaved changes to config");
            }

            using (SuppressCallback()) //The following block will modify the data but during a load that shouldn't trigger ValueChanged
            {
                var a = root.Element(m_name);
                m_data.Clear();
                if (a != null)
                {
                    foreach (var node in a.Elements("Element"))
                    {
                        ConfigParameter <TValue> t = m_nodeFactory();
                        t.Load(node);
                        m_data.Add(t.Value);
                    }
                }
                m_suppressibleValueChanged.Dispose(); //Pretend we haven't changed anything, by destroying the old callback and making a new one
            }

            m_suppressibleValueChanged = new SuppressibleAction(() => ValueChanged.Execute());
        }
Пример #5
0
        // Grabs a PQSMod of type T from a parameter with a given PQS
        public override void Create(PQSCity2 mod, PQS pqsVersion)
        {
            base.Create(mod, pqsVersion);

            // Create the callback list
            LodRanges = new CallbackList <LodRangeLoader>(e =>
            {
                Mod.objects = LodRanges.Where(lodRange => !lodRange.Delete)
                              .Select(lodRange => lodRange.Value).ToArray();
                foreach (GameObject obj in e.Value.objects)
                {
                    obj.transform.parent        = Mod.transform;
                    obj.transform.localPosition = Vector3.zero;
                    obj.SetLayerRecursive(GameLayers.LOCAL_SPACE);
                    obj.gameObject.AddOrGetComponent <KopernicusSurfaceObject>().objectName = Mod.name;
                }
            });

            // Load LandClasses
            if (Mod.objects != null)
            {
                for (Int32 i = 0; i < Mod.objects.Length; i++)
                {
                    // Only activate the callback if we are adding the last loader
                    LodRanges.Add(new LodRangeLoader(Mod.objects[i]), i == Mod.objects.Length - 1);
                }
            }
            else
            {
                Mod.objects = new PQSCity2.LodObject[0];
            }
        }
Пример #6
0
        // Grabs a PQSMod of type T from a parameter with a given PQS
        public override void Create(PQSMod_HeightBiomeMap mod, PQS pqsVersion)
        {
            base.Create(mod, pqsVersion);

            // Create the callback list
            LandClasses = new CallbackList <LandClassLoader>(e =>
            {
                Mod.landClasses = LandClasses.Where(landClass => !landClass.Delete)
                                  .Select(landClass => landClass.Value).ToArray();
                Mod.lcCount = Mod.landClasses.Length;
            });

            // Load LandClasses
            if (Mod.landClasses != null)
            {
                for (Int32 i = 0; i < Mod.landClasses.Length; i++)
                {
                    // Only activate the callback if we are adding the last loader
                    LandClasses.Add(new LandClassLoader(Mod.landClasses[i]), i == Mod.landClasses.Length - 1);
                }
            }
            else
            {
                Mod.landClasses = new PQSMod_HeightBiomeMap.LandClass[Mod.lcCount = 0];
            }
        }
Пример #7
0
        public static CallbackList <T1> Create <T1>(Callback <T1> callback)
        {
            CallbackList <T1> list = new CallbackList <T1>();

            list.Add(callback);
            return(list);
        }
Пример #8
0
        protected Condition(Environment environment, IEnumerable <Event> events)
            : base(environment)
        {
            CallbackList.Add(CollectValues);
            Events      = new List <Event>(events);
            FiredEvents = new List <Event>();

            foreach (var @event in Events)
            {
                if (Environment != @event.Environment)
                {
                    throw new ArgumentException("It is not allowed to mix events from different environments");
                }
                if (@event.IsProcessed)
                {
                    Check(@event);
                }
                else
                {
                    @event.AddCallback(Check);
                }
            }

            if (IsAlive && Evaluate())
            {
                Succeed();
            }
        }
Пример #9
0
                // Grabs a PQSMod of type T from a parameter with a given PQS
                public override void Create(PQSCity2 _mod, PQS pqsVersion)
                {
                    base.Create(_mod, pqsVersion);

                    // Create the callback list
                    lodRanges = new CallbackList <LODRangeLoader> (e =>
                    {
                        mod.objects = lodRanges.Where(lodRange => !lodRange.delete)
                                      .Select(lodRange => lodRange.Value).ToArray();
                        foreach (GameObject obj in e.Value.objects)
                        {
                            obj.transform.parent        = mod.transform;
                            obj.transform.localPosition = Vector3.zero;
                            obj.SetLayerRecursive(GameLayers.LocalSpace);
                        }
                    });

                    // Load LandClasses
                    if (mod.objects != null)
                    {
                        for (Int32 i = 0; i < mod.objects.Length; i++)
                        {
                            // Only activate the callback if we are adding the last loader
                            lodRanges.Add(new LODRangeLoader(mod.objects[i]), i == mod.objects.Length - 1);
                        }
                    }
                    else
                    {
                        mod.objects = new PQSCity2.LodObject[0];
                    }
                }
Пример #10
0
 public Initialize(Simulation environment, Process process, int priority)
     : base(environment)
 {
     CallbackList.Add(process.Resume);
     IsOk        = true;
     IsTriggered = true;
     environment.Schedule(this, priority);
 }
Пример #11
0
 /// <summary>
 /// This method adds a callback to the list of callbacks. Callbacks will be
 /// executed in the order they have been added.
 /// </summary>
 /// <param name="callback">The callback to execute when the event is being
 /// processed.</param>
 public virtual void AddCallback(Action <Event> callback)
 {
     if (IsProcessed)
     {
         throw new InvalidOperationException("Event is already processed.");
     }
     CallbackList.Add(callback);
 }
Пример #12
0
 public Initialize(Environment environment, Process process)
     : base(environment)
 {
     CallbackList.Add(process.Resume);
     IsOk        = true;
     IsTriggered = true;
     environment.Schedule(this);
 }
Пример #13
0
 public Request(Environment environment, Action <Event> callback, Action <Event> disposeCallback)
     : base(environment)
 {
     CallbackList.Add(callback);
     this.disposeCallback = disposeCallback;
     Time    = environment.Now;
     Process = environment.ActiveProcess;
 }
Пример #14
0
            public RingLoader(CelestialBody body)
            {
                // Is this a spawned body?
                if (body?.scaledBody == null || Injector.IsInPrefab)
                {
                    throw new InvalidOperationException("The body must be already spawned by the PSystemManager.");
                }

                Value = new GameObject(body.transform.name + "Ring").AddComponent <Ring>();
                Value.transform.parent = body.scaledBody.transform;
                Value.planetRadius     = (Single)body.Radius;

                // Need to check the parent body's rotation to orient the LAN properly
                Value.referenceBody = body;

                // Create the Component callback
                Components = new CallbackList <ComponentLoader <Ring> > (e =>
                {
                    Value.Components = Components.Select(c => c.Value).ToList();
                });

                // Load existing Modules
                foreach (IComponent <Ring> component in Value.Components)
                {
                    Type componentType = component.GetType();
                    foreach (Type loaderType in Parser.ModTypes)
                    {
                        if (loaderType.BaseType == null)
                        {
                            continue;
                        }
                        if (loaderType.BaseType.Namespace != "Kopernicus.Configuration")
                        {
                            continue;
                        }
                        if (!loaderType.BaseType.Name.StartsWith("ComponentParser"))
                        {
                            continue;
                        }
                        if (loaderType.BaseType.GetGenericArguments()[0] != Value.GetType())
                        {
                            continue;
                        }
                        if (loaderType.BaseType.GetGenericArguments()[1] != componentType)
                        {
                            continue;
                        }

                        // We found our loader type
                        ComponentLoader <Ring> loader = (ComponentLoader <Ring>)Activator.CreateInstance(loaderType);
                        loader.Create(component);
                        Components.Add(loader);
                    }
                }
            }
Пример #15
0
        public void Adding_an_element_calls_back()
        {
            int i   = 0;
            var lst = new CallbackList <int>();

            lst.OnAdd = (el) => { i++; return(el); };

            lst.Add(5);

            Assert.Equal(1, i);
        }
Пример #16
0
 public StorePut(Simulation environment, Action <Event> callback, object value)
     : base(environment)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value", "Value to put in a Store cannot be null.");
     }
     CallbackList.Add(callback);
     Value = value;
     Time  = environment.Now;
     Owner = environment.ActiveProcess;
 }
Пример #17
0
 public ContainerGet(Environment environment, Action <Event> callback, double amount)
     : base(environment)
 {
     if (amount <= 0)
     {
         throw new ArgumentException("Amount must be > 0.", "amount");
     }
     Amount = amount;
     CallbackList.Add(callback);
     Time    = environment.Now;
     Process = environment.ActiveProcess;
 }
Пример #18
0
            public RingLoader(Ring value)
            {
                Value = value;

                // Create the Component callback
                Components = new CallbackList <ComponentLoader <Ring> > (e =>
                {
                    Value.Components = Components.Select(c => c.Value).ToList();
                });

                // Load existing Modules
                foreach (IComponent <Ring> component in Value.Components)
                {
                    Type componentType = component.GetType();
                    foreach (Type loaderType in Parser.ModTypes)
                    {
                        if (loaderType.BaseType == null)
                        {
                            continue;
                        }
                        if (loaderType.BaseType.Namespace != "Kopernicus.Configuration")
                        {
                            continue;
                        }
                        if (!loaderType.BaseType.Name.StartsWith("ComponentParser"))
                        {
                            continue;
                        }
                        if (loaderType.BaseType.GetGenericArguments()[0] != Value.GetType())
                        {
                            continue;
                        }
                        if (loaderType.BaseType.GetGenericArguments()[1] != componentType)
                        {
                            continue;
                        }

                        // We found our loader type
                        ComponentLoader <Ring> loader = (ComponentLoader <Ring>)Activator.CreateInstance(loaderType);
                        loader.Create(component);
                        Components.Add(loader);
                    }
                }
                if (Value.innerMultCurve == null)
                {
                    Value.innerMultCurve = new FloatCurve(new Keyframe[] { new Keyframe(0, 1), new Keyframe(1, 1) });
                }
                if (Value.outerMultCurve == null)
                {
                    Value.outerMultCurve = new FloatCurve(new Keyframe[] { new Keyframe(0, 1), new Keyframe(1, 1) });
                }
            }
Пример #19
0
        public RingLoader(CelestialBody body)
        {
            // Is this a spawned body?
            if (body.scaledBody == null || Injector.IsInPrefab)
            {
                throw new InvalidOperationException("The body must be already spawned by the PSystemManager.");
            }

            Value = new GameObject(body.transform.name + "Ring").AddComponent <Ring>();
            Value.transform.parent = body.scaledBody.transform;
            Value.planetRadius     = (Single)body.Radius;

            // Need to check the parent body's rotation to orient the LAN properly
            Value.referenceBody = body;

            // Create the Component callback
            Components = new CallbackList <ComponentLoader <Ring> >(e =>
            {
                Value.Components = Components.Select(c => c.Value).ToList();
            });

            // Load existing Modules
            foreach (IComponent <Ring> component in Value.Components)
            {
                Type componentType       = component.GetType();
                Type componentLoaderType = typeof(ComponentLoader <,>).MakeGenericType(typeof(Ring), componentType);
                foreach (Type loaderType in Parser.ModTypes)
                {
                    if (!componentLoaderType.IsAssignableFrom(loaderType))
                    {
                        continue;
                    }

                    // We found our loader type
                    ComponentLoader <Ring> loader = (ComponentLoader <Ring>)Activator.CreateInstance(loaderType);
                    loader.Create(component);
                    Components.Add(loader);
                }
            }

            if (Value.innerMultCurve == null)
            {
                Value.innerMultCurve = new FloatCurve(new [] { new Keyframe(0, 1), new Keyframe(1, 1) });
            }

            if (Value.outerMultCurve == null)
            {
                Value.outerMultCurve = new FloatCurve(new [] { new Keyframe(0, 1), new Keyframe(1, 1) });
            }
        }
Пример #20
0
            public EmissionModuleLoader(ParticleSystem.EmissionModule module)
            {
                _value = module;
                bursts = new CallbackList <BurstLoader>(e =>
                {
                    _value.SetBursts(bursts.Select(b => b.Value).ToArray());
                });

                ParticleSystem.Burst[] burstArray = new ParticleSystem.Burst[module.burstCount];
                module.GetBursts(burstArray);
                for (Int32 i = 0; i < module.burstCount; i++)
                {
                    bursts.Add(burstArray[i], i + 1 == module.burstCount);
                }
            }
Пример #21
0
        /// <summary>
        /// Creates a new Properties Loader from a spawned CelestialBody.
        /// </summary>
        public PropertiesLoader(CelestialBody body)
        {
            // Is this a spawned body?
            if (body.scaledBody == null || Injector.IsInPrefab)
            {
                throw new InvalidOperationException("The body must be already spawned by the PSystemManager.");
            }

            // Store values
            Value = body;

            // We require a science values object
            if (Value.scienceValues == null)
            {
                Value.scienceValues = new CelestialBodyScienceParams();
            }
            ScienceValues = new ScienceValuesLoader(Value.scienceValues);

            // isHomeWorld Check
            Value.isHomeWorld = Value.transform.name == "Kerbin";

            // Biomes
            Biomes = new CallbackList <BiomeLoader>(e =>
            {
                // Check biome map
                if (Value.BiomeMap == null)
                {
                    throw new InvalidOperationException("The Biome Map cannot be null if you want to add biomes.");
                }

                // Replace the old biomes list with the new one
                Value.BiomeMap.Attributes = Biomes.Select(b => b.Value).ToArray();
            });
            if (body.BiomeMap == null || body.BiomeMap.Attributes == null)
            {
                return;
            }

            foreach (CBAttributeMapSO.MapAttribute attribute in body.BiomeMap.Attributes)
            {
                Biomes.Add(new BiomeLoader(attribute), false);
            }
        }
Пример #22
0
        // Initialize the RingLoader
        public RingLoader(Ring value)
        {
            Value = value;

            // Create the Component callback
            Components = new CallbackList <ComponentLoader <Ring> >(e =>
            {
                Value.Components = Components.Select(c => c.Value).ToList();
            });

            // Load existing Modules
            foreach (IComponent <Ring> component in Value.Components)
            {
                Type componentType       = component.GetType();
                Type componentLoaderType = typeof(ComponentLoader <,>).MakeGenericType(typeof(Ring), componentType);
                foreach (Type loaderType in Parser.ModTypes)
                {
                    if (!componentLoaderType.IsAssignableFrom(loaderType))
                    {
                        continue;
                    }

                    // We found our loader type
                    ComponentLoader <Ring> loader = (ComponentLoader <Ring>)Activator.CreateInstance(loaderType);
                    loader.Create(component);
                    Components.Add(loader);
                }
            }

            if (Value.innerMultCurve == null)
            {
                Value.innerMultCurve = new FloatCurve(new[] { new Keyframe(0, 1), new Keyframe(1, 1) });
            }

            if (Value.outerMultCurve == null)
            {
                Value.outerMultCurve = new FloatCurve(new[] { new Keyframe(0, 1), new Keyframe(1, 1) });
            }
        }
Пример #23
0
        private SimpleUndoPair InnerAddNodes(IEnumerable <ConversationNode> nodes, IEnumerable <NodeGroup> groups, ILocalizationEngine localization)
        {
            List <Action> undoActions = new List <Action>();
            List <Action> redoActions = new List <Action>();

            //Set up actions for adding/removing the nodes
            foreach (var node in nodes)
            {
                var            n       = node;
                SimpleUndoPair actions = n.GetNodeRemoveActions();

                //Ensure that the localization engine is up to date in terms of usage of localized data
                foreach (var parameter in n.Data.Parameters.OfType <ILocalizedStringParameter>())
                {
                    if (parameter.Value != null)
                    {
                        SimpleUndoPair clearLocalization = localization.ClearLocalizationAction(Id <LocalizedStringType> .ConvertFrom(parameter.TypeId), parameter.Value);
                        undoActions.Add(clearLocalization.Redo);
                        redoActions.Add(clearLocalization.Undo);
                    }
                }

                var containingGroups = m_groups.Where(g => g.Contents.Contains(n.Data.NodeId)).Evaluate();
                redoActions.Add(() =>
                {
                    m_nodes.Add(n);
                    m_audioProvider.UpdateUsage(n);
                    foreach (var group in containingGroups)
                    {
                        group.Contents.Add(n.Data.NodeId);
                    }
                    actions.Undo(); //Undo the node removal
                });
                undoActions.Add(() =>
                {
                    if (CanRemoveFromData(n, PromptNodeDeletion))
                    {
                        m_nodes.Remove(n);
                    }
                    foreach (var group in containingGroups)
                    {
                        group.Contents.Remove(n.Data.NodeId);
                    }
                    actions.Redo(); //Redo the node removal
                    NodesDeleted.Execute();
                });
            }

            //Set up actions for adding/removing nodes from other groups that are gaining/losing their grouping due to removing/adding new groups
            foreach (var group in groups)
            {
                foreach (var node in group.Contents)
                {
                    var n   = node;
                    var old = m_groups.SingleOrDefault(g => g.Contents.Contains(n));
                    if (old != null)
                    {
                        undoActions.Add(() => old.Contents.Add(n));
                        redoActions.Add(() => old.Contents.Remove(n));
                    }
                }
            }

            //Set up actions for adding/removing the groups
            undoActions.Add(() =>
            {
                foreach (var group in groups.Reverse())
                {
                    m_groups.Remove(group);
                }
            });
            redoActions.Add(() =>
            {
                m_groups.AddRange(groups);
            });

            return(new SimpleUndoPair
            {
                Undo = () => { using (m_audioProvider.SuppressUpdates()) foreach (Action action in undoActions)
                                   {
                                       action();
                                   }
                },
                Redo = () => { using (m_audioProvider.SuppressUpdates()) foreach (Action action in redoActions)
                                   {
                                       action();
                                   }
                },
            });
        }
Пример #24
0
            // Runtime constructor
            public LandClassScatterLoader(PQSLandControl.LandClassScatter value)
            {
                Value = value;

                if (CustomMaterial)
                {
                    if (NormalDiffuse.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new NormalDiffuseLoader(CustomMaterial);
                    }
                    else if (NormalBumped.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new NormalBumpedLoader(CustomMaterial);
                    }
                    else if (NormalDiffuseDetail.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new NormalDiffuseDetailLoader(CustomMaterial);
                    }
                    else if (DiffuseWrap.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new DiffuseWrapLoader(CustomMaterial);
                    }
                    else if (AlphaTestDiffuse.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new AlphaTestDiffuseLoader(CustomMaterial);
                    }
                    else if (AerialTransCutout.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new AerialTransCutoutLoader(CustomMaterial);
                    }
                    else if (Standard.UsesSameShader(CustomMaterial))
                    {
                        CustomMaterial = new StandardLoader(CustomMaterial);
                    }
                }

                // Get the Scatter-Parent
                GameObject scatterParent = typeof(PQSLandControl.LandClassScatter)
                                           .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                                           .FirstOrDefault(f => f.FieldType == typeof(GameObject))?.GetValue(Value) as GameObject;

                // If the GameObject is null, create one
                if (scatterParent == null)
                {
                    scatterParent = new GameObject("Scatter");
                    scatterParent.transform.parent = Utility.Deactivator;
                }

                // Add the scatter module
                Scatter         = scatterParent.AddOrGetComponent <ModularScatter>();
                Scatter.scatter = Value;

                // Create the Component callback
                Components = new CallbackList <ComponentLoader <ModularScatter> >(e =>
                {
                    Scatter.Components = Components.Select(c => c.Value).ToList();
                });

                // Load existing Modules
                foreach (IComponent <ModularScatter> component in Scatter.Components)
                {
                    Type componentType       = component.GetType();
                    Type componentLoaderType = typeof(ComponentLoader <>).MakeGenericType(Value.GetType(), componentType);
                    foreach (Type loaderType in Parser.ModTypes)
                    {
                        if (!componentLoaderType.IsAssignableFrom(loaderType))
                        {
                            continue;
                        }

                        // We found our loader type
                        ComponentLoader <ModularScatter> loader = (ComponentLoader <ModularScatter>)Activator.CreateInstance(loaderType);
                        loader.Create(component);
                        Components.Add(loader);
                    }
                }
            }
Пример #25
0
            // Runtime constructor
            public LandClassLoader(PQSLandControl.LandClass value)
            {
                Value = value;

                // Initialize default parameters
                if (Value.altitudeRange == null)
                {
                    LerpRangeLoader range = new LerpRangeLoader
                    {
                        Value =
                        {
                            endEnd     = 1,
                            endStart   = 1,
                            startEnd   = 0,
                            startStart = 0
                        }
                    };
                    AltitudeRange = range;
                }

                if (Value.latitudeRange == null)
                {
                    LerpRangeLoader range = new LerpRangeLoader
                    {
                        Value =
                        {
                            endEnd     = 1,
                            endStart   = 1,
                            startEnd   = 0,
                            startStart = 0
                        }
                    };
                    LatitudeRange = range;
                }

                if (Value.latitudeDoubleRange == null)
                {
                    LerpRangeLoader range = new LerpRangeLoader
                    {
                        Value =
                        {
                            endEnd     = 1,
                            endStart   = 1,
                            startEnd   = 0,
                            startStart = 0
                        }
                    };
                    LatitudeDoubleRange = range;
                }

                if (Value.longitudeRange == null)
                {
                    LerpRangeLoader range = new LerpRangeLoader
                    {
                        Value =
                        {
                            endEnd     =  2,
                            endStart   =  2,
                            startEnd   = -1,
                            startStart = -1
                        }
                    };
                    LongitudeRange = range;
                }

                // Create the scatter list
                Scatter = new CallbackList <LandClassScatterAmountLoader>(e =>
                {
                    Value.scatter = Scatter.Where(s => !s.Delete).Select(s => s.Value).ToArray();
                });

                // Load scatters
                if (Value.scatter != null)
                {
                    for (Int32 i = 0; i < Value.scatter.Length; i++)
                    {
                        // Only activate the callback if we are adding the last loader
                        Scatter.Add(new LandClassScatterAmountLoader(Value.scatter[i]),
                                    i == Value.scatter.Length - 1);
                    }
                }
                else
                {
                    Value.scatter = new PQSLandControl.LandClassScatterAmount[0];
                }
            }
Пример #26
0
 protected StackingEvent(SimSharp.Simulation environment, Action <Event> callback, Action <Event> cancel) : base(environment)
 {
     CallbackList.Add(callback);
     Time    = environment.Now;
     _cancel = cancel;
 }
Пример #27
0
        // Grabs a PQSMod of type T from a parameter with a given PQS
        public override void Create(PQSMod_VertexPlanet mod, PQS pqsVersion)
        {
            base.Create(mod, pqsVersion);

            // Create mod components
            if (Continental == null)
            {
                Continental = new SimplexLoader();
            }
            else if (Mod.continental.GetType() == typeof(PQSMod_VertexPlanet.SimplexWrapper))
            {
                Continental = new SimplexLoader(Mod.continental);
            }

            if (ContinentalRuggedness == null)
            {
                ContinentalRuggedness = new SimplexLoader();
            }
            else if (Mod.continentalRuggedness.GetType() == typeof(PQSMod_VertexPlanet.SimplexWrapper))
            {
                ContinentalRuggedness = new SimplexLoader(Mod.continentalRuggedness);
            }

            if (ContinentalSharpness == null)
            {
                ContinentalSharpness = new NoiseModLoader();
            }

            if (ContinentalSharpnessMap == null)
            {
                ContinentalSharpnessMap = new SimplexLoader();
            }
            else if (Mod.continentalSharpnessMap.GetType() == typeof(PQSMod_VertexPlanet.SimplexWrapper))
            {
                ContinentalSharpnessMap = new SimplexLoader(Mod.continentalSharpnessMap);
            }

            if (TerrainType == null)
            {
                TerrainType = new SimplexLoader();
            }
            else if (Mod.terrainType.GetType() == typeof(PQSMod_VertexPlanet.SimplexWrapper))
            {
                TerrainType = new SimplexLoader(Mod.terrainType);
            }

            // Create the callback list
            LandClasses = new CallbackList <LandClassLoader>(e =>
            {
                Mod.landClasses = LandClasses.Where(landClass => !landClass.Delete)
                                  .Select(landClass => landClass.Value).ToArray();
            });

            // Load LandClasses
            if (Mod.landClasses != null)
            {
                for (Int32 i = 0; i < Mod.landClasses.Length; i++)
                {
                    // Only activate the callback if we are adding the last loader
                    LandClasses.Add(new LandClassLoader(Mod.landClasses[i]), i == Mod.landClasses.Length - 1);
                }
            }
            else
            {
                Mod.landClasses = new PQSMod_VertexPlanet.LandClass[0];
            }
        }
Пример #28
0
        // Grabs a PQSMod of type T from a parameter with a given PQS
        public override void Create(PQSLandControl mod, PQS pqsVersion)
        {
            base.Create(mod, pqsVersion);

            // Create the callback list for Scatters
            Scatters = new CallbackList <LandClassScatterLoader>(e =>
            {
                foreach (LandClassScatterLoader loader in Scatters)
                {
                    loader.Scatter.transform.parent = Mod.transform;
                }

                Mod.scatters = Scatters.Where(scatter => !scatter.Delete)
                               .Select(scatter => scatter.Value).ToArray();
            });

            // Load Scatters
            if (Mod.scatters != null)
            {
                for (Int32 i = 0; i < Mod.scatters.Length; i++)
                {
                    // Only activate the callback if we are adding the last loader
                    Scatters.Add(new LandClassScatterLoader(Mod.scatters[i]), i == Mod.scatters.Length - 1);
                }
            }
            else
            {
                Mod.scatters = new PQSLandControl.LandClassScatter[0];
            }

            // Create the callback list for LandClasses
            LandClasses = new CallbackList <LandClassLoader>(e =>
            {
                // Assign each scatter amount with their corresponding scatter
                foreach (PQSLandControl.LandClassScatterAmount amount in e.Scatter)
                {
                    Int32 i = 0;
                    while (i < Mod.scatters.Length)
                    {
                        if (Mod.scatters[i].scatterName.Equals(amount.scatterName))
                        {
                            break;
                        }

                        i++;
                    }

                    if (i >= Mod.scatters.Length)
                    {
                        continue;
                    }
                    amount.scatterIndex = i;
                    amount.scatter      = Mod.scatters[i];
                }

                // Assign the new values
                Mod.landClasses = LandClasses.Where(landClass => !landClass.Delete)
                                  .Select(landClass => landClass.Value).ToArray();
            });

            // Load LandClasses
            if (Mod.landClasses != null)
            {
                for (Int32 i = 0; i < Mod.landClasses.Length; i++)
                {
                    // Only activate the callback if we are adding the last loader
                    LandClasses.Add(new LandClassLoader(Mod.landClasses[i]), i == Mod.landClasses.Length - 1);
                }
            }
            else
            {
                Mod.landClasses = new PQSLandControl.LandClass[0];
            }
        }
Пример #29
0
 public Release(Environment environment, Request request, Action <Event> callback)
     : base(environment)
 {
     Request = request;
     CallbackList.Add(callback);
 }