示例#1
0
    public static bool DoesComponentFitInSlot(ComponentSlot _slot, ComponentObject _comp, out float _efficiency)
    {
        _efficiency = 0;

        if ((_slot.SlotType != _comp.Type && _comp.StaticInfo.EfficiencyInOtherSlots.Find(x => x.Type == _slot.SlotType) == null))
        {
            return(false);            // stop if the held component doesn't match the slot and can't be jury-rigged into the slot
        }
        // determine how good a match the component is
        if (_slot.SlotTypeID == _comp.TypeID)
        {
            _efficiency = 1;
        }
        else
        {
            int _effIndex = _comp.StaticInfo.EfficiencyInOtherSlots.FindIndex(x => x.Type == _slot.SlotType);
            if (_effIndex > -1)
            {
                _efficiency = _comp.StaticInfo.EfficiencyInOtherSlots[_effIndex].Efficiency;
            }
        }

        if (_efficiency == 0)
        {
            return(false);            // stop if the held component is as good as a non-match
        }
        return(true);
    }
示例#2
0
        Component ImportComponent(string tempDir, ComponentObject compObj)
        {
            Component component = importRepo.ComponentRepo.Get(compObj.Id);

            bool isNew = false;

            if (component == null)
            {
                isNew     = true;
                component = new Component();
            }

            MapSerializableEntityToComponent(tempDir, compObj, component);

            if (isNew)
            {
                importRepo.ComponentRepo.Save(component);
            }
            else
            {
                importRepo.ComponentRepo.SaveOrUpdate(component);
            }

            return(component);
        }
示例#3
0
    void ToggleVisible(bool _enable, CanInspect _newIO = null, ComponentObject _trackedComponent = null)
    {
        if (OwnerInspectable != null && _enable)
        {
            ToggleVisible(false);
            // Debug.LogError(name + " already has an OwnerIO!");
        }

        OwnerInspectable = _newIO;
        trackedComponent = _trackedComponent;

        for (int i = 0; i < images.Length; i++)
        {
            images[i].enabled = _enable;
        }
        for (int i = 0; i < Buttons.Length; i++)
        {
            Buttons[i].enabled = _enable;
        }
        for (int i = 0; i < texts.Length; i++)
        {
            texts[i].enabled = _enable;
        }

        transform.SetParent(_enable ? myCanvas.transform : GUIManager.Instance.transform);
        if (!_enable)
        {
            OwnerInspectable = null;
        }
    }
示例#4
0
        void MapSerializableEntityToComponent(string tempDir, ComponentObject compObj, Component component, Joint joint = null)
        {
            component.Id                 = compObj.Id;
            component.IsActive           = compObj.IsActive;
            component.Certificate        = compObj.Certificate;
            component.Type               = ImportComponentType(compObj.Type);
            component.Number             = compObj.Number;
            component.Length             = compObj.Length;
            component.IsAvailableToJoint = compObj.IsAvailableToJoint;
            component.ConstructionStatus = compObj.ConstructionStatus;
            component.InspectionStatus   = compObj.InspectionStatus;

            if (compObj.Attachments != null)
            {
                component.Attachments = new List <Domain.Entity.File>();
                foreach (var file in compObj.Attachments)
                {
                    component.Attachments.Add(ImportFile(file, component.Id));
                }
            }

            if (compObj.Connectors != null)
            {
                component.Connectors = new List <Connector>();
                foreach (var connector in compObj.Connectors)
                {
                    component.Connectors.Add(ImportConnector(tempDir, connector, component, joint));
                }
            }
        }
