Esempio n. 1
0
 public static TileData GetNaturalWall(MaterialID materialID)
 {
     return(new TileData()
     {
         ID = TileID.NaturalWall, MaterialID = materialID
     });
 }
Esempio n. 2
0
        public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (EditorID != null)
            {
                ele.TryPathTo("EditorID", true, out subEle);
                EditorID.WriteXML(subEle, master);
            }
            if (Name != null)
            {
                ele.TryPathTo("Name", true, out subEle);
                Name.WriteXML(subEle, master);
            }
            if (NoiseMap != null)
            {
                ele.TryPathTo("NoiseMap", true, out subEle);
                NoiseMap.WriteXML(subEle, master);
            }
            if (Opacity != null)
            {
                ele.TryPathTo("Opacity", true, out subEle);
                Opacity.WriteXML(subEle, master);
            }
            if (WaterFlags != null)
            {
                ele.TryPathTo("WaterFlags", true, out subEle);
                WaterFlags.WriteXML(subEle, master);
            }
            if (MaterialID != null)
            {
                ele.TryPathTo("MaterialID", true, out subEle);
                MaterialID.WriteXML(subEle, master);
            }
            if (Sound != null)
            {
                ele.TryPathTo("Sound", true, out subEle);
                Sound.WriteXML(subEle, master);
            }
            if (ActorEffect != null)
            {
                ele.TryPathTo("ActorEffect", true, out subEle);
                ActorEffect.WriteXML(subEle, master);
            }
            if (Damage != null)
            {
                ele.TryPathTo("Damage", true, out subEle);
                Damage.WriteXML(subEle, master);
            }
            if (Data != null)
            {
                ele.TryPathTo("Data", true, out subEle);
                Data.WriteXML(subEle, master);
            }
            if (RelatedWaters != null)
            {
                ele.TryPathTo("RelatedWaters", true, out subEle);
                RelatedWaters.WriteXML(subEle, master);
            }
        }
Esempio n. 3
0
 protected ConcreteObject(ObjectType objectType, ConcreteObjectBuilder builder)
     : base(objectType, builder)
 {
     m_name = builder.Name;
     m_color = builder.Color;
     m_materialID = builder.MaterialID;
 }
Esempio n. 4
0
 public bool Match(ItemID itemID, ItemCategory itemCategory, MaterialID materialID, MaterialCategory materialCategory)
 {
     return((m_itemIDMask == null || m_itemIDMask.Get(itemID)) &&
            (m_itemCategoryMask == null || m_itemCategoryMask.Get(itemCategory)) &&
            (m_materialIDMask == null || m_materialIDMask.Get(materialID)) &&
            (m_materialCategoryMask == null || m_materialCategoryMask.Get(materialCategory)));
 }
Esempio n. 5
0
        static ItemObject CreateItem(EnvironmentObject env, ItemID itemID, MaterialID materialID, IntVector3 p)
        {
            var builder = new ItemObjectBuilder(itemID, materialID);
            var item    = builder.Create(env.World);

            item.MoveToMustSucceed(env, p);
            return(item);
        }
Esempio n. 6
0
 public static Material GetMaterial(MaterialID resource)
 {
     if (!Instance.materials.TryGetValue(resource, out Material material))
     {
         Assert.IsTrue(Instance.materialsMap.ContainsKey(resource));
         material = Resources.Load <Material>(Instance.materialsMap[resource]);
         Instance.materials.Add(resource, material);
     }
     return(material);
 }
Esempio n. 7
0
        public void AddMaterialParameters(string materialName, MaterialID materialID, Color color)
        {
            MaterialParameters parameters = new MaterialParameters
            {
                materialType = materialID,
                baseColor    = color
            };

            MixerUtils.materialsParameters[materialName] = parameters;
        }
Esempio n. 8
0
    private void UpdateMesh(List <Vector3> input, Mesh mesh, MaterialID matid, UVMapper uvMapper)
    {
        Vertex3[] inputVtx3 = new Vertex3[input.Count];
        CastToVertex3(input, inputVtx3);

        ConvexHull <Vertex3, Face3> hull = ConvexHull.Create <Vertex3, Face3>(inputVtx3, 0.0001);

//        List<Vertex3> hullVtx3 = new List<Vertex3>(hull.Points);
        List <Vertex3> hullVtx3 = new List <Vertex3>();
        List <Face3>   faces    = new List <Face3>(hull.Faces);

        int[] indices = new int[faces.Count * 3];

        int n = 0;

        for (int i = 0; i < faces.Count; ++i)
        {
            // Sometime in the future, I'd like each side of the log
            // to share vertices, and only separate them along the
            // cardinal edges.

            // This is how we do it when we want to separate each
            // triangle. We create a vertex for each point of each
            // triangle.
            hullVtx3.Add(faces[i].Vertices[0]);
            indices[n++] = hullVtx3.Count - 1;
            hullVtx3.Add(faces[i].Vertices[1]);
            indices[n++] = hullVtx3.Count - 1;
            hullVtx3.Add(faces[i].Vertices[2]);
            indices[n++] = hullVtx3.Count - 1;

            // This is the way to do it when you want to share
            // vertices between triangles. That's not going to
            // work with texture atlassing.
//            indices[n++] = hullVtx3.IndexOf(faces[i].Vertices[0]);
//            indices[n++] = hullVtx3.IndexOf(faces[i].Vertices[1]);
//            indices[n++] = hullVtx3.IndexOf(faces[i].Vertices[2]);
        }

        Vector3[] vertices = new Vector3[hullVtx3.Count];
        CastToVector3(hullVtx3, vertices);

        mesh.Clear();
        mesh.vertices = vertices;
        mesh.SetIndices(indices, MeshTopology.Triangles, 0);

        MaterialData md    = MaterialIndex.GetMaterialData(matIndex, matid);
        UVMapFn      mapFn = UVMapper.GetMapFunction(uvMapper, md.mapFnID);

        UVMapper.SetUV(md, mesh, mapFn);

        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
    }
