Exemplo n.º 1
0
    protected void btn_Modity_Click(object sender, EventArgs e)
    {
        ObjectGroup r = new ObjectGroup();
        r.Code = lab_Code.Text.Trim();
        r.Name = txt_Name.Text.Trim();
        r.TypeCode = ddl_Type.SelectedValue.ToString();

        bool re = new ObjectGroupBLL().Update(r);
        if (re)
        {
            UtilityService.AlertAndRedirect(this, "修改成功!", "ObjectGroupMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this, "修改失败!");
        }
    }
Exemplo n.º 2
0
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        ObjectGroup r = new ObjectGroup();
        r.Name = txt_Name.Text.Trim();
        r.TypeCode = ddl_Type.SelectedValue.ToString();
        r.OrganID = (int)Session["OrganID"];
        r.InputBy = Session["UserID"].ToString();

        int re = new ObjectGroupBLL().Add(r);
        if (re > 0)
        {
            UtilityService.AlertAndRedirect(this, "添加成功!", "ObjectGroupMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this, "添加失败!");
        }
    }
Exemplo n.º 3
0
    public static GameObject InstantiateObject(ObjectGroup objectGroup, MapObject someMapObject, float scale)
    {
        GameObject newObject = null;

        if (objectGroup.name == "Collisions")
        {
            return null;

            //newObject = new GameObject();
            //newObject.name = objectGroup.name;
            //newObject.AddComponent<BoxCollider2D>().size = new Vector2(someMapObject.width / scale, someMapObject.height / scale);
            //newObject.GetComponent<BoxCollider2D>().offset = new Vector2(someMapObject.width / 2 / scale - 0.5f, someMapObject.height / 2 / scale - 0.5f);
        }
        else if (someMapObject.properties != null)
        {
            if (someMapObject.type == "Teleport")
            {
                newObject = new GameObject();
                newObject.name = objectGroup.name + " - TeleportTo: " + someMapObject.properties["TeleportTo"];
                TeleportToScript script = newObject.AddComponent<TeleportToScript>();
                string[] values = ((string)someMapObject.properties["TeleportTo"]).Split(',');
                script.mapName = values[0];
                script.position = new Vector2(float.Parse(values[1]), float.Parse(values[2]));

                string[] args = new string[1];
                args[0] = "Player";
                script.mask = LayerMask.GetMask(args);

                BoxCollider2D collider = newObject.AddComponent<BoxCollider2D>();
                collider.size = new Vector2(someMapObject.width / scale, someMapObject.height / scale);
                collider.offset = new Vector2(someMapObject.width / 2 / scale - 0.5f, someMapObject.height / 2 / scale - 0.5f);
                collider.isTrigger = true;
            }
        }

        return newObject;
    }
Exemplo n.º 4
0
        // show object
        internal static void ShowObject(int ObjectIndex, ObjectType Type)
        {
            if (ObjectManager.Objects[ObjectIndex] == null) {
                return;
            }
            if (ObjectManager.Objects[ObjectIndex].RendererIndex == 0) {
                if (ObjectCount >= Objects.Length) {
                    Array.Resize<Object>(ref Objects, Objects.Length << 1);
                }
                Objects[ObjectCount].ObjectIndex = ObjectIndex;
                Objects[ObjectCount].Type = Type;
                int f = ObjectManager.Objects[ObjectIndex].Mesh.Faces.Length;
                Objects[ObjectCount].FaceListReferences = new ObjectListReference[f];
                for (int i = 0; i < f; i++) {
                    bool alpha = false;
                    int k = ObjectManager.Objects[ObjectIndex].Mesh.Faces[i].Material;
                    Textures.OpenGlTextureWrapMode wrap = Textures.OpenGlTextureWrapMode.ClampClamp;
                    if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture != null | ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture != null) {

                        // HACK: Objects do not store information on the texture wrapping mode.
                        //       Let's determine the best wrapping mode now and then save it
                        //       so we can quickly access it in the rendering loop.

                        if (ObjectManager.Objects[ObjectIndex].Dynamic) {
                            wrap = Textures.OpenGlTextureWrapMode.RepeatRepeat;
                        } else {
                            for (int v = 0; v < ObjectManager.Objects[ObjectIndex].Mesh.Vertices.Length; v++) {
                                if (ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.X < 0.0f | ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.X > 1.0f) {
                                    wrap |= Textures.OpenGlTextureWrapMode.RepeatClamp;
                                }
                                if (ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.Y < 0.0f | ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.Y > 1.0f) {
                                    wrap |= Textures.OpenGlTextureWrapMode.ClampRepeat;
                                }
                            }
                        }

                        if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture != null) {
                            if (Textures.LoadTexture(ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture, wrap)) {
                                OpenBveApi.Textures.TextureTransparencyType type = ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture.Transparency;
                                if (type == OpenBveApi.Textures.TextureTransparencyType.Alpha) {
                                    alpha = true;
                                } else if (type == OpenBveApi.Textures.TextureTransparencyType.Partial & Interface.CurrentOptions.TransparencyMode == TransparencyMode.Quality) {
                                    alpha = true;
                                }
                            }
                        }
                        if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture != null) {
                            if (Textures.LoadTexture(ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture, wrap)) {
                                OpenBveApi.Textures.TextureTransparencyType type = ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture.Transparency;
                                if (type == OpenBveApi.Textures.TextureTransparencyType.Alpha) {
                                    alpha = true;
                                } else if (type == OpenBveApi.Textures.TextureTransparencyType.Partial & Interface.CurrentOptions.TransparencyMode == TransparencyMode.Quality) {
                                    alpha = true;
                                }
                            }
                        }
                    }
                    if (Type == ObjectType.Overlay & World.CameraRestriction != World.CameraRestrictionMode.NotAvailable) {
                        alpha = true;
                    } else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].Color.A != 255) {
                        alpha = true;
                    } else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].BlendMode == World.MeshMaterialBlendMode.Additive) {
                        alpha = true;
                    } else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].GlowAttenuationData != 0) {
                        alpha = true;
                    }
                    ObjectListType listType;
                    switch (Type) {
                        case ObjectType.Static:
                            listType = alpha ? ObjectListType.DynamicAlpha : ObjectListType.StaticOpaque;
                            break;
                        case ObjectType.Dynamic:
                            listType = alpha ? ObjectListType.DynamicAlpha : ObjectListType.DynamicOpaque;
                            break;
                        case ObjectType.Overlay:
                            listType = alpha ? ObjectListType.OverlayAlpha : ObjectListType.OverlayOpaque;
                            break;
                        default:
                            throw new InvalidOperationException();
                    }
                    if (listType == ObjectListType.StaticOpaque) {
                        /*
                         * For the static opaque list, insert the face into
                         * the first vacant position in the matching group's list.
                         * */
                        int groupIndex = (int)ObjectManager.Objects[ObjectIndex].GroupIndex;
                        if (groupIndex >= StaticOpaque.Length) {
                            if (StaticOpaque.Length == 0) {
                                StaticOpaque = new ObjectGroup[16];
                            }
                            while (groupIndex >= StaticOpaque.Length) {
                                Array.Resize<ObjectGroup>(ref StaticOpaque, StaticOpaque.Length << 1);
                            }
                        }
                        if (StaticOpaque[groupIndex] == null) {
                            StaticOpaque[groupIndex] = new ObjectGroup();
                        }
                        ObjectList list = StaticOpaque[groupIndex].List;
                        int newIndex = list.FaceCount;
                        for (int j = 0; j < list.FaceCount; j++) {
                            if (list.Faces[j] == null) {
                                newIndex = j;
                                break;
                            }
                        }
                        if (newIndex == list.FaceCount) {
                            if (list.FaceCount == list.Faces.Length) {
                                Array.Resize<ObjectFace>(ref list.Faces, list.Faces.Length << 1);
                            }
                            list.FaceCount++;
                        }
                        list.Faces[newIndex] = new ObjectFace();
                        list.Faces[newIndex].ObjectListIndex = ObjectCount;
                        list.Faces[newIndex].ObjectIndex = ObjectIndex;
                        list.Faces[newIndex].FaceIndex = i;

                        // HACK: Let's store the wrapping mode.
                        list.Faces[newIndex].Wrap = wrap;

                        StaticOpaque[groupIndex].Update = true;
                        Objects[ObjectCount].FaceListReferences[i] = new ObjectListReference(listType, newIndex);
                        Game.InfoStaticOpaqueFaceCount++;
                    } else {
                        /*
                         * For all other lists, insert the face at the end of the list.
                         * */
                        ObjectList list;
                        switch (listType) {
                            case ObjectListType.DynamicOpaque:
                                list = DynamicOpaque;
                                break;
                            case ObjectListType.DynamicAlpha:
                                list = DynamicAlpha;
                                break;
                            case ObjectListType.OverlayOpaque:
                                list = OverlayOpaque;
                                break;
                            case ObjectListType.OverlayAlpha:
                                list = OverlayAlpha;
                                break;
                            default:
                                throw new InvalidOperationException();
                        }
                        if (list.FaceCount == list.Faces.Length) {
                            Array.Resize<ObjectFace>(ref list.Faces, list.Faces.Length << 1);
                        }
                        list.Faces[list.FaceCount] = new ObjectFace();
                        list.Faces[list.FaceCount].ObjectListIndex = ObjectCount;
                        list.Faces[list.FaceCount].ObjectIndex = ObjectIndex;
                        list.Faces[list.FaceCount].FaceIndex = i;

                        // HACK: Let's store the wrapping mode.
                        list.Faces[list.FaceCount].Wrap = wrap;

                        Objects[ObjectCount].FaceListReferences[i] = new ObjectListReference(listType, list.FaceCount);
                        list.FaceCount++;
                    }

                }
                ObjectManager.Objects[ObjectIndex].RendererIndex = ObjectCount + 1;
                ObjectCount++;
            }
        }