示例#5
0
    public void Read(TProtocol iprot)
    {
        bool   isset_bolt_object = false;
        bool   isset_common      = false;
        TField field;

        iprot.ReadStructBegin();
        while (true)
        {
            field = iprot.ReadFieldBegin();
            if (field.Type == TType.Stop)
            {
                break;
            }
            switch (field.ID)
            {
            case 1:
                if (field.Type == TType.Struct)
                {
                    Bolt_object = new ComponentObject();
                    Bolt_object.Read(iprot);
                    isset_bolt_object = true;
                }
                else
                {
                    TProtocolUtil.Skip(iprot, field.Type);
                }
                break;

            case 2:
                if (field.Type == TType.Struct)
                {
                    Common = new ComponentCommon();
                    Common.Read(iprot);
                    isset_common = true;
                }
                else
                {
                    TProtocolUtil.Skip(iprot, field.Type);
                }
                break;

            default:
                TProtocolUtil.Skip(iprot, field.Type);
                break;
            }
            iprot.ReadFieldEnd();
        }
        iprot.ReadStructEnd();
        if (!isset_bolt_object)
        {
            throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
        if (!isset_common)
        {
            throw new TProtocolException(TProtocolException.INVALID_DATA);
        }
    }
示例#6
0
    //return component is changes have been made
    public Component RestoreSettings()
    {
        Component resultChangedComponent = null;

        if (!_isComponentObjectNull)
        {
            ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component;
        }
        else
        {
            ComponentObject = null;
        }

        if (ComponentObject != null && _values != null)
        {
            foreach (var name in _values.Keys)
            {
                var newValue = _values[name];

                var property = ComponentObject.GetType().GetProperty(name);

                if (null != property)
                {
                    var currentValue = property.GetValue(ComponentObject, null);

                    if (!HasValueChanged(newValue, currentValue))
                    {
                        continue;
                    }
                    property.SetValue(ComponentObject, newValue, null);
                    resultChangedComponent = ComponentObject;
                }
                else
                {
                    var field        = ComponentObject.GetType().GetField(name);
                    var currentValue = field.GetValue(ComponentObject);

                    if (!HasValueChanged(newValue, currentValue))
                    {
                        continue;
                    }

                    field.SetValue(ComponentObject, newValue);
                    resultChangedComponent = ComponentObject;
                }
            }
        }

        _values = null;

        return(resultChangedComponent);
    }
示例#7
0
        ComponentObject FindComponentById(Data data, Guid id)
        {
            ComponentObject result = null;

            if (data.Components != null)
            {
                foreach (ComponentObject c in data.Components)
                {
                    if (c.Id == id)
                    {
                        result = c;
                        break;
                    }
                }
            }
            return(result);
        }
示例#8
0
    private List <FieldInfo> GetFields(List <string> propertiesToIgnore)
    {
        List <FieldInfo> fields = new List <FieldInfo>();

        foreach (FieldInfo fieldInfo in ComponentObject.GetType().GetFields())
        {
            if (fieldInfo.IsPublic && !propertiesToIgnore.Contains(fieldInfo.Name))
            {
                if (!Attribute.IsDefined(fieldInfo, typeof(HideInInspector)))
                {
                    fields.Add(fieldInfo);
                }
            }
        }

        return(fields);
    }
示例#9
0
 public void Read (TProtocol iprot)
 {
   bool isset_bolt_object = false;
   bool isset_common = false;
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.Struct) {
           Bolt_object = new ComponentObject();
           Bolt_object.Read(iprot);
           isset_bolt_object = true;
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Common = new ComponentCommon();
           Common.Read(iprot);
           isset_common = true;
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
   if (!isset_bolt_object)
     throw new TProtocolException(TProtocolException.INVALID_DATA);
   if (!isset_common)
     throw new TProtocolException(TProtocolException.INVALID_DATA);
 }
示例#10
0
    private IEnumerable <FieldInfo> GetFields()
    {
        var fields = new List <FieldInfo>();

        foreach (var fieldInfo in ComponentObject.GetType().GetFields())
        {
            if (!fieldInfo.IsPublic)
            {
                continue;
            }

            if (!Attribute.IsDefined(fieldInfo, typeof(HideInInspector)))
            {
                fields.Add(fieldInfo);
            }
        }

        return(fields);
    }
示例#11
0
    private IEnumerable <PropertyInfo> GetProperties()
    {
        var properties = new List <PropertyInfo>();

        foreach (var propertyInfo in ComponentObject.GetType().GetProperties())
        {
            if (Attribute.IsDefined(propertyInfo, typeof(HideInInspector)))
            {
                continue;
            }

            var setMethod = propertyInfo.GetSetMethod();
            if (null != setMethod && setMethod.IsPublic)
            {
                properties.Add(propertyInfo);
            }
        }

        return(properties);
    }
示例#12
0
    private List <PropertyInfo> GetProperties(List <string> propertiesToIgnore)
    {
        List <PropertyInfo> properties = new List <PropertyInfo>();

        foreach (PropertyInfo propertyInfo in ComponentObject.GetType().GetProperties())
        {
            if (!propertiesToIgnore.Contains(propertyInfo.Name))
            {
                if (!Attribute.IsDefined(propertyInfo, typeof(HideInInspector)))
                {
                    MethodInfo setMethod = propertyInfo.GetSetMethod();
                    if (null != setMethod && setMethod.IsPublic)
                    {
                        properties.Add(propertyInfo);
                    }
                }
            }
        }

        return(properties);
    }
示例#13
0
        private void ButtonCreate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            object newObject = null;
            var    editValue = EditValue;

            switch (EditMode)
            {
            case ObjectEditMode.Property:
                var propertyName = (string)Key;
                var property     = ComponentObject.GetType().GetProperty(propertyName);
                if (ConfigPublic.CreateNewAddonValue(property.PropertyType
                                                     , false
                                                     , out newObject))
                {
                    EditValue = newObject;
                    SetComponentPropertyValue();
                    ModifyData();
                }
                break;

            case ObjectEditMode.Object:
                var objectType = ObjectType;
                if (objectType == null)
                {
                    objectType = typeof(PaoObject);
                }
                if (ConfigPublic.CreateNewAddonValue(objectType
                                                     , false
                                                     , out newObject))
                {
                    EditValue = newObject;
                    SetComponentPropertyValue();
                    ModifyData();
                }
                break;

            default:
                break;
            }
        }