Esempio n. 9
0
        private static GameObject Create(PaintTools what, Color color)
        {
            GameObject rootObject = new GameObject();

            rootObject.transform.parent        = SceneManager.RightHanded;
            rootObject.transform.localPosition = Vector3.zero;
            rootObject.transform.localRotation = Quaternion.identity;
            rootObject.transform.localScale    = Vector3.one;

            GameObject gobject = new GameObject();

            gobject.transform.parent = rootObject.transform;
            gobject.name             = Utils.CreateUniqueName(what == PaintTools.Volume ? "Volume" : "Paint");

            gobject.transform.localPosition = Vector3.zero;
            gobject.transform.localRotation = Quaternion.identity;
            gobject.transform.localScale    = Vector3.one;
            gobject.tag = "PhysicObject";

            Mesh mesh = new Mesh
            {
                indexFormat = UnityEngine.Rendering.IndexFormat.UInt32
            };
            MeshFilter meshFilter = gobject.AddComponent <MeshFilter>();

            meshFilter.mesh = mesh;
            MeshRenderer renderer      = gobject.AddComponent <MeshRenderer>();
            MaterialID   materialId    = color.a == 1f ? MaterialID.ObjectOpaque : MaterialID.ObjectTransparent;
            Material     paintMaterial = ResourceManager.GetMaterial(materialId);

            renderer.sharedMaterial = paintMaterial;
            renderer.material.SetColor("_BaseColor", color);
            renderer.material.SetFloat("_Opacity", color.a);

            // Update scene data for live sync
            SceneManager.AddMaterialParameters(Utils.GetMaterialName(gobject), materialId, color);

            gobject.AddComponent <MeshCollider>();

            if (what == PaintTools.Volume)
            {
                gobject.AddComponent <VolumeController>();
            }
            else
            {
                gobject.AddComponent <PaintController>();
            }

            return(gobject);
        }
        public void Initialise()
        {
            LevelMaterialID           = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterMaterialID       = new MaterialID(Engine.Singleton.NewtonWorld);
            TriggerVolumeMaterialID   = new MaterialID(Engine.Singleton.NewtonWorld);
            DescribedMaterialID       = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterSensorMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            EnemyMaterialID           = new MaterialID(Engine.Singleton.NewtonWorld);
            NoColID = new MaterialID(Engine.Singleton.NewtonWorld);


            //

            NoColLevelPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                LevelMaterialID, NoColID);
            NoColLevelPair.SetContactCallback(new IgnoreCollisionCallback());

            NoColDMPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, NoColID);
            NoColDMPair.SetContactCallback(new IgnoreCollisionCallback());

            NoColCharPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                CharacterMaterialID, NoColID);
            NoColCharPair.SetContactCallback(new IgnoreCollisionCallback());

            //

            SensorLevelPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                LevelMaterialID, CharacterSensorMaterialID);
            SensorLevelPair.SetContactCallback(new IgnoreCollisionCallback());

            SensorTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                TriggerVolumeMaterialID, CharacterSensorMaterialID);
            SensorTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            DescribedTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, TriggerVolumeMaterialID);
            DescribedTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            EnemyTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                EnemyMaterialID, TriggerVolumeMaterialID);
            EnemyTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());
        }
Esempio n. 11
0
        public static void CreateBaseMinerals(TerrainData terrain, Random random, double xk, double yk)
        {
            int width  = terrain.Width;
            int height = terrain.Height;
            int depth  = terrain.Depth;

            var rockMaterials = Materials.GetMaterials(MaterialCategory.Rock).ToArray();
            var layers        = new MaterialID[20];

            {
                int        rep = 0;
                MaterialID mat = MaterialID.Undefined;
                for (int z = 0; z < layers.Length; ++z)
                {
                    if (rep == 0)
                    {
                        rep = random.Next(4) + 1;
                        mat = rockMaterials[random.Next(rockMaterials.Length - 1)].ID;
                    }

                    layers[z] = mat;
                    rep--;
                }
            }

            Parallel.For(0, height, y =>
            {
                for (int x = 0; x < width; ++x)
                {
                    int surface = terrain.GetSurfaceLevel(x, y);

                    for (int z = 0; z < surface; ++z)
                    {
                        var p = new IntVector3(x, y, z);

                        int _z = MyMath.Round(z + x * xk + y * yk);

                        _z = _z % layers.Length;

                        if (_z < 0)
                        {
                            _z += layers.Length;
                        }

                        terrain.SetTileDataNoHeight(p, TileData.GetNaturalWall(layers[_z]));
                    }
                }
            });
        }
        public void Initialise()
        {
            LevelMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            TriggerVolumeMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            DescribedMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterSensorMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            EnemyMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            NoColID = new MaterialID(Engine.Singleton.NewtonWorld);

            //

            NoColLevelPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                LevelMaterialID, NoColID);
            NoColLevelPair.SetContactCallback(new IgnoreCollisionCallback());

            NoColDMPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, NoColID);
            NoColDMPair.SetContactCallback(new IgnoreCollisionCallback());

            NoColCharPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                CharacterMaterialID, NoColID);
            NoColCharPair.SetContactCallback(new IgnoreCollisionCallback());

            //

            SensorLevelPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                LevelMaterialID, CharacterSensorMaterialID);
            SensorLevelPair.SetContactCallback(new IgnoreCollisionCallback());

            SensorTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                TriggerVolumeMaterialID, CharacterSensorMaterialID);
            SensorTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            DescribedTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, TriggerVolumeMaterialID);
            DescribedTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            EnemyTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                EnemyMaterialID, TriggerVolumeMaterialID);
            EnemyTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());
        }