Exemplo n.º 5
0
        private void CreatePolygons(ObjectGroup objectGroup)
        {
            foreach (var tiledObject in objectGroup.TiledObjects)
            {
                if (tiledObject.Polygon != null)
                {
                    var pointArr = tiledObject.Polygon.Points.Split(' ');
                    var vectorArray = new Vec2[pointArr.Length];
                    for (var i = 0; i < pointArr.Length; i++)
                    {
                        var pointCoords = pointArr[i].Split(',');
                        vectorArray[i] = new Vec2(
                            float.Parse(pointCoords[0], CultureInfo.InvariantCulture.NumberFormat),
                            float.Parse(pointCoords[1], CultureInfo.InvariantCulture.NumberFormat));
                    }

                    uint polyColor = 0;
                    if (tiledObject.Properties != null)
                    {
                        foreach (var property in tiledObject.Properties)
                        {
                            if (property.Property.Name.ToLower() == "colour" ||
                                property.Property.Name.ToLower() == "color")
                            {
                                polyColor = Convert.ToUInt32(property.Property.Value, 16) + 0xFF000000;
                            }
                        }
                        var poly = new Polygon(vectorArray, polyColor, this, tiledObject.ID, tiledObject.X,
                            tiledObject.Y);
                        poly.SetXY(tiledObject.X, tiledObject.Y);
                        _polyList.Add(poly);
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void loadObjectGroupsFromXML()
 {
     // get all object groups
         foreach (XmlNode objGroup in objectgroupNodes) {
             ObjectGroup group = new ObjectGroup();
             // Check all the attributes from the object group
             foreach (XmlAttribute groupAttribute in objGroup.Attributes) {
                 if (groupAttribute.Name == "name") group.Name = groupAttribute.InnerText;
                 if (groupAttribute.Name == "width") group.Width = int.Parse(groupAttribute.InnerText);
                 if (groupAttribute.Name == "height") group.Height = int.Parse(groupAttribute.InnerText);
             }
             // Now checks all the objects contained
             foreach (XmlNode obj in objGroup) {
                 TiledObject tiledObj = new TiledObject();
                 // Check all the attributes for the object
                 //Iterating throught the attributes of <object>
                 foreach (XmlAttribute attribute in obj.Attributes) {
                     if (attribute.Name == "name") tiledObj.Name = attribute.InnerText;
                     if (attribute.Name == "type") tiledObj.Type = attribute.InnerText;
                     if (attribute.Name == "x") tiledObj.X = int.Parse(attribute.InnerText);
                     if (attribute.Name == "y") tiledObj.Y = int.Parse(attribute.InnerText);
                     if (attribute.Name == "width") tiledObj.Width = int.Parse(attribute.InnerText);
                     if (attribute.Name == "height") tiledObj.Height = int.Parse(attribute.InnerText);
                 }
                 // Now loads all the properties for this same <object>
                 foreach (XmlNode properties in obj) {
                     foreach (XmlNode property in properties) {
                         string propertyName = "";
                         string propertyValue = "";
                         foreach (XmlAttribute propAttr in property.Attributes) {
                             if (propAttr.Name == "name") propertyName = propAttr.InnerText;
                             if (propAttr.Name == "value") propertyValue = propAttr.InnerText;
                         }
                         tiledObj.Properties.Add(propertyName, propertyValue);
                     }
                 }
                 group.Add(tiledObj);
             }
             objectGroups.Add(group);
         }
 }
Exemplo n.º 7
0
    private string AddPosition(string name,int organID,string fatherName)
    {
        if (name == "0" || name == string.Empty)
        {
            return "";
        }
        PositionBLL pBLL = new PositionBLL();
        bool _re = pBLL.Exists(name, organID);
        if (!_re)
        {
            string _fatherCode = pBLL.GetPosiCode(fatherName, organID);
            if (string.IsNullOrEmpty(_fatherCode))
            {
                _fatherCode = "0";
            }
            Position p = new Position();
            p.PosiName = name;
            p.FatherCode = _fatherCode;
            p.OrganID = organID;
            p.InputBy = Session["UserID"].ToString();

            bool re = pBLL.Add(p);

            if (re)
            {
                //添加数据组
                string _groupName = name + "数据组";
                try
                {
                    ObjectGroup r = new ObjectGroup();
                    r.Name = _groupName;
                    r.TypeCode = "T0001";
                    r.OrganID = organID;
                    r.InputBy = Session["UserID"].ToString();
                    int reOG = new ObjectGroupBLL().Add(r);
                    if (reOG > 0)
                    {
                        string _groupCode = new ObjectGroupBLL().GetObjectGroupCode(_groupName, organID);
                        string _pCode = pBLL.GetPosiCode(name, organID);

                        List<string> ogList = new List<string>();
                        ogList.Add(_groupCode);

                        int reP2O = new PositionBLL().AddPosi2ObjectGroup(_pCode, ogList);

                    }
                }
                catch
                {

                }
            }
        }
        string _Code = pBLL.GetPosiCode(name, organID);
        return _Code;
    }
Exemplo n.º 8
0
        static void ReadObjectGroup(XmlNode node, ref Map map)
        {
            ObjectGroup r = new ObjectGroup();
            r.Name = node.ReadTag("name");
            r.X = node.ReadInt("x");
            r.Y = node.ReadInt("y");
            r.Width = node.ReadInt("width");
            r.Height = node.ReadInt("height");

            if (node.HasChildNodes)
            {
                ColorConverter cc = new ColorConverter();
                foreach (XmlNode c in node.ChildNodes)
                {
                    MapObject o = new MapObject();
                    o.Name = c.ReadTag("name");
                    o.Type = c.ReadTag("type");
                    o.X = c.ReadInt("x");
                    o.Y = c.ReadInt("y");
                    o.Width = c.ReadInt("width");
                    o.Height = c.ReadInt("height");
                    o.Gid = c.ReadInt("gid", -1);

                    if (c.HasChildNodes)
                    {
                        foreach (XmlNode d in c.ChildNodes)
                        {
                            switch (d.Name)
                            {
                                case "properties":
                                    foreach (XmlNode e in d.ChildNodes)
                                    {
                                        o.Properties.Add(e.ReadTag("name"), e.ReadTag("value"));
                                    }
                                    break;
                                case "image":
                                    string cp = d.ReadTag("trans", "FFFFFF");
                                    if (cp.Length == 6 && !cp.StartsWith("#")) { cp = "#" + cp; }
                                    Color t = ColorTranslator.FromHtml(cp);
                                    if (d.Attributes["trans"] != null)
                                    {
                                        o.Images.Add(new Image() { Source = d.ReadTag("source"), TransColor = t, UseTransColor = true });
                                    }
                                    else
                                    {
                                        o.Images.Add(new Image() { Source = d.ReadTag("source"), TransColor = t, UseTransColor = false });
                                    }
                                    break;
                            }
                        }
                    }
                    r.Add(o);
                }
            }
            map.ObjectGroups.Add(r);
        }
Exemplo n.º 9
0
        public override bool Run()
        {
            var owner    = new UGUI("11223344-1122-1122-1122-123456789012");
            var regionID = new UUID("12345678-1234-1234-1234-123456789012");
            var scene    = new DummyScene(256, 256, regionID);
            var objgrp   = new ObjectGroup();
            var part     = new ObjectPart
            {
                Name = "Test Object"
            };
            var item = new ObjectPartInventoryItem
            {
                Name          = "Test Item",
                AssetType     = AssetType.CallingCard,
                InventoryType = InventoryType.CallingCard,
                Owner         = owner
            };

            part.Inventory.Add(item);
            objgrp.Add(1, part);
            objgrp.Owner     = owner;
            part.ObjectGroup = objgrp;
            objgrp.Scene     = scene;

            SceneListener listener = SimulationData.GetSceneListener(regionID);

            listener.StartStorageThread();
            try
            {
                m_Log.Info("Checking that region object data is empty");
                if (SimulationData.Objects.ObjectsInRegion(regionID).Count != 0)
                {
                    return(false);
                }
                m_Log.Info("Checking that region prim data is empty");
                if (SimulationData.Objects.PrimitivesInRegion(regionID).Count != 0)
                {
                    return(false);
                }
                m_Log.Info("Checking that actual object does not exist");
                if (SimulationData.Objects.LoadObjects(regionID).Count != 0)
                {
                    return(false);
                }

                m_Log.Info("Store object");
                listener.ScheduleUpdate(part.UpdateInfo, regionID);
                /* ensure working time for listener */
                m_Log.Info("Wait 2s for processing");
                Thread.Sleep(2000);

                List <UUID> resultList;
                m_Log.Info("Checking that region contains one object");
                resultList = SimulationData.Objects.ObjectsInRegion(regionID);
                if (resultList.Count != 1)
                {
                    return(false);
                }

                if (resultList[0] != objgrp.ID)
                {
                    return(false);
                }

                m_Log.Info("Checking that region contains one prim");
                resultList = SimulationData.Objects.PrimitivesInRegion(regionID);
                if (resultList.Count != 1)
                {
                    return(false);
                }
                m_Log.Info("Checking that actual object exists");
                List <ObjectGroup> objectList = SimulationData.Objects.LoadObjects(regionID);
                if (objectList.Count != 1)
                {
                    return(false);
                }

                m_Log.Info("Check that actual object contains one prim");
                if (objectList[0].Count != 1)
                {
                    return(false);
                }

                ObjectPart resPart;
                m_Log.Info("Try retrieving known prim");
                if (!objectList[0].TryGetValue(part.ID, out resPart))
                {
                    return(false);
                }

                m_Log.Info("Check that actual prim contains one item");
                if (resPart.Inventory.Count != 1)
                {
                    return(false);
                }

                m_Log.Info("Check that actual item has known ID");
                if (!resPart.Inventory.ContainsKey(item.ID))
                {
                    return(false);
                }

                m_Log.Info("Remove inventory item");
                resPart.Inventory.Remove(item.ID);
                item.UpdateInfo.SetRemovedItem();
                listener.ScheduleUpdate(item.UpdateInfo, regionID);
                /* ensure working time for listener */
                m_Log.Info("Wait 2s for processing");
                Thread.Sleep(2000);

                m_Log.Info("check that inventory item got deleted");
                objectList = SimulationData.Objects.LoadObjects(regionID);
                if (objectList.Count != 1 || !objectList[0].TryGetValue(part.ID, out resPart) || resPart.Inventory.Count != 0)
                {
                    return(false);
                }

                m_Log.Info("Remove prim");
                part.UpdateInfo.KillObject();
                listener.ScheduleUpdate(part.UpdateInfo, regionID);

                /* ensure working time for listener */
                m_Log.Info("Wait 2s for processing");
                Thread.Sleep(2000);

                m_Log.Info("Checking that region object data is empty");
                if (SimulationData.Objects.ObjectsInRegion(regionID).Count != 0)
                {
                    return(false);
                }
                m_Log.Info("Checking that region prim data is empty");
                if (SimulationData.Objects.PrimitivesInRegion(regionID).Count != 0)
                {
                    return(false);
                }
                m_Log.Info("Checking that actual object does not exist");
                if (SimulationData.Objects.LoadObjects(regionID).Count != 0)
                {
                    return(false);
                }
            }
            finally
            {
                listener.StopStorageThread();
            }
            return(true);
        }
Exemplo n.º 10
0
 public override void RezScriptsForObject(ObjectGroup group, int startparam = 0)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 11
0
 public bool CanReturn(IAgent agent, ObjectGroup group, Vector3 location) =>
 CanReturn(agent.Owner, group, location);
Exemplo n.º 12
0
        public bool CanMove(IAgent agent, ObjectGroup group, Vector3 location)
        {
            UGUI agentOwner = agent.Owner;
            UGUI groupOwner = group.Owner;

            if (IsPossibleGod(agentOwner))
            {
                if (group.RootPart.IsLocked && groupOwner.EqualsGrid(agentOwner))
                {
                    return(false);
                }
                return(true);
            }
            /* deny modification of admin objects by non-admins */
            else if (IsPossibleGod(groupOwner))
            {
                return(false);
            }

            /* check locked state */
            if (group.RootPart.IsLocked)
            {
                return(false);
            }

            /* check object owner */
            if (agentOwner.EqualsGrid(groupOwner))
            {
                return(true);
            }
            else if (group.IsAttached)
            {
                /* others should not be able to edit attachments */
                return(false);
            }

#warning Add Friends Rights to CanMove

            if (group.RootPart.CheckPermissions(agentOwner, agent.Group, InventoryPermissionsMask.Move))
            {
                return(true);
            }
            else if ((group.RootPart.EveryoneMask & InventoryPermissionsMask.Move) != 0)
            {
                return(true);
            }

            if (HasGroupPower(agent.Owner, group.Group, GroupPowers.ObjectManipulate))
            {
                return(true);
            }

            ParcelInfo pinfo;
            if (Parcels.TryGetValue(location, out pinfo))
            {
                if (pinfo.Owner.EqualsGrid(agentOwner))
                {
                    return(true);
                }

                if (HasGroupPower(agent.Owner, pinfo.Group, GroupPowers.ObjectManipulate))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 13
0
        private void BuildCrane(IRepository repository)
        {
            var gpm = new ObjectGroup {
                Name = "Грузоподъёмные механизмы"
            };
            var electroCranes = new ObjectGroup {
                Name = "Краны электрические"
            };
            var bridgeCranes = new ObjectGroup {
                Name = "Краны мостовые"
            };

            gpm.AddChild(electroCranes);
            electroCranes.AddChild(bridgeCranes);

            var fullTO = new MaintenanceInterval
                         (
                MaintenanceTypeFactory.TO_Full,
                null, null, null, 1,
                TimePeriod.Month,
                36
                         );

            var partialTO = new MaintenanceInterval
                            (
                MaintenanceTypeFactory.TO_Partial,
                null, null, null, 1,
                TimePeriod.Month,
                12
                            );

            var O = new MaintenanceInterval
                    (
                MaintenanceTypeFactory.O_Repair,
                null, null, null, 14,
                TimePeriod.Month,
                6
                    );

            var T = new MaintenanceInterval
                    (
                MaintenanceTypeFactory.T_Repair,
                null, null, null, 13,
                TimePeriod.Month,
                12
                    );

            var K = new MaintenanceInterval
                    (
                MaintenanceTypeFactory.K_Repair,
                null, null, null, 1,
                TimePeriod.Month,
                186
                    );

            bridgeCranes.AddIntervals(fullTO, partialTO, O, T, K);
            repository.Save(gpm);

            Crane = new MaintenanceObject(bridgeCranes, "", DateTime.Now);
            Crane.AddSpecificationsFromGroup();
            repository.Save(Crane);
        }
Exemplo n.º 14
0
        private void BuildCompressor(IRepository repository)
        {
            var nko = new ObjectGroup {
                Name = "Насосно-компрессорное оборудование"
            };
            var kompressors = new ObjectGroup {
                Name = "Компрессоры"
            };
            var kompressorsTypes = new ObjectGroup {
                Name = "Поршневые"
            };
            var kompressorsModels = new ObjectGroup {
                Name = "5Г-300/15-30"
            };

            nko.AddChild(kompressors);
            kompressors.AddChild(kompressorsTypes);
            kompressorsTypes.AddChild(kompressorsModels);

            kompressors.AddSpecification(new GroupSpecification(SpecificationFactory.InjectionPressure));

            var O = new MaintenanceInterval(
                MaintenanceTypeFactory.O_Repair,
                MeasureUnitFactory.WorkHours,
                2630,
                3210,
                12
                );
            var T = new MaintenanceInterval(
                MaintenanceTypeFactory.T_Repair,
                MeasureUnitFactory.WorkHours,
                5260,
                6420,
                6
                );
            var C = new MaintenanceInterval(
                MaintenanceTypeFactory.C_Repair,
                MeasureUnitFactory.WorkHours,
                10520,
                12840,
                5
                );
            var K = new MaintenanceInterval(
                MaintenanceTypeFactory.K_Repair,
                MeasureUnitFactory.WorkHours,
                63120,
                77040,
                1
                );

            kompressorsTypes.AddIntervals(O, T, C, K);

            repository.Save(nko);

            Compressor = new MaintenanceObject(kompressorsModels, "КП-1", DateTime.Now);
            Compressor.AddSpecificationsFromGroup();
            Compressor.Specifications.First().Value = "11,2";
            Compressor.AddChild(ElectroMotor);

            repository.Save(Compressor);
        }
Exemplo n.º 15
0
        /// <summary>Makes an object visible within the world</summary>
        /// <param name="ObjectIndex">The object's index</param>
        /// <param name="Type">Whether this is a static or dynamic object</param>
        internal static void ShowObject(int ObjectIndex, ObjectType Type)
        {
            if (ObjectManager.Objects[ObjectIndex] == null)
            {
                return;
            }
            if (ObjectManager.Objects[ObjectIndex].RendererIndex == 0)
            {
                if (ObjectCount >= Objects.Length)
                {
                    Array.Resize <Object>(ref Objects, Objects.Length << 1);
                }
                Objects[ObjectCount].ObjectIndex = ObjectIndex;
                Objects[ObjectCount].Type        = Type;
                int f = ObjectManager.Objects[ObjectIndex].Mesh.Faces.Length;
                Objects[ObjectCount].FaceListReferences = new ObjectListReference[f];
                for (int i = 0; i < f; i++)
                {
                    bool alpha = false;
                    int  k     = ObjectManager.Objects[ObjectIndex].Mesh.Faces[i].Material;
                    OpenGlTextureWrapMode wrap = OpenGlTextureWrapMode.ClampClamp;
                    if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture != null | ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture != null)
                    {
                        if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].WrapMode == null)
                        {
                            // If the object does not have a stored wrapping mode, determine it now
                            for (int v = 0; v < ObjectManager.Objects[ObjectIndex].Mesh.Vertices.Length; v++)
                            {
                                if (ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.X <0.0f |
                                                                                                              ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.X> 1.0f)
                                {
                                    wrap |= OpenGlTextureWrapMode.RepeatClamp;
                                }
                                if (ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.Y <0.0f |
                                                                                                              ObjectManager.Objects[ObjectIndex].Mesh.Vertices[v].TextureCoordinates.Y> 1.0f)
                                {
                                    wrap |= OpenGlTextureWrapMode.ClampRepeat;
                                }
                            }
                        }
                        else
                        {
                            //Yuck cast, but we need the null, as otherwise requires rewriting the texture indexer
                            wrap = (OpenGlTextureWrapMode)ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].WrapMode;
                        }
                        if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture != null)
                        {
                            if (Textures.LoadTexture(ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture, wrap))
                            {
                                TextureTransparencyType type =
                                    ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].DaytimeTexture.Transparency;
                                if (type == TextureTransparencyType.Alpha)
                                {
                                    alpha = true;
                                }
                                else if (type == TextureTransparencyType.Partial &&
                                         Interface.CurrentOptions.TransparencyMode == TransparencyMode.Quality)
                                {
                                    alpha = true;
                                }
                            }
                        }
                        if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture != null)
                        {
                            if (Textures.LoadTexture(ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture, wrap))
                            {
                                TextureTransparencyType type =
                                    ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].NighttimeTexture.Transparency;
                                if (type == TextureTransparencyType.Alpha)
                                {
                                    alpha = true;
                                }
                                else if (type == TextureTransparencyType.Partial &
                                         Interface.CurrentOptions.TransparencyMode == TransparencyMode.Quality)
                                {
                                    alpha = true;
                                }
                            }
                        }
                    }
                    if (Type == ObjectType.Overlay & World.CameraRestriction != Camera.RestrictionMode.NotAvailable)
                    {
                        alpha = true;
                    }
                    else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].Color.A != 255)
                    {
                        alpha = true;
                    }
                    else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].BlendMode == MeshMaterialBlendMode.Additive)
                    {
                        alpha = true;
                    }
                    else if (ObjectManager.Objects[ObjectIndex].Mesh.Materials[k].GlowAttenuationData != 0)
                    {
                        alpha = true;
                    }
                    ObjectListType listType;
                    switch (Type)
                    {
                    case ObjectType.Static:
                        listType = alpha ? ObjectListType.DynamicAlpha : ObjectListType.StaticOpaque;
                        break;

                    case ObjectType.Dynamic:
                        listType = alpha ? ObjectListType.DynamicAlpha : ObjectListType.DynamicOpaque;
                        break;

                    case ObjectType.Overlay:
                        listType = alpha ? ObjectListType.OverlayAlpha : ObjectListType.OverlayOpaque;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                    if (listType == ObjectListType.StaticOpaque)
                    {
                        /*
                         * For the static opaque list, insert the face into
                         * the first vacant position in the matching group's list.
                         * */
                        int groupIndex = (int)ObjectManager.Objects[ObjectIndex].GroupIndex;
                        if (groupIndex >= StaticOpaque.Length)
                        {
                            if (StaticOpaque.Length == 0)
                            {
                                StaticOpaque = new ObjectGroup[16];
                            }
                            while (groupIndex >= StaticOpaque.Length)
                            {
                                Array.Resize <ObjectGroup>(ref StaticOpaque, StaticOpaque.Length << 1);
                            }
                        }
                        if (StaticOpaque[groupIndex] == null)
                        {
                            StaticOpaque[groupIndex] = new ObjectGroup();
                        }
                        ObjectList list     = StaticOpaque[groupIndex].List;
                        int        newIndex = list.FaceCount;
                        for (int j = 0; j < list.FaceCount; j++)
                        {
                            if (list.Faces[j] == null)
                            {
                                newIndex = j;
                                break;
                            }
                        }
                        if (newIndex == list.FaceCount)
                        {
                            if (list.FaceCount == list.Faces.Length)
                            {
                                Array.Resize <ObjectFace>(ref list.Faces, list.Faces.Length << 1);
                            }
                            list.FaceCount++;
                        }
                        list.Faces[newIndex] = new ObjectFace
                        {
                            ObjectListIndex = ObjectCount,
                            ObjectIndex     = ObjectIndex,
                            FaceIndex       = i,
                            Wrap            = wrap
                        };

                        // HACK: Let's store the wrapping mode.

                        StaticOpaque[groupIndex].Update            = true;
                        Objects[ObjectCount].FaceListReferences[i] = new ObjectListReference(listType, newIndex);
                        Game.InfoStaticOpaqueFaceCount++;

                        /*
                         * Check if the given object has a bounding box, and insert it to the end of the list of bounding boxes if required
                         */
                        if (ObjectManager.Objects[ObjectIndex].Mesh.BoundingBox != null)
                        {
                            int Index = list.BoundingBoxes.Length;
                            for (int j = 0; j < list.BoundingBoxes.Length; j++)
                            {
                                if (list.Faces[j] == null)
                                {
                                    Index = j;
                                    break;
                                }
                            }
                            if (Index == list.BoundingBoxes.Length)
                            {
                                Array.Resize <BoundingBox>(ref list.BoundingBoxes, list.BoundingBoxes.Length << 1);
                            }
                            list.BoundingBoxes[Index].Upper = ObjectManager.Objects[ObjectIndex].Mesh.BoundingBox[0];
                            list.BoundingBoxes[Index].Lower = ObjectManager.Objects[ObjectIndex].Mesh.BoundingBox[1];
                        }
                    }
                    else
                    {
                        /*
                         * For all other lists, insert the face at the end of the list.
                         * */
                        ObjectList list;
                        switch (listType)
                        {
                        case ObjectListType.DynamicOpaque:
                            list = DynamicOpaque;
                            break;

                        case ObjectListType.DynamicAlpha:
                            list = DynamicAlpha;
                            break;

                        case ObjectListType.OverlayOpaque:
                            list = OverlayOpaque;
                            break;

                        case ObjectListType.OverlayAlpha:
                            list = OverlayAlpha;
                            break;

                        default:
                            throw new InvalidOperationException();
                        }
                        if (list.FaceCount == list.Faces.Length)
                        {
                            Array.Resize <ObjectFace>(ref list.Faces, list.Faces.Length << 1);
                        }
                        list.Faces[list.FaceCount] = new ObjectFace
                        {
                            ObjectListIndex = ObjectCount,
                            ObjectIndex     = ObjectIndex,
                            FaceIndex       = i,
                            Wrap            = wrap
                        };

                        // HACK: Let's store the wrapping mode.

                        Objects[ObjectCount].FaceListReferences[i] = new ObjectListReference(listType, list.FaceCount);
                        list.FaceCount++;
                    }
                }
                ObjectManager.Objects[ObjectIndex].RendererIndex = ObjectCount + 1;
                ObjectCount++;
            }
        }