示例#14
0
    public void RestoreSettings()
    {
        if (ComponentObject != null)
        {
            ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component;
        }

        if (IsSavingSettings && null != ComponentObject && null != values)
        {
            foreach (string name in values.Keys)
            {
                object newValue = values[name];

                PropertyInfo property = ComponentObject.GetType().GetProperty(name);

                if (null != property)
                {
                    object currentValue = property.GetValue(ComponentObject, null);

                    if (HasValueChanged(newValue, currentValue))
                    {
                        property.SetValue(ComponentObject, newValue, null);
                    }
                }
                else
                {
                    FieldInfo field        = ComponentObject.GetType().GetField(name);
                    object    currentValue = field.GetValue(ComponentObject);

                    if (HasValueChanged(newValue, currentValue))
                    {
                        field.SetValue(ComponentObject, newValue);
                    }
                }
            }
        }

        values = null;
    }
示例#15
0
        private void SetComponentPropertyValue()
        {
            switch (EditMode)
            {
            case ObjectEditMode.Property:
                var propertyName = (string)Key;
                ComponentObject.SetPropertyValueByPath(propertyName, EditValue);
                break;

            case ObjectEditMode.ListElement:
                var index = (int)Key;
                ComponentObject.SetPropertyValueByPath(index.ToString(), EditValue);
                break;

            case ObjectEditMode.DictionaryElement:
                ComponentObject.SetPropertyValueByPath(Key.ToString(), EditValue);
                break;

            default:
                break;
            }
        }