Esempio n. 13
0
        public static WoodMaterialCategory GetWoodMaterialCategory(MaterialID materialID)
        {
            switch (materialID)
            {
            case MaterialID.Fir:
            case MaterialID.Pine:
                return(WoodMaterialCategory.Coniferous);

            case MaterialID.Birch:
            case MaterialID.Oak:
                return(WoodMaterialCategory.Deciduous);

            default:
                throw new Exception();
            }
        }
Esempio n. 14
0
 public override void WriteData(ESPWriter writer)
 {
     if (EditorID != null)
     {
         EditorID.WriteBinary(writer);
     }
     if (Name != null)
     {
         Name.WriteBinary(writer);
     }
     if (NoiseMap != null)
     {
         NoiseMap.WriteBinary(writer);
     }
     if (Opacity != null)
     {
         Opacity.WriteBinary(writer);
     }
     if (WaterFlags != null)
     {
         WaterFlags.WriteBinary(writer);
     }
     if (MaterialID != null)
     {
         MaterialID.WriteBinary(writer);
     }
     if (Sound != null)
     {
         Sound.WriteBinary(writer);
     }
     if (ActorEffect != null)
     {
         ActorEffect.WriteBinary(writer);
     }
     if (Damage != null)
     {
         Damage.WriteBinary(writer);
     }
     if (Data != null)
     {
         Data.WriteBinary(writer);
     }
     if (RelatedWaters != null)
     {
         RelatedWaters.WriteBinary(writer);
     }
 }
Esempio n. 15
0
        public static void CreateBaseMinerals(TerrainData terrain, Random random, double xk, double yk)
        {
            int width = terrain.Width;
            int height = terrain.Height;
            int depth = terrain.Depth;

            var rockMaterials = Materials.GetMaterials(MaterialCategory.Rock).ToArray();
            var layers = new MaterialID[20];

            {
                int rep = 0;
                MaterialID mat = MaterialID.Undefined;
                for (int z = 0; z < layers.Length; ++z)
                {
                    if (rep == 0)
                    {
                        rep = random.Next(4) + 1;
                        mat = rockMaterials[random.Next(rockMaterials.Length - 1)].ID;
                    }

                    layers[z] = mat;
                    rep--;
                }
            }

            Parallel.For(0, height, y =>
            {
                for (int x = 0; x < width; ++x)
                {
                    int surface = terrain.GetSurfaceLevel(x, y);

                    for (int z = 0; z < surface; ++z)
                    {
                        var p = new IntVector3(x, y, z);

                        int _z = MyMath.Round(z + x * xk + y * yk);

                        _z = _z % layers.Length;

                        if (_z < 0)
                            _z += layers.Length;

                        terrain.SetTileDataNoHeight(p, TileData.GetNaturalWall(layers[_z]));
                    }
                }
            });
        }
Esempio n. 16
0
        static void CreateOreCluster(TerrainData terrain, IntVector3 p, MaterialID oreMaterialID, int count)
        {
            bool b = CreateOre(terrain, p, oreMaterialID);

            if (b == false)
            {
                return;
            }

            if (count > 0)
            {
                foreach (var d in DirectionExtensions.CardinalUpDownDirections)
                {
                    CreateOreCluster(terrain, p + d, oreMaterialID, count - 1);
                }
            }
        }
Esempio n. 17
0
    public void NewListsForEachPlayerSFX()
    {
        NewListOfAudioClips(footSteps, currentFootSteps);
        NewListOfAudioClips(jumpSounds, currentJumpSounds);
        NewListOfAudioClips(landingSounds, currentLandingSounds);
        NewListOfAudioClips(climbingSounds, currentClimbingSounds);

        if (currentFootSteps.Count == 0 || currentJumpSounds.Count == 0 || currentLandingSounds.Count == 0)
        {
            materialID = MaterialID.Default;
            NewListOfAudioClips(footSteps, currentFootSteps);
            NewListOfAudioClips(jumpSounds, currentJumpSounds);
            NewListOfAudioClips(landingSounds, currentLandingSounds);
            NewListOfAudioClips(climbingSounds, currentClimbingSounds);

            if (debugOn)
            {
                Debug.Log("One of the current PlayerSFX was empty, so all PlayerSFX are set to Default Material");
            }
        }
    }
Esempio n. 18
0
 public static Material LoadMaterial(MaterialID matID)
 {
     if (matID == MaterialID.PLANE_INVISIBLE)
     {
         return((Material)Resources.Load("Materials/UnlitInvisible"));
     }
     else if (matID == MaterialID.PLANE_VISBLE)
     {
         return((Material)Resources.Load("Materials/PlaneDefault"));
     }
     else if (matID == MaterialID.PLANE_LINE_VISIBLE)
     {
         return((Material)Resources.Load("Materials/PlaneLineDefault"));
     }
     else if (matID == MaterialID.WATER)
     {
         return((Material)Resources.Load("Materials/Water"));
     }
     else
     {
         return((Material)Resources.Load("Materials/PlaneDefault"));
     }
 }
Esempio n. 19
0
        static bool CreateOre(TerrainData terrain, IntVector3 p, MaterialID oreMaterialID)
        {
            if (!terrain.Contains(p))
            {
                return(false);
            }

            var td = terrain.GetTileData(p);

            if (td.ID != TileID.NaturalWall)
            {
                return(false);
            }

            if (Materials.GetMaterial(td.MaterialID).Category != MaterialCategory.Rock)
            {
                return(false);
            }

            td.SecondaryMaterialID = oreMaterialID;
            terrain.SetTileDataNoHeight(p, td);

            return(true);
        }
        static ItemObject CreateItem(EnvironmentObject env, ItemID itemID, MaterialID materialID, IntPoint3 p)
        {
            var builder = new ItemObjectBuilder(itemID, materialID);
            var item = builder.Create(env.World);
            var ok = item.MoveTo(env, p);
            if (!ok)
                throw new Exception();

            return item;
        }
Esempio n. 21
0
 static ItemObject CreateItem(EnvironmentObject env, ItemID itemID, MaterialID materialID, IntVector3 p)
 {
     var builder = new ItemObjectBuilder(itemID, materialID);
     var item = builder.Create(env.World);
     item.MoveToMustSucceed(env, p);
     return item;
 }
Esempio n. 22
0
        static bool CreateOre(TerrainData terrain, IntVector3 p, MaterialID oreMaterialID)
        {
            if (!terrain.Contains(p))
                return false;

            var td = terrain.GetTileData(p);

            if (td.ID != TileID.NaturalWall)
                return false;

            if (Materials.GetMaterial(td.MaterialID).Category != MaterialCategory.Rock)
                return false;

            td.SecondaryMaterialID = oreMaterialID;
            terrain.SetTileDataNoHeight(p, td);

            return true;
        }
Esempio n. 23
0
        public static MaterialInfo GetMaterial(MaterialID id)
        {
            Debug.Assert(s_materials[(int)id] != null);

            return s_materials[(int)id];
        }
Esempio n. 24
0
 public ItemObjectBuilder(ItemID itemID, MaterialID materialID)
 {
     this.ItemID = itemID;
     this.MaterialID = materialID;
 }
Esempio n. 25
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Name", false, out subEle))
            {
                if (Name == null)
                {
                    Name = new SimpleSubrecord <String>();
                }

                Name.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("NoiseMap", false, out subEle))
            {
                if (NoiseMap == null)
                {
                    NoiseMap = new SimpleSubrecord <String>();
                }

                NoiseMap.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Opacity", false, out subEle))
            {
                if (Opacity == null)
                {
                    Opacity = new SimpleSubrecord <Byte>();
                }

                Opacity.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("WaterFlags", false, out subEle))
            {
                if (WaterFlags == null)
                {
                    WaterFlags = new SimpleSubrecord <WaterFlags>();
                }

                WaterFlags.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("MaterialID", false, out subEle))
            {
                if (MaterialID == null)
                {
                    MaterialID = new SimpleSubrecord <String>();
                }

                MaterialID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Sound", false, out subEle))
            {
                if (Sound == null)
                {
                    Sound = new RecordReference();
                }

                Sound.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ActorEffect", false, out subEle))
            {
                if (ActorEffect == null)
                {
                    ActorEffect = new RecordReference();
                }

                ActorEffect.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Damage", false, out subEle))
            {
                if (Damage == null)
                {
                    Damage = new SimpleSubrecord <UInt16>();
                }

                Damage.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new WaterData();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("RelatedWaters", false, out subEle))
            {
                if (RelatedWaters == null)
                {
                    RelatedWaters = new RelatedWaters();
                }

                RelatedWaters.ReadXML(subEle, master);
            }
        }
Esempio n. 26
0
        public void MFCS_Submit(IEnumerable <DTOCommand> cmds)
        {
            try
            {
                ServiceHostBase sh = OperationContext.Current.Host;
                if (!(sh is WarehouseServiceHost))
                {
                    throw new WCFServiceException("Host is wrong type.");
                }

                var warehouse = (sh as WarehouseServiceHost).Warehouse;

                try
                {
                    using (MFCSEntities dc = new MFCSEntities())
                    {
                        foreach (var c in cmds)
                        {
                            if (c.Status != (int)Command.EnumCommandStatus.Canceled)
                            {
                                MaterialID matID = dc.MaterialIDs.Find((int)c.TU_ID);
                                if (matID == null)
                                {
                                    dc.MaterialIDs.Add(new MaterialID {
                                        ID = c.TU_ID, Size = 1, Weight = 1
                                    });
                                }
                                dc.Commands.Add(new CommandMaterial
                                {
                                    WMS_ID   = c.Order_ID,
                                    Source   = c.Source,
                                    Target   = c.Target,
                                    Info     = "WMS",
                                    Material = c.TU_ID,
                                    Priority = 0,
                                    Status   = (Command.EnumCommandStatus)c.Status,
                                    Task     = Command.EnumCommandTask.Move,
                                    Time     = DateTime.Now,
                                    Reason   = Command.EnumCommandReason.OK
                                });
                                warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.WMS, $"MFCS_AddMoveCommands called {c.ToString()}");
                            }
                            else
                            {
                                if (c.Order_ID >= 0)
                                {
                                    Command cc = dc.Commands.FirstOrDefault(p => p.WMS_ID == c.Order_ID);
                                    if (cc != null)
                                    {
                                        dc.Commands.Add(new CommandCommand
                                        {
                                            WMS_ID    = -1,
                                            Task      = Command.EnumCommandTask.CancelCommand,
                                            CommandID = cc.ID,
                                            Priority  = 0,
                                            Status    = Command.EnumCommandStatus.NotActive,
                                            Time      = DateTime.Now
                                        });
                                    }
                                }
                            }
                        }
                        dc.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception,
                                       string.Format("{0}.{1}: {2}, MFCS_Submit exception.",
                                                     this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
                    throw new FaultException(e.Message);
                }
            }
            catch (Exception ee)
            {
                throw new FaultException(ee.Message);
            }
        }
Esempio n. 27
0
        public void Initialise()
        {
            LevelMaterialID           = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterMaterialID       = new MaterialID(Engine.Singleton.NewtonWorld);
            TriggerVolumeMaterialID   = new MaterialID(Engine.Singleton.NewtonWorld);
            DescribedMaterialID       = new MaterialID(Engine.Singleton.NewtonWorld);
            CharacterSensorMaterialID = new MaterialID(Engine.Singleton.NewtonWorld);
            EnemyMaterialID           = new MaterialID(Engine.Singleton.NewtonWorld);
            WaypointMaterialID        = new MaterialID(Engine.Singleton.NewtonWorld);

            TriggerVolumeCharacterPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                CharacterMaterialID, TriggerVolumeMaterialID);
            TriggerVolumeCharacterPair.SetContactCallback(new TriggerVolumeGameObjectCallback());

            CharacterSensorPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                CharacterMaterialID, CharacterSensorMaterialID);
            CharacterSensorPair.SetContactCallback(new SensorGameObjectCallback());

            SensorLevelPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                LevelMaterialID, CharacterSensorMaterialID);
            //SensorLevelPair.SetContactCallback(new IgnoreCollisionCallback());
            SensorLevelPair.SetContactCallback(new SensorGameObjectCallback());

            SensorTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                TriggerVolumeMaterialID, CharacterSensorMaterialID);
            SensorTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            SensorDescribedObjectPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, CharacterSensorMaterialID);
            SensorDescribedObjectPair.SetContactCallback(new SensorGameObjectCallback());

            DescribedTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                DescribedMaterialID, TriggerVolumeMaterialID);
            DescribedTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            EnemyTriggerVolumePair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                EnemyMaterialID, TriggerVolumeMaterialID);
            EnemyTriggerVolumePair.SetContactCallback(new IgnoreCollisionCallback());

            EnemySensorPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                EnemyMaterialID, CharacterSensorMaterialID);
            EnemySensorPair.SetContactCallback(new SensorGameObjectCallback());

            WaypointCharacterPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                WaypointMaterialID, CharacterMaterialID);
            WaypointCharacterPair.SetContactCallback(new IgnoreCollisionCallback());

            WaypointTriggerPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                WaypointMaterialID, TriggerVolumeMaterialID);
            WaypointTriggerPair.SetContactCallback(new IgnoreCollisionCallback());

            WaypointEnemyPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                WaypointMaterialID, EnemyMaterialID);
            WaypointEnemyPair.SetContactCallback(new IgnoreCollisionCallback());

            WaypointDescribedPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                WaypointMaterialID, DescribedMaterialID);
            WaypointDescribedPair.SetContactCallback(new IgnoreCollisionCallback());

            WaypointSensorPair = new MaterialPair(
                Engine.Singleton.NewtonWorld,
                WaypointMaterialID, CharacterSensorMaterialID);
            WaypointSensorPair.SetContactCallback(new IgnoreCollisionCallback());
        }