示例#16
0
    //public void ToggleWindow(InteractiveObject _io, InteractiveObject.State _state, WindowType _type) { // currently only support for 1 window, but maybe more later?
    //    if (currentInfoWindow != null && currentInfoWindow.OwnerIO == _io)
    //        CloseCurrentInfoWindow();
    //    else
    //        OpenNewWindow(_io, _state, _type);
    //}

    public void OpenNewWindow(CanInspect _inspectable, CanInspect.State _state, WindowType _type)
    {
        int          _index         = currentInfoWindows.FindIndex(x => x.User == _inspectable);
        UIInfoWindow _currentWindow = null;

        if (_index > -1)
        {
            _currentWindow = currentInfoWindows[_index].Window;

            if (_currentWindow.OwnerInspectable == _inspectable)
            {
                if (_state != _currentWindow.State)
                {
                    _currentWindow.ChangeState(_state);
                }

                return;
            }

            CloseInfoWindow(_inspectable, _index); // not sure if needed
        }

        switch (_type)
        {
        case WindowType.Basic:
            _currentWindow = ComponentWindow_Main;
            break;

        case WindowType.Basic_SecondWindow:
            _currentWindow = ComponentWindow_Sub;
            break;

        case WindowType.ComponentHolder_x6:
            _currentWindow = ComponentHolderWindow_x6;
            break;

        case WindowType.ComponentHolder_x9:
            _currentWindow = ComponentHolderWindow_x9;
            break;

        case WindowType.ComponentHolder_15:
            _currentWindow = ComponentHolderWindow_x15;
            break;

        case WindowType.ComponentHolder_x24:
            _currentWindow = ComponentHolderWindow_x24;
            break;
        }

        // make sure no on else is using this window
        for (int i = 0; i < currentInfoWindows.Count; i++)
        {
            if (currentInfoWindows [i].Window == _currentWindow)
            {
                CloseInfoWindow(currentInfoWindows[i].User, i);
            }
        }

        ComponentObject _trackedComponent = null;

        switch (_type)
        {
        case WindowType.Basic:
        case WindowType.Basic_SecondWindow:
            _trackedComponent = _inspectable.GetComponent <ComponentObject>();
            break;

        case WindowType.ComponentHolder_x6:
        case WindowType.ComponentHolder_x9:
        case WindowType.ComponentHolder_15:
        case WindowType.ComponentHolder_x24:
            currentComponentHolder = _inspectable.GetComponent <ComponentHolder>();

            // set button-names to be the same as in the component-slots
            ComponentObject.ComponentType _compType;
            int _compTypeID;
            for (int i = 0; i < _currentWindow.Buttons.Length; i++)
            {
                _compType   = currentComponentHolder.ComponentSlots[i].SlotType;
                _compTypeID = currentComponentHolder.ComponentSlots[i].SlotTypeID;
                _currentWindow.Buttons[i].GetComponentInChildren <Text>().text = ComponentInfoManager.Instance.AllComponentsInfo[_compType][_compTypeID].Name;
            }
            break;
        }

        _currentWindow.UI_Image.sprite = _inspectable.Selected_Sprite;
        _currentWindow.UI_Name.text    = _inspectable.Selected_Name;
        _currentWindow.UI_Desc.text    = _inspectable.Selected_Desc;

        UITrackObject _tracker = _currentWindow.GetComponent <UITrackObject>();

        if (_tracker != null)
        {
            _tracker.trackTransform = _inspectable.transform;
        }

        _currentWindow.ChangeState(_state);
        _currentWindow.ShowWindow(_inspectable, _trackedComponent);
        currentInfoWindows.Add(new InfoWindowUser(_currentWindow, _inspectable));

        UpdateButtonGraphics(_inspectable);
    }