Esempio n. 28
0
        static void CreateOreCluster(TerrainData terrain, IntVector3 p, MaterialID oreMaterialID, int count)
        {
            bool b = CreateOre(terrain, p, oreMaterialID);
            if (b == false)
                return;

            if (count > 0)
            {
                foreach (var d in DirectionExtensions.CardinalUpDownDirections)
                    CreateOreCluster(terrain, p + d, oreMaterialID, count - 1);
            }
        }
Esempio n. 29
0
 public ItemObjectBuilder(ItemID itemID, MaterialID materialID)
 {
     this.ItemID     = itemID;
     this.MaterialID = materialID;
 }
Esempio n. 30
0
 public static TileData GetNaturalWall(MaterialID materialID)
 {
     return new TileData() { ID = TileID.NaturalWall, MaterialID = materialID };
 }
Esempio n. 31
0
        public static MaterialInfo GetMaterial(MaterialID id)
        {
            Debug.Assert(s_materials[(int)id] != null);

            return(s_materials[(int)id]);
        }
Esempio n. 32
0
        public override void CreateAndSendTOTelegram(SimpleCommand cmd)
        {
            try
            {
                if (!(cmd is SimpleCraneCommand))
                {
                    throw new CraneException(String.Format("{0} is not SimpleCraneCommand.", cmd.ToString()));
                }

                SimpleCraneCommand Cmd = cmd as SimpleCraneCommand;

                MaterialID matID = null;
                if (Cmd.Material.HasValue)
                {
                    matID = Warehouse.DBService.FindMaterialID((int)Cmd.Material, true);
                }

                LPosition pos = LPosition.FromString(Cmd.Source);
                if (!pos.IsWarehouse())
                {
                    if (cmd.Task == SimpleCommand.EnumTask.Pick)
                    {
                        pos = FindInConveyor(cmd.Source).CraneAddress;
                    }
                    else if (cmd.Task == SimpleCommand.EnumTask.Drop)
                    {
                        pos = FindOutConveyor(cmd.Source).CraneAddress;
                    }
                    else if (cmd.Task == SimpleCommand.EnumTask.Move)
                    {
                        pos = FindInOutConveyor(cmd.Source).CraneAddress;
                    }
                    else if (cmd.Task == SimpleCommand.EnumTask.Cancel)
                    {
                        pos = CraneAddress;
                        if (!cmd.CancelID.HasValue)
                        {
                            throw new CraneException(String.Format("{0} Parameter null", cmd != null ? cmd.ToString() : "null"));
                        }
                    }
                    else if (cmd.Task >= SimpleCommand.EnumTask.Delete)
                    {
                        pos = CraneAddress;
                    }
                }
                if (matID == null && cmd.Task != SimpleCommand.EnumTask.Move && cmd.Task != SimpleCommand.EnumTask.Cancel)
                {
                    throw new CraneException(String.Format("Command validity fault ({0})", cmd.ToString()));
                }

                Communicator.AddSendTelegram(
                    new Telegrams.TelegramCraneTO
                {
                    Sender    = Communicator.MFCS_ID,
                    Receiver  = Communicator.PLC_ID,
                    MFCS_ID   = cmd.ID,
                    Order     = (short)cmd.Task,
                    Buffer_ID = (cmd.Task != SimpleCommand.EnumTask.Cancel) ? (matID != null ? matID.ID : 0) : cmd.CancelID.Value,
                    Position  = new Telegrams.Position {
                        R = (short)pos.Shelve, X = (short)pos.Travel, Y = (short)pos.Height, Z = (short)pos.Depth
                    },
                    Palette = new Telegrams.Palette {
                        Barcode = Convert.ToUInt32(matID != null ? matID.ID : 0), Type = (Int16)(matID != null ? matID.Size : 0), Weight = (UInt16)(matID != null ? matID.Weight : 0)
                    },
                    ID = PLC_ID
                });
                cmd.Status = SimpleCommand.EnumStatus.Written;
                Warehouse.DBService.UpdateSimpleCommand(cmd);
                Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, cmd.ToString());

                // check for blocked locations
                LPosition p = LPosition.FromString(cmd.Source);
                string    frontLoc;

                if (p.Shelve > 0 && p.Depth == 2)
                {
                    LPosition pOther = new LPosition {
                        Shelve = p.Shelve, Travel = p.Travel, Height = p.Height, Depth = 1
                    };
                    frontLoc = pOther.ToString();
                }
                else
                {
                    frontLoc = cmd.Source;
                }
                if (Warehouse.DBService.FindPlaceID(cmd.Source) != null &&
                    (Warehouse.DBService.FindPlaceID(cmd.Source).Blocked || Warehouse.DBService.FindPlaceID(frontLoc).Blocked))
                {
                    Warehouse.Segment[Segment].AlarmRequest(0);
                    Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Command, string.Format("Location blocked. Command: {0}", cmd.ToString()));
                }

                if (cmd.Command_ID.HasValue)
                {
                    Command command = Warehouse.DBService.FindCommandByID(cmd.Command_ID.Value);
                    if (command == null)
                    {
                        throw new ConveyorException($"Command {command.ToString()} null.");
                    }
                    if (command.Status < Database.Command.EnumCommandStatus.Active)
                    {
                        command.Status = Database.Command.EnumCommandStatus.Active;
                        Warehouse.DBService.UpdateCommand(command);
                        Warehouse.OnCommandFinish?.Invoke(command);
                    }
                }
            }
            catch (Exception ex)
            {
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message);
                throw new CraneException(String.Format("{0} Crane.CreateAndSendTOTelegram failed. ({1})", Name, cmd != null ? cmd.ToString() : "null"));
            }
        }
Esempio n. 33
0
        void CreateBaseGrid()
        {
            int width = m_size.Width;
            int height = m_size.Height;
            int depth = m_size.Depth;

            var rockMaterials = Materials.GetMaterials(MaterialCategory.Rock).ToArray();
            var layers = new MaterialID[20];

            {
                int rep = 0;
                MaterialID mat = MaterialID.Undefined;
                for (int z = 0; z < layers.Length; ++z)
                {
                    if (rep == 0)
                    {
                        rep = m_random.Next(4) + 1;
                        mat = rockMaterials[m_random.Next(rockMaterials.Length - 1)].ID;
                    }

                    layers[z] = mat;
                    rep--;
                }
            }

            double xk = (GetRandomDouble() * 2 - 1) * 0.01;
            double yk = (GetRandomDouble() * 2 - 1) * 0.01;

            m_rockLayerSlant = new Tuple<double, double>(xk, yk);

            Parallel.For(0, height, y =>
            {
                for (int x = 0; x < width; ++x)
                {
                    int surface = m_data.GetHeight(x, y);

                    for (int z = 0; z < depth; ++z)
                    {
                        var p = new IntPoint3(x, y, z);
                        var td = new TileData();

                        if (z < surface)
                        {
                            td.TerrainID = TerrainID.NaturalWall;

                            int _z = (int)Math.Round(z + x * xk + y * yk);

                            _z = _z % layers.Length;

                            if (_z < 0)
                                _z += layers.Length;

                            td.TerrainMaterialID = layers[_z];
                        }
                        else if (z == surface)
                        {
                            td.TerrainID = TerrainID.NaturalFloor;
                            td.TerrainMaterialID = GetTileData(new IntPoint3(x, y, z - 1)).TerrainMaterialID;
                        }
                        else
                        {
                            td.TerrainID = TerrainID.Empty;
                            td.TerrainMaterialID = MaterialID.Undefined;
                        }

                        td.InteriorID = InteriorID.Empty;
                        td.InteriorMaterialID = MaterialID.Undefined;

                        SetTileData(p, td);
                    }
                }
            });
        }
Esempio n. 34
0
        void CreateOreSphere(IntPoint3 center, int r, MaterialID oreMaterialID, double probIn, double probOut)
        {
            // adjust r, so that r == 1 gives sphere of one tile
            r -= 1;

            // XXX split the sphere into 8 parts, and mirror

            var bb = new IntGrid3(center.X - r, center.Y - r, center.Z - r, r * 2 + 1, r * 2 + 1, r * 2 + 1);

            var rs = MyMath.Square(r);

            foreach (var p in bb.Range())
            {
                var y = p.Y;
                var x = p.X;
                var z = p.Z;

                var v = MyMath.Square(x - center.X) + MyMath.Square(y - center.Y) + MyMath.Square(z - center.Z);

                if (rs >= v)
                {
                    var rr = Math.Sqrt(v);

                    double rel;

                    if (r == 0)
                        rel = 1;
                    else
                        rel = 1 - rr / r;

                    var prob = (probIn - probOut) * rel + probOut;

                    if (GetRandomDouble() <= prob)
                        CreateOre(p, oreMaterialID);
                }
            }
        }
Esempio n. 35
0
        void CreateOreCluster(IntPoint3 p, MaterialID oreMaterialID, int count)
        {
            if (!m_size.Contains(p))
                return;

            var td = GetTileData(p);

            if (td.TerrainID != TerrainID.NaturalWall)
                return;

            if (td.InteriorID == InteriorID.Ore)
                return;

            td.InteriorID = InteriorID.Ore;
            td.InteriorMaterialID = oreMaterialID;
            SetTileData(p, td);

            if (count > 0)
            {
                foreach (var d in DirectionExtensions.CardinalUpDownDirections)
                    CreateOreCluster(p + d, oreMaterialID, count - 1);
            }
        }