示例#17
0
        private PartData ImportPartData(PartDataObject partDataObj, Data data, string tempDir, Joint joint)
        {
            if (partDataObj == null)
            {
                return(null);
            }

            PartType type   = partDataObj.PartType;
            Guid     partId = partDataObj.Id;

            switch (type)
            {
            case PartType.Pipe:
                Pipe pipe = importRepo.PipeRepo.Get(partId);

                bool newPipe = false;
                if (pipe == null)
                {
                    PipeObject pipeObj = FindPipeById(data, partId);
                    if (pipeObj != null)
                    {
                        pipe = new Pipe();
                        MapSerializableEntityToPipe(tempDir, pipeObj, pipe);
                        newPipe = true;
                    }
                }

                if (pipe != null)
                {
                    if (newPipe)
                    {
                        importRepo.PipeRepo.Save(pipe);
                    }
                    else
                    {
                        importRepo.PipeRepo.SaveOrUpdate(pipe);
                    }
                }

                break;

            case PartType.Spool:
                Spool spool = importRepo.SpoolRepo.Get(partId);

                bool isNewSpool = false;
                if (spool == null)
                {
                    SpoolObject spoolObj = FindSpoolById(data, partId);
                    if (spoolObj != null)
                    {
                        spool = new Spool();
                        MapSerializableEntityToSpool(tempDir, spoolObj, spool);
                        isNewSpool = true;
                    }
                }

                if (spool != null)
                {
                    if (isNewSpool)
                    {
                        importRepo.SpoolRepo.Save(spool);
                    }
                    else
                    {
                        importRepo.SpoolRepo.SaveOrUpdate(spool);
                    }
                }

                break;

            case PartType.Component:
                Component component = importRepo.ComponentRepo.Get(partId);

                bool isNewComponent = false;
                if (component == null)
                {
                    ComponentObject compObj = FindComponentById(data, partId);
                    if (compObj != null)
                    {
                        component = new Component();
                        MapSerializableEntityToComponent(tempDir, compObj, component, joint);
                        isNewComponent = true;
                    }
                }

                if (component != null)
                {
                    if (isNewComponent)
                    {
                        importRepo.ComponentRepo.Save(component);
                    }
                    else
                    {
                        importRepo.ComponentRepo.SaveOrUpdate(component);
                    }
                }

                break;
            }

            PartData pd = new PartData();

            pd.Id       = partId;
            pd.PartType = type;
            return(pd);
        }
示例#18
0
        public IActionResult List(ComponentObject component)
        {
            foreach (var o in component.orderItems)
            {
                o.ItemID = _uow.InventoryItems.GetFirstOrDefault(i => i.Name == o.ItemName).InventoryItemID;
            }
            if (component.purchaseOrderDetails.PurchaseOrderID == 0)
            {
                _uow.PurchaseOrders.Add(component.purchaseOrderDetails);
            }
            else
            {
                _uow.PurchaseOrders.update(component.purchaseOrderDetails);
            }
            _uow.Save();
            //Now update the order items
            if (component.purchaseOrderDetails.PurchaseOrderID != 0)
            {
                //Get the current order items in the db to compare
                var DBItems = _uow.OrderItems.GetAll(o => o.PurchaseOrderID == component.purchaseOrderDetails.PurchaseOrderID).ToList();

                if (component.orderItems.Count() > 0)
                {
                    decimal newTotal = 0.00M;
                    foreach (var o in component.orderItems)
                    {
                        if (o.PurchaseOrderID == 0)
                        {
                            o.PurchaseOrderID = component.purchaseOrderDetails.PurchaseOrderID;
                        }
                        if (component.purchaseOrderDetails.StatusID == _uow.Statuses.GetFirstOrDefault(s => s.Name == "Received").StatusId)
                        {
                            o.QuantityReceived = o.QuantityOrdered;
                        }
                        newTotal += (o.Price * o.QuantityOrdered);
                        if (DBItems.Where(d => d.OrderItemID == o.OrderItemID).Count() > 0)
                        {
                            // Update o in DB
                            _uow.OrderItems.update(o);
                            // Remove o from DBItems list
                            DBItems.Remove(DBItems.Where(d => d.OrderItemID == o.OrderItemID).FirstOrDefault());
                        }
                        else
                        {
                            // Add o to DB
                            _uow.OrderItems.Add(o);
                        }
                        // Update vendorItem table
                        if (_uow.VendorItems.GetAll(v =>
                                                    v.VendorID == component.purchaseOrderDetails.VendorID &&
                                                    v.InventoryItemID == o.ItemID).ToList().Count() == 0)
                        {
                            _uow.VendorItems.Add(new VendorItem
                            {
                                VendorID        = component.purchaseOrderDetails.VendorID,
                                InventoryItemID = o.ItemID
                            });
                        }
                    }
                    component.purchaseOrderDetails.TotalPrice = newTotal;
                    _uow.PurchaseOrders.update(component.purchaseOrderDetails);
                }
                if (DBItems.Count > 0)
                {
                    foreach (var i in DBItems)
                    {
                        // Delete i from DB
                        _uow.OrderItems.Remove(i.OrderItemID);
                        // Update vendorItems table
                    }
                }
                _uow.Save();
            }
            return(Json(new { msg = "success" }));
        }