Esempio n. 36
0
 void CreateOreCluster(IntPoint3 p, MaterialID oreMaterialID)
 {
     CreateOreCluster(p, oreMaterialID, GetRandomInt(6) + 1);
 }
Esempio n. 37
0
 public bool Match(ItemID itemID, ItemCategory itemCategory, MaterialID materialID, MaterialCategory materialCategory)
 {
     return (m_itemIDMask == null || m_itemIDMask.Get(itemID)) &&
         (m_itemCategoryMask == null || m_itemCategoryMask.Get(itemCategory)) &&
         (m_materialIDMask == null || m_materialIDMask.Get(materialID)) &&
         (m_materialCategoryMask == null || m_materialCategoryMask.Get(materialCategory));
 }
Esempio n. 38
0
 static void CreateOreCluster(TerrainData terrain, Random random, IntVector3 p, MaterialID oreMaterialID)
 {
     CreateOreCluster(terrain, p, oreMaterialID, random.Next(6) + 1);
 }
Esempio n. 39
0
 public static MaterialData GetMaterialData(MaterialIndex index, MaterialID id)
 {
     return(index.materials[id]);
 }
Esempio n. 40
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "FULL":
                    if (Name == null)
                    {
                        Name = new SimpleSubrecord <String>();
                    }

                    Name.ReadBinary(reader);
                    break;

                case "NNAM":
                    if (NoiseMap == null)
                    {
                        NoiseMap = new SimpleSubrecord <String>();
                    }

                    NoiseMap.ReadBinary(reader);
                    break;

                case "ANAM":
                    if (Opacity == null)
                    {
                        Opacity = new SimpleSubrecord <Byte>();
                    }

                    Opacity.ReadBinary(reader);
                    break;

                case "FNAM":
                    if (WaterFlags == null)
                    {
                        WaterFlags = new SimpleSubrecord <WaterFlags>();
                    }

                    WaterFlags.ReadBinary(reader);
                    break;

                case "MNAM":
                    if (MaterialID == null)
                    {
                        MaterialID = new SimpleSubrecord <String>();
                    }

                    MaterialID.ReadBinary(reader);
                    break;

                case "SNAM":
                    if (Sound == null)
                    {
                        Sound = new RecordReference();
                    }

                    Sound.ReadBinary(reader);
                    break;

                case "XNAM":
                    if (ActorEffect == null)
                    {
                        ActorEffect = new RecordReference();
                    }

                    ActorEffect.ReadBinary(reader);
                    break;

                case "DATA":
                    ReadDamage(reader);
                    break;

                case "DNAM":
                    if (Data == null)
                    {
                        Data = new WaterData();
                    }

                    Data.ReadBinary(reader);
                    break;

                case "GNAM":
                    if (RelatedWaters == null)
                    {
                        RelatedWaters = new RelatedWaters();
                    }

                    RelatedWaters.ReadBinary(reader);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
Esempio n. 41
0
 public MaterialViewModel()
 {
     _material = new MaterialID();
     Validator = new PropertyValidator();
 }
Esempio n. 42
0
 public bool Match(ItemID itemID, ItemCategory itemCategory, MaterialID materialID, MaterialCategory materialCategory)
 {
     return m_itemIDMask.Get(itemID) &&
         m_itemCategoryMask.Get(itemCategory) &&
         m_materialIDMask.Get(materialID) &&
         m_materialCategoryMask.Get(materialCategory);
 }
Esempio n. 43
0
 public static void AddMaterialParameters(string materialName, MaterialID materialID, Color color)
 {
     Instance.scene.AddMaterialParameters(materialName, materialID, color);
 }
Esempio n. 44
0
        public static WoodMaterialCategory GetWoodMaterialCategory(MaterialID materialID)
        {
            switch (materialID)
            {
                case MaterialID.Fir:
                case MaterialID.Pine:
                    return WoodMaterialCategory.Coniferous;

                case MaterialID.Birch:
                case MaterialID.Oak:
                    return WoodMaterialCategory.Deciduous;

                default:
                    throw new Exception();
            }
        }
Esempio n. 45
0
 public static IEnumerable<BPMaterial> GetMaterialsRaw(MaterialID material)
 {
     using (var cnn = new SQLiteConnection(DefaultDatabase.dbConnection))
     {
         cnn.Open();
         var query = @"SELECT m.materialTypeID, m.quantity
     FROM invTypeMaterials AS m
      INNER JOIN invTypes AS t
       ON m.typeID = t.typeID
     WHERE m.typeID = " + material + ";";
         var reader = DefaultDatabase.RunSQLTableQuery(query, cnn);
         var results = new List<BPMaterial>();
         while (reader.Read())
         {
             results.Add(new BPMaterial(new MaterialID(reader["materialTypeID"].ToInt()), reader["quantity"].ToLong()));
         }
         return results;
     }
 }
Esempio n. 46
0
        public override void CreateAndSendTOTelegram(SimpleCommand cmd)
        {
            try
            {
                if (!(cmd is SimpleConveyorCommand))
                {
                    throw new ConveyorException(String.Format("{0} is not SimpleCoveyorCommand", cmd.ToString()));
                }

                SimpleConveyorCommand Cmd = cmd as SimpleConveyorCommand;

                MaterialID matID = Warehouse.DBService.FindMaterialID((int)cmd.Material, true);

                short task;
                switch (Cmd.Task)
                {
                case SimpleCommand.EnumTask.Move:
                    task = TelegramTransportTO.ORDER_MOVE;
                    break;

                case SimpleCommand.EnumTask.Delete:
                    task = TelegramTransportTO.ORDER_PALETTEDELETE;
                    break;

                case SimpleCommand.EnumTask.Create:
                    task = TelegramTransportTO.ORDER_PALETTECREATE;
                    break;

                case SimpleCommand.EnumTask.Cancel:
                    throw new NotImplementedException();

                default:
                    throw new ConveyorException(String.Format("{0} has unknown Order", Cmd.ToString()));
                }

                if (Warehouse.Conveyor.ContainsKey(Cmd.Source))
                {
                    Communicator.AddSendTelegram(new TelegramTransportTO
                    {
                        MFCS_ID  = Cmd.ID,
                        Sender   = Communicator.MFCS_ID,
                        Receiver = Communicator.PLC_ID,
                        Order    = task,
                        Palette  = new Palette {
                            Barcode = (UInt32)Cmd.Material, Type = (short)matID.Size, Weight = (ushort)matID.Weight
                        },
                        SenderTransport = Warehouse.FindConveyorBasic(Cmd.Source).ConveyorAddress,
                        Source          = Warehouse.FindConveyorBasic(Cmd.Source).ConveyorAddress,
                        Target          = Warehouse.FindConveyorBasic(Cmd.Target).ConveyorAddress
                    });

                    cmd.Status = SimpleCommand.EnumStatus.Written;
                    Warehouse.DBService.UpdateSimpleCommand(cmd);
                    Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, cmd.ToString());

                    if (cmd.Command_ID.HasValue)
                    {
                        Command command = Warehouse.DBService.FindCommandByID(cmd.Command_ID.Value);
                        if (command == null)
                        {
                            throw new ConveyorException($"Command {command.ToString()} null.");
                        }
                        if (command.Status < Database.Command.EnumCommandStatus.Active)
                        {
                            command.Status = Database.Command.EnumCommandStatus.Active;
                            Warehouse.DBService.UpdateCommand(command);
                            Warehouse.OnCommandFinish?.Invoke(command);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, e.Message);
                throw new ConveyorException(String.Format("{0} Conveyor.CreateAndSendTOTelegram failed ({1}).", Name, cmd != null ? cmd.ToString() : "null"));
            }
        }
Esempio n. 47
0
        public static IEnumerable<BPMaterial> GetMaterialsReprocessing(MaterialID material)
        {
            return GetMaterialsRaw(material); // seems like

            //            var query = @"SELECT t.MaterialID, m.quantity
            //FROM invTypeMaterials AS m
            // INNER JOIN invTypes AS t
            //  ON m.materialTypeID = t.MaterialID
            //WHERE m.MaterialID =" + material + ";";
            //            var results = DefaultDatabase.RunSQLTableQuery(query);

            //            return from DataRow row in results.Rows
            //                   select new BPMaterial(row["MaterialID"].ToInt(), row["quantity"].ToLong());
        }
Esempio n. 48
0
 static void CreateOreCluster(TerrainData terrain, Random random, IntVector3 p, MaterialID oreMaterialID)
 {
     CreateOreCluster(terrain, p, oreMaterialID, random.Next(6) + 1);
 }
Esempio n. 49
0
 public static IEnumerable<MaterialID> GetMetaGroupVersionOfT1(MaterialID matID, int metaGroupID)
 {
     using (var cnn = new SQLiteConnection(DefaultDatabase.dbConnection))
     {
         cnn.Open();
         var query = @"select typeId from invMetaTypes where parentTypeID = " + matID + " and metaGroupID = " + metaGroupID;
         var results = DefaultDatabase.RunSQLTableQuery(query, cnn);
         var t1Name = CommonQueries.GetTypeName(matID);
         while (results.Read())
         {
             yield return new MaterialID(results["typeID"].ToInt());
         }
     }
 }
Esempio n. 50
0
 public void AddMaterialParameters(string materialName, MaterialID materialID, Color color)
 {
 }
Esempio n. 51
0
 public static MaterialID GetT1VersionOfT2(MaterialID matID)
 {
     var query = @"select parentTypeID from invMetaTypes where typeID = " + matID + ";";
     return new MaterialID(DefaultDatabase.RunSQLStringQuery(query).ToInt());
 }
Esempio n. 52
0
        static void CreateOreSphere(TerrainData terrain, Random random, IntVector3 center, int r, MaterialID oreMaterialID, double probIn, double probOut)
        {
            // adjust r, so that r == 1 gives sphere of one tile
            r -= 1;

            // XXX split the sphere into 8 parts, and mirror

            var bb = new IntGrid3(center.X - r, center.Y - r, center.Z - r, r * 2 + 1, r * 2 + 1, r * 2 + 1);

            var rs = MyMath.Square(r);

            foreach (var p in bb.Range())
            {
                var y = p.Y;
                var x = p.X;
                var z = p.Z;

                var v = MyMath.Square(x - center.X) + MyMath.Square(y - center.Y) + MyMath.Square(z - center.Z);

                if (rs >= v)
                {
                    var rr = Math.Sqrt(v);

                    double rel;

                    if (r == 0)
                    {
                        rel = 1;
                    }
                    else
                    {
                        rel = 1 - rr / r;
                    }

                    var prob = (probIn - probOut) * rel + probOut;

                    if (random.NextDouble() <= prob)
                    {
                        CreateOre(terrain, p, oreMaterialID);
                    }
                }
            }
        }
Esempio n. 53
0
 public static MaterialID GetT2VersionOfT1(MaterialID matID, string outputName = null)
 {
     var result = GetMetaGroupVersionOfT1(matID, 2); // note metaGroup not metaLevel
     return result.FirstOrDefault(r => outputName != null ? CommonQueries.GetTypeName(r) == outputName : true);
 }
Esempio n. 54
0
 public static BlueprintID GetBlueprintFromProduct(MaterialID matID)
 {
     // not sure if there's a better way of doing this
     return GetBlueprintID(GetTypeName(matID));
 }
Esempio n. 55
0
        void CreateOre(IntPoint3 p, MaterialID oreMaterialID)
        {
            if (!m_size.Contains(p))
                return;

            var td = GetTileData(p);

            if (td.TerrainID != TerrainID.NaturalWall)
                return;

            td.InteriorID = InteriorID.Ore;
            td.InteriorMaterialID = oreMaterialID;
            SetTileData(p, td);
        }