示例#19
0
 public void ShowWindow(CanInspect _newIO, ComponentObject _trackedComponent = null)
 {
     ToggleVisible(true, _newIO, _trackedComponent);
 }
示例#20
0
 public static void SetCache(this ComponentObject component, in ent entity, in RectTransform rectTransformLocalScale = default)
示例#21
0
    //return component is changes have been made
    public Component RestoreSettings()
    {
        Component resultChangedComponent = null;

        if (!_isComponentObjectNull)
        {
            ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component;
        }
        else
        {
            ComponentObject = null;
        }

        if (ComponentObject != null && _values != null)
        {
            foreach (var name in _values.Keys)
            {
                var newValue = _values[name];

                var property = ComponentObject.GetType().GetProperty(name);

                if (null != property)
                {
                    var currentValue = property.GetValue(ComponentObject, null);

                    if (!HasValueChanged(newValue, currentValue))
                    {
                        continue;
                    }

                    property.SetValue(ComponentObject, newValue, null);
                    resultChangedComponent = ComponentObject;
                }
                else
                {
                    var field        = ComponentObject.GetType().GetField(name);
                    var currentValue = field.GetValue(ComponentObject);

                    if (!HasValueChanged(newValue, currentValue))
                    {
                        continue;
                    }

                    if (ComponentObject.ToString().Contains("DarkTonic.MasterAudio.MasterAudio"))
                    {
                        switch (field.Name)
                        {
                        case "customEvents":
                            FilterOutDGSCCustomEvents(ref newValue);
                            break;

                        case "customEventCategories":
                            FilterOutDGSCCustomEventCategories(ref newValue);
                            break;

                        case "musicPlaylists":
                            FilterOutDGSCPlaylists(ref newValue);
                            break;

                        case "groupBuses":
                            FilterOutDGSCBuses(ref newValue);
                            break;

                        case "musicDuckingSounds":
                            FilterOutDGSCDuckGroups(ref newValue);
                            break;
                        }
                    }
                    field.SetValue(ComponentObject, newValue);
                    resultChangedComponent = ComponentObject;
                }
            }
        }

        _values = null;
        return(resultChangedComponent);
    }
示例#22
0
 public Bolt(ComponentObject bolt_object, ComponentCommon common) : this()
 {
     this.Bolt_object = bolt_object;
     this.Common      = common;
 }
示例#23
0
 public Bolt(ComponentObject bolt_object, ComponentCommon common) : this() {
   this.Bolt_object = bolt_object;
   this.Common = common;
 }
示例#24
0
 public StateSpoutSpec(ComponentObject state_spout_object, ComponentCommon common) : this() {
   this.State_spout_object = state_spout_object;
   this.Common = common;
 }
示例#25
0
 public SpoutSpec(ComponentObject spout_object, ComponentCommon common) : this()
 {
     this.Spout_object = spout_object;
     this.Common       = common;
 }