Exemple #1
0
 // fills gui_objects, AroundObjects (active_objects has been filled during XML load)
 private void PreLoadRegisterObjects(GuiObject o)
 {
     if (o is IHasID)
     {
         IHasID p = o as IHasID;
         if (p.ID == null)
         {
             throw new ArgumentException("no id");
         }
         if (gui_objects.ContainsKey(p.ID))
         {
             throw new ArgumentException("two identical ids");
         }
         gui_objects[p.ID] = o;
     }
     if (o is IAroundObject)
     {
         AroundObjects.Add(o);
     }
     if (o.children != null)
     {
         foreach (GuiBound b in o.children)
         {
             PreLoadRegisterObjects(b);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Adds the control tower fuel info.
        /// </summary>
        /// <param name="srcItem">The source item.</param>
        /// <param name="item">The item.</param>
        private static void AddControlTowerFuelInfo(IHasID srcItem, SerializableItem item)
        {
            IEnumerable <SerializableControlTowerFuel> controlTowerResourcesTable = Database.InvControlTowerResourcesTable
                                                                                    .Join(Database.InvControlTowerResourcePurposesTable, ctr => ctr.PurposeID, ctrp => ctrp.ID,
                                                                                          (ctr, ctrp) => new { ctr, ctrp })
                                                                                    .Where(x => x.ctr.ID == srcItem.ID)
                                                                                    .Select(resource => new SerializableControlTowerFuel
            {
                ID               = resource.ctr.ResourceID,
                Purpose          = resource.ctrp.PurposeName,
                Quantity         = resource.ctr.Quantity,
                MinSecurityLevel = resource.ctr.MinSecurityLevel.HasValue
                                                ? resource.ctr.MinSecurityLevel.Value.ToString(CultureInfo.InvariantCulture)
                                                : String.Empty,
                FactionID = resource.ctr.FactionID.HasValue
                                                ? resource.ctr.FactionID.Value.ToString(CultureInfo.InvariantCulture)
                                                : String.Empty,
                FactionName = resource.ctr.FactionID.HasValue
                                                ? Database.ChrFactionsTable[resource.ctr.FactionID.Value].
                              FactionName
                                                : String.Empty
            });

            item.ControlTowerFuelInfo.AddRange(controlTowerResourcesTable);
        }
        public static bool Update(IHasID item, string dbTableName = null)
        {
            // get the table name if no argument provided
            if (dbTableName == null)
            {
                dbTableName = GetTableName(item.GetType());
            }
            if (dbTableName == null)
            {
                throw new InvalidOperationException();
            }

            // get clauses (NAME=PLACEHOLDER) and values to be updated
            var(clauses, values) = CollectUpdateInfo(item);

            // prepare and execute command
            SqliteCommand command = new SqliteCommand();

            command.Connection  = DBHelper.Connection;
            command.CommandText = $"UPDATE {dbTableName} SET {clauses} WHERE ID = {item.ID};";
            for (int i = 0; i < values.Count; i++)
            {
                command.Parameters.AddWithValue($"@P{i}", values[i]);
            }
            int rows = command.ExecuteNonQuery();

            // reture true if item inserted successfully
            return(rows > 0);
        }
        /// <summary>
        /// Webshes the innogy event.
        /// </summary>
        /// <param name="data">The data.</param>
        private void websh_InnogyEvent(EventData data)
        {
            //Ggf. State anpassen
            if (data.Type.Split('/').Last() == "StateChanged")
            {
                IHasID Iobject = GetObjectByID <DeviceState>(data.Link.CleanValue.ToString().Replace("/", ""));
            }

            InnogyEvent?.Invoke(data);
        }
Exemple #5
0
    public static void SetNames(IHasID IHasIDIns)
    {
        string insTypeName = IHasIDIns.GetType().Name;

        if (TypeNameItemInfoPairs.ContainsKey(insTypeName))
        {
            ItemInfo itemInfo = TypeNameItemInfoPairs[insTypeName];
            IHasIDIns.SetChineseName(itemInfo.chineseName);
            IHasIDIns.SetEnglishName(itemInfo.englishName);
        }
    }
Exemple #6
0
 /// <summary>
 /// Exports the planets.
 /// </summary>
 /// <param name="srcSystem">The SRC system.</param>
 /// <returns></returns>
 private static IEnumerable <SerializablePlanet> ExportPlanets(IHasID srcSystem)
 => Planets.ContainsKey(srcSystem.ID) ? Planets[srcSystem.ID].Select(srcPlanet =>
 {
     SerializablePlanet planet = new SerializablePlanet
     {
         ID     = srcPlanet.ID,
         Name   = Database.InvNamesTable[srcPlanet.ID].Name,
         TypeID = srcPlanet.TypeID
     };
     return(planet);
 }) : new SerializablePlanet[0];
Exemple #7
0
 /// <summary>
 /// Exports the planets.
 /// </summary>
 /// <param name="srcSystem">The SRC system.</param>
 /// <returns></returns>
 private static IEnumerable <SerializablePlanet> ExportPlanets(IHasID srcSystem)
 => Database.InvItemsTable.Where(x => x.LocationID == srcSystem.ID && Database.
                                 InvTypesTable[x.TypeID].GroupID == 7).Select(srcPlanet =>
 {
     SerializablePlanet planet = new SerializablePlanet
     {
         ID     = srcPlanet.ID,
         Name   = Database.InvNamesTable[srcPlanet.ID].Name,
         TypeID = srcPlanet.TypeID
     };
     return(planet);
 });
Exemple #8
0
        /// <summary>
        /// Exports the constellations.
        /// </summary>
        /// <param name="srcRegion">The source region.</param>
        /// <returns></returns>
        private static IEnumerable <SerializableConstellation> ExportConstellations(IHasID srcRegion)
        => Database.MapConstellationsTable.Where(x => x.RegionID == srcRegion.ID)
        .Select(srcConstellation =>
        {
            SerializableConstellation constellation = new SerializableConstellation
            {
                ID   = srcConstellation.ID,
                Name = srcConstellation.Name
            };

            // Systems
            constellation.Systems.AddRange(ExportSystems(srcConstellation).OrderBy(x => x.Name));
            return(constellation);
        });
Exemple #9
0
        /// <summary>
        /// Adds the meta group.
        /// </summary>
        /// <param name="srcItem">The source item.</param>
        /// <param name="item">The serializable item.</param>
        private static void AddMetaGroup(IHasID srcItem, SerializableItem item)
        {
            //int itemID = Database.InvBlueprintTypesTable.Any(x => x.ID == srcItem.ID)
            //    ? Database.InvBlueprintTypesTable[srcItem.ID].ProductTypeID
            //    : srcItem.ID;

            foreach (InvMetaTypes relation in Database.InvMetaTypesTable.Where(x => x.ItemID == srcItem.ID))
            {
                switch (relation.MetaGroupID)
                {
                case DBConstants.TechIMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.T1;
                    break;

                case DBConstants.TechIIMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.T2;
                    break;

                case DBConstants.StorylineMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.Storyline;
                    break;

                case DBConstants.FactionMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.Faction;
                    break;

                case DBConstants.OfficerMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.Officer;
                    break;

                case DBConstants.DeadspaceMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.Deadspace;
                    break;

                case DBConstants.TechIIIMetaGroupID:
                    item.MetaGroup = ItemMetaGroup.T3;
                    break;

                default:
                    item.MetaGroup = ItemMetaGroup.None;
                    break;
                }
            }

            if (item.MetaGroup == ItemMetaGroup.None)
            {
                item.MetaGroup = ItemMetaGroup.T1;
            }
        }
Exemple #10
0
        /// <summary>
        /// Exports the constellations.
        /// </summary>
        /// <param name="srcRegion">The source region.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableConstellation> ExportConstellations(IHasID srcRegion)
            => Database.MapConstellationsTable
                .Where(x => x.RegionID == srcRegion.ID)
                .Select(srcConstellation =>
                {
                    SerializableConstellation constellation = new SerializableConstellation
                    {
                        ID = srcConstellation.ID,
                        Name = srcConstellation.Name
                    };

                    // Systems
                    constellation.Systems.AddRange(ExportSystems(srcConstellation).OrderBy(x => x.Name));
                    return constellation;
                });
        /// <summary>
        /// value.TryGetValue(out x)と使える。この場合<T>を書かなくてもxの型で類推される。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <param name="dest"></param>
        /// <returns></returns>
        public static bool TryGetValue <T>(this IHasID value, out T dest)
        {
            var temp = value as IHasID <T>;

            if (temp != null)
            {
                dest = temp.Parameter;
                return(true);
            }
            else
            {
                dest = default(T);
                return(false);
            }
        }
Exemple #12
0
 /// <summary>
 /// Exports the agents.
 /// </summary>
 /// <param name="srcStation">The station.</param>
 /// <returns></returns>
 private static IEnumerable <SerializableAgent> ExportAgents(IHasID srcStation)
 => Database.AgtAgentsTable
 .Where(x => x.LocationID == srcStation.ID)
 .Select(agent => new SerializableAgent
 {
     ID              = agent.ID,
     Level           = agent.Level,
     Quality         = agent.Quality,
     Name            = Database.InvNamesTable[agent.ID].Name,
     DivisionName    = Database.CrpNPCDivisionsTable[agent.DivisionID].DivisionName,
     AgentType       = Database.AgtAgentTypesTable[agent.AgentTypeID].AgentType,
     ResearchSkillID = Database.AgtResearchAgentsTable.Any(x => x.ID == agent.ID)
                 ? Database.AgtResearchAgentsTable[agent.ID].ResearchSkillID
                 : 0,
     LocatorService = agent.IsLocator
 });
        /// <summary>
        /// Does the action.
        /// </summary>
        /// <param name="actInf">The act inf.</param>
        /// <returns></returns>
        public bool DoAction(ActionInfo actInf)
        {
            ActionResponse       actres = default(ActionResponse);
            InnogyRequestHandler reqH   = new InnogyRequestHandler(authHandler.Token);

            actres = reqH.Perform(RequestTyp.Action, actInf.ToInAction()) as ActionResponse;
            if (actres.ResultCode == "Success")
            {
                IHasID iObejct = GetObjectByID <DeviceState>(actInf.ID);
                if (iObejct.GetType() == typeof(DeviceState))
                {
                    (iObejct as DeviceState).State.Find(s => s.Name == actInf.Setting).Value = actInf.Value.ToString();
                }
                return(true);
            }
            return(false);
        }
Exemple #14
0
        /// <summary>
        /// Exports the systems.
        /// </summary>
        /// <param name="srcConstellation">The source constellation.</param>
        /// <returns></returns>
        private static IEnumerable <SerializableSolarSystem> ExportSystems(IHasID srcConstellation)
        => Database.MapSolarSystemsTable.Where(x => x.ConstellationID == srcConstellation.ID)
        .Select(srcSystem =>
        {
            SerializableSolarSystem system = new SerializableSolarSystem
            {
                ID            = srcSystem.ID,
                Name          = srcSystem.Name,
                X             = (int)(srcSystem.X / BaseDistance),
                Y             = (int)(srcSystem.Y / BaseDistance),
                Z             = (int)(srcSystem.Z / BaseDistance),
                SecurityLevel = srcSystem.SecurityLevel
            };

            // Stations
            system.Stations.AddRange(ExportStations(srcSystem).OrderBy(x => x.Name));
            return(system);
        });
Exemple #15
0
        /// <summary>
        /// Exports the stations.
        /// </summary>
        /// <param name="srcSystem">The SRC system.</param>
        /// <returns></returns>
        private static IEnumerable <SerializableStation> ExportStations(IHasID srcSystem)
        => Database.StaStationsTable.Where(x => x.SolarSystemID == srcSystem.ID)
        .Select(srcStation =>
        {
            SerializableStation station = new SerializableStation
            {
                ID                       = srcStation.ID,
                Name                     = srcStation.Name,
                CorporationID            = srcStation.CorporationID,
                CorporationName          = Database.InvNamesTable[srcStation.CorporationID].Name,
                ReprocessingEfficiency   = srcStation.ReprocessingEfficiency,
                ReprocessingStationsTake = srcStation.ReprocessingStationsTake
            };

            // Agents
            station.Agents.AddRange(ExportAgents(srcStation));
            return(station);
        });
Exemple #16
0
    public void OnPointerClick(PointerEventData eventData)
    {
        //if (eventData.button != PointerEventData.InputButton.Left) return;

        if (GameController.state == GameController.STATE_PLAYING && eventData.button == PointerEventData.InputButton.Left)
        {
            if (groupable.ShouldShowUI)
            {
                Debug.Log("Playing Click");

                GameController.Pause(GameController.STATE_PAUSE);

                UIManager.ins.ShowItemPanel(transform.position, groupable.IsGroupParent ? 0 : 1);

                UIManager.ins.gameObjectPanel[GameController.STATE_PLAYING].transform.Find("Group").GetComponent <Button>().onClick.RemoveAllListeners();
                UIManager.ins.gameObjectPanel[GameController.STATE_PLAYING].transform.Find("Group").GetComponent <Button>().onClick.AddListener(OnGroupButtonClick);

//                UIManager.ins.gameObjectPanel[GameController.STATE_PLAYING].transform.Find("Group").GetComponent<Button>().onClick.AddListener(() => { groupButtonDelegates[delegateIndex](); });
            }
        }
        else if (GameController.state == GameController.STATE_SEARCH)
        {
            Debug.Log("Search Click");

            IHasID item = GetComponent <IHasID>();

            if (item != null)
            {
                Debug.Log("eventData.button = " + eventData.button);
                // 左键显示英文 右键显示中文
                if (eventData.button == PointerEventData.InputButton.Left)
                {
                    //  按左键英文  按右键 中文    id 分成两组 一组英文,一组英文
                    UIManager.ins.ShowItemText(item.englishName, transform.position);
                }
                else if (eventData.button == PointerEventData.InputButton.Right)
                {
                    Debug.Log("监听到右键点击目标");
                    UIManager.ins.ShowItemText(item.chineseName, transform.position);
                }
            }
        }
    }
Exemple #17
0
 /// <summary>
 /// Adds the reaction info.
 /// </summary>
 /// <param name="srcItem">The source item.</param>
 /// <param name="item">The item.</param>
 private static void AddReactionInfo(IHasID srcItem, SerializableItem item)
 {
     item.ReactionInfo.AddRange(Database.InvTypeReactionsTable.Where(x => x.ID == srcItem.ID).Select(
                                    srcReaction => new
     {
         srcReaction,
         multiplier = Database.DgmTypeAttributesTable.Where(
             x => x.ItemID == srcReaction.TypeID &&
             x.AttributeID == DBConstants.MoonMiningAmountPropertyID).Select(
             x => x.GetInt64Value).FirstOrDefault()
     }).Select(
                                    reaction => new SerializableReactionInfo
     {
         ID       = reaction.srcReaction.TypeID,
         IsInput  = reaction.srcReaction.Input,
         Quantity = reaction.multiplier > 0
                                                 ? reaction.srcReaction.Quantity * reaction.multiplier
                                                 : reaction.srcReaction.Quantity
     }));
 }
Exemple #18
0
 /// <summary>
 /// Adds the reaction info.
 /// </summary>
 /// <param name="srcItem">The source item.</param>
 /// <param name="item">The item.</param>
 private static void AddReactionInfo(IHasID srcItem, SerializableItem item)
 {
     foreach (var srcReaction in Database.InvTypeReactionsTable)
     {
         if (srcReaction.ID == srcItem.ID)
         {
             int  reactionTypeID = srcReaction.TypeID;
             long multiplier     = (Database.DgmTypeAttributesTable.FirstOrDefault(x =>
                                                                                   x.ItemID == reactionTypeID && x.AttributeID == DBConstants.
                                                                                   MoonMiningAmountPropertyID)?.GetInt64Value) ?? 1L, qty = srcReaction.
                                                                                                                                            Quantity;
             item.ReactionInfo.Add(new SerializableReactionInfo
             {
                 ID       = srcReaction.TypeID,
                 IsInput  = srcReaction.Input,
                 Quantity = multiplier > 0L ? qty * multiplier : qty
             });
         }
     }
 }
Exemple #19
0
        private static (string, List <object>) CollectInsertInfo(IHasID item, bool skipID = false)
        {
            List <object> values = new List <object>();
            StringBuilder sb     = new StringBuilder();

            foreach (var prop in item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                // skip property if NonDBValueAttribute found
                if (prop.GetCustomAttributes(typeof(NonDBValueAttribute), true).Length > 0)
                {
                    continue;
                }

                // skip ID if it is not needed
                if (skipID && prop.Name == "ID")
                {
                    continue;
                }

                // collect property name
                string name = prop.Name;
                // replace with ColumnName property if found
                var attributes = prop.GetCustomAttributes(typeof(DBValueAttribute), true);
                if (attributes.Length > 0)
                {
                    name = ((DBValueAttribute)attributes[0]).ColumnName;
                }
                sb.Append(name + ",");

                // collect property value
                object value = prop.GetValue(item) ?? DBNull.Value;
                if (prop.Name == "ID")
                {
                    value = DBNull.Value;                                    // replace ID value with NULL
                }
                values.Add(value);
            }
            sb.Remove(sb.Length - 1, 1);             // remove the last comma

            return(sb.ToString(), values);
        }
Exemple #20
0
        /// <summary>
        /// Get's the item requirements.
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprint"></param>
        private static void GetRequirements(IHasID srcBlueprint, SerializableBlueprint blueprint)
        {
            List <SerializablePrereqSkill>      prerequisiteSkills = new List <SerializablePrereqSkill>();
            List <SerializableRequiredMaterial> requiredMaterials  = new List <SerializableRequiredMaterial>();

            // Find required skills
            foreach (var requirement in Database.IndustryActivitySkillsTable
                     .Where(x => x.BlueprintTypeID == srcBlueprint.ID))
            {
                if (requirement.Level.HasValue)
                {
                    prerequisiteSkills.Add(new SerializablePrereqSkill
                    {
                        ID       = requirement.SkillID,
                        Level    = requirement.Level.Value,
                        Activity = requirement.ActivityID
                    });
                }
            }

            // Find required materials
            foreach (var requirement in Database.IndustryActivityMaterialsTable
                     .Where(x => x.BlueprintTypeID == srcBlueprint.ID))
            {
                if (requirement.Quantity.HasValue)
                {
                    requiredMaterials.Add(new SerializableRequiredMaterial
                    {
                        ID       = requirement.MaterialTypeID,
                        Quantity = requirement.Quantity.Value,
                        Activity = requirement.ActivityID,
                    });
                }
            }

            // Add prerequisite skills to item
            blueprint.PrereqSkill.AddRange(prerequisiteSkills.OrderBy(x => x.Activity));

            // Add required materials to item
            blueprint.ReqMaterial.AddRange(requiredMaterials.OrderBy(x => x.Activity));
        }
Exemple #21
0
        public static bool Delete(IHasID item, string dbTableName = null)
        {
            // get the table name if no argument provided
            if (dbTableName == null)
            {
                dbTableName = GetTableName(item.GetType());
            }
            if (dbTableName == null)
            {
                throw new InvalidOperationException();
            }

            // prepare and execute command
            int rows = new SqliteCommand(
                $"DELETE FROM {dbTableName} WHERE ID = {item.ID};",
                DBHelper.Connection
                ).ExecuteNonQuery();

            // reture true if item inserted successfully
            return(rows > 0);
        }
Exemple #22
0
        /// <summary>
        /// Get's the item requirements.
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprint"></param>
        private static void GetRequirements(IHasID srcBlueprint, SerializableBlueprint blueprint)
        {
            List <SerializablePrereqSkill>      prerequisiteSkills = new List <SerializablePrereqSkill>();
            List <SerializableRequiredMaterial> requiredMaterials  = new List <SerializableRequiredMaterial>();

            // Find the requirements and add them to the list, ignore any blueprint type
            foreach (RamTypeRequirements requirement in Database.RamTypeRequirementsTable
                     .Where(requirement => requirement.ID == srcBlueprint.ID &&
                            Database.InvBlueprintTypesTable.All(x => x.ID != requirement.RequiredTypeID)))
            {
                // Is it a skill ? Add it to the prerequisities skills list
                if (requirement.Level.HasValue)
                {
                    prerequisiteSkills.Add(new SerializablePrereqSkill
                    {
                        ID       = requirement.RequiredTypeID,
                        Level    = requirement.Level.Value,
                        Activity = requirement.ActivityID
                    });
                    continue;
                }

                // It is an item (material)
                if (requirement.Quantity.HasValue)
                {
                    requiredMaterials.Add(new SerializableRequiredMaterial
                    {
                        ID       = requirement.RequiredTypeID,
                        Quantity = requirement.Quantity.Value,
                        Activity = requirement.ActivityID,
                    });
                }
            }

            // Add prerequisite skills to item
            blueprint.PrereqSkill.AddRange(prerequisiteSkills.OrderBy(x => x.Activity));

            // Add required materials to item
            blueprint.ReqMaterial.AddRange(requiredMaterials.OrderBy(x => x.Activity));
        }
    private void OnInstantiated(GameObject ins)
    {
        IHasID hasID = ins.GetComponent <IHasID>();

        if (hasID != null)
        {
            string insEnglishName = hasID.englishName;
            foreach (LevelClearGameObjectInfo info in targetInfos)
            {
                if (info.isInsInRuntime && insEnglishName.Equals(info.GetFullName()))
                {
                    AddComponentInTarget(ins);
                }
            }
            //foreach (string englishName in targetEnglishNames)
            //{
            //    if (englishName.Equals(insEnglishName))
            //    {
            //        AddComponentInTarget(ins);
            //    }
            //}
        }
    }
Exemple #24
0
        public static bool Insert(IHasID item, string dbTableName = null)
        {
            // get the table name if no argument provided
            if (dbTableName == null)
            {
                dbTableName = GetTableName(item.GetType());
            }
            if (dbTableName == null)
            {
                throw new InvalidOperationException();
            }

            // get colume names and values to be inserted
            var(names, values) = CollectInsertInfo(item);

            // prepare and execute command
            int           n       = values.Count;
            SqliteCommand command = new SqliteCommand();

            command.Connection  = DBHelper.Connection;;
            command.CommandText = $"INSERT INTO {dbTableName} ({names}) VALUES ({MakePlaceholders(n)});";
            for (int i = 0; i < n; i++)
            {
                command.Parameters.AddWithValue($"@P{i}", values[i]);
            }
            int rows = command.ExecuteNonQuery();

            // get and assign the last insert row id
            if (rows > 0)
            {
                command = new SqliteCommand("SELECT last_insert_rowid()", DBHelper.Connection);
                item.ID = (long)command.ExecuteScalar();
            }

            // reture true if item inserted successfully
            return(rows > 0);
        }
Exemple #25
0
        /// <summary>
        /// Adds the control tower fuel info.
        /// </summary>
        /// <param name="srcItem">The source item.</param>
        /// <param name="item">The item.</param>
        private static void AddControlTowerFuelInfo(IHasID srcItem, SerializableItem item)
        {
            IEnumerable<SerializableControlTowerFuel> controlTowerResourcesTable = Database.InvControlTowerResourcesTable
                .Join(Database.InvControlTowerResourcePurposesTable, ctr => ctr.PurposeID, ctrp => ctrp.ID,
                    (ctr, ctrp) => new { ctr, ctrp })
                .Where(x => x.ctr.ID == srcItem.ID)
                .Select(resource => new SerializableControlTowerFuel
                {
                    ID = resource.ctr.ResourceID,
                    Purpose = resource.ctrp.PurposeName,
                    Quantity = resource.ctr.Quantity,
                    MinSecurityLevel = resource.ctr.MinSecurityLevel.HasValue
                        ? resource.ctr.MinSecurityLevel.Value.ToString(CultureInfo.InvariantCulture)
                        : String.Empty,
                    FactionID = resource.ctr.FactionID.HasValue
                        ? resource.ctr.FactionID.Value.ToString(CultureInfo.InvariantCulture)
                        : String.Empty,
                    FactionName = resource.ctr.FactionID.HasValue
                        ? Database.ChrFactionsTable[resource.ctr.FactionID.Value].
                            FactionName
                        : String.Empty
                });

            item.ControlTowerFuelInfo.AddRange(controlTowerResourcesTable);
        }
Exemple #26
0
        /// <summary>
        /// Adds the meta group.
        /// </summary>
        /// <param name="srcItem">The source item.</param>
        /// <param name="item">The serializable item.</param>
        private static void AddMetaGroup(IHasID srcItem, SerializableItem item)
        {
            int itemID = Database.InvBlueprintTypesTable.Any(x => x.ID == srcItem.ID)
                ? Database.InvBlueprintTypesTable[srcItem.ID].ProductTypeID
                : srcItem.ID;

            foreach (InvMetaTypes relation in Database.InvMetaTypesTable.Where(x => x.ItemID == itemID))
            {
                switch (relation.MetaGroupID)
                {
                    case DBConstants.TechIMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.T1;
                        break;
                    case DBConstants.TechIIMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.T2;
                        break;
                    case DBConstants.StorylineMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.Storyline;
                        break;
                    case DBConstants.FactionMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.Faction;
                        break;
                    case DBConstants.OfficerMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.Officer;
                        break;
                    case DBConstants.DeadspaceMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.Deadspace;
                        break;
                    case DBConstants.TechIIIMetaGroupID:
                        item.MetaGroup = ItemMetaGroup.T3;
                        break;
                    default:
                        item.MetaGroup = ItemMetaGroup.None;
                        break;
                }
            }

            if (item.MetaGroup == ItemMetaGroup.None)
                item.MetaGroup = ItemMetaGroup.T1;
        }
Exemple #27
0
 /// <summary>
 /// Adds the reaction info.
 /// </summary>
 /// <param name="srcItem">The source item.</param>
 /// <param name="item">The item.</param>
 private static void AddReactionInfo(IHasID srcItem, SerializableItem item)
 {
     item.ReactionInfo.AddRange(Database.InvTypeReactionsTable.Where(x => x.ID == srcItem.ID).Select(
         srcReaction => new
         {
             srcReaction,
             multiplier = Database.DgmTypeAttributesTable.Where(
                 x => x.ItemID == srcReaction.TypeID &&
                      x.AttributeID == DBConstants.MoonMiningAmountPropertyID).Select(
                          x => x.GetInt64Value).FirstOrDefault()
         }).Select(
             reaction => new SerializableReactionInfo
             {
                 ID = reaction.srcReaction.TypeID,
                 IsInput = reaction.srcReaction.Input,
                 Quantity = reaction.multiplier > 0
                     ? reaction.srcReaction.Quantity * reaction.multiplier
                     : reaction.srcReaction.Quantity
             }));
 }
Exemple #28
0
 public static void Unsubscribe(object unsubscriber, IHasID sender)
 {
     PerformUnsubscribe(unsubscriber, GetSignatureFor(sender), null);
 }
Exemple #29
0
 public static void Unsubscribe <T> (object unsubscriber, IHasID sender)
 {
     PerformUnsubscribe(unsubscriber, GetSignatureFor(sender), typeof(T));
 }
Exemple #30
0
 /// <summary>
 /// Exports the agents.
 /// </summary>
 /// <param name="srcStation">The station.</param>
 /// <returns></returns>
 private static IEnumerable<SerializableAgent> ExportAgents(IHasID srcStation)
     => Database.AgtAgentsTable
         .Where(x => x.LocationID == srcStation.ID)
         .Select(agent => new SerializableAgent
         {
             ID = agent.ID,
             Level = agent.Level,
             Quality = agent.Quality,
             Name = Database.InvNamesTable[agent.ID].Name,
             DivisionName = Database.CrpNPCDivisionsTable[agent.DivisionID].DivisionName,
             AgentType = Database.AgtAgentTypesTable[agent.AgentTypeID].AgentType,
             ResearchSkillID = Database.AgtResearchAgentsTable.Any(x => x.ID == agent.ID)
                 ? Database.AgtResearchAgentsTable[agent.ID].ResearchSkillID
                 : 0,
             LocatorService = agent.IsLocator
         });
Exemple #31
0
        /// <summary>
        /// Exports the systems.
        /// </summary>
        /// <param name="srcConstellation">The source constellation.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableSolarSystem> ExportSystems(IHasID srcConstellation)
            => Database.MapSolarSystemsTable
                .Where(x => x.ConstellationID == srcConstellation.ID)
                .Select(
                    srcSystem =>
                    {
                        SerializableSolarSystem system = new SerializableSolarSystem
                        {
                            ID = srcSystem.ID,
                            Name = srcSystem.Name,
                            X = (int)(srcSystem.X / BaseDistance),
                            Y = (int)(srcSystem.Y / BaseDistance),
                            Z = (int)(srcSystem.Z / BaseDistance),
                            SecurityLevel = srcSystem.SecurityLevel
                        };

                        // Stations
                        system.Stations.AddRange(ExportStations(srcSystem).OrderBy(x => x.Name));
                        return system;
                    });
Exemple #32
0
 public static void Subscribe(object subscriber, IHasID sender, Action callback)
 {
     PerformSubscribe(subscriber, GetSignatureFor(sender), null, args => callback());
 }
Exemple #33
0
        // Subscribe

        public static void Subscribe <T> (object subscriber, IHasID sender, Action <T> callback)
        {
            PerformSubscribe(subscriber, GetSignatureFor(sender), typeof(T), args => callback((T)args));
        }
Exemple #34
0
        // Private methods

        static string GetSignatureFor(IHasID sender)
        {
            return($"{sender.GetType ().FullName}.{sender.ID}");
        }
Exemple #35
0
        /// <summary>
        /// Exports the skills in the skill group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableSkill> ExportSkillsInGroup(IHasID group)
        {
            List<SerializableSkill> listOfSkillsInGroup = new List<SerializableSkill>();

            foreach (InvTypes skill in Database.InvTypesTable.Where(x => x.GroupID == group.ID))
            {
                Util.UpdatePercentDone(Database.SkillsTotalCount);

                SerializableSkill singleSkill = new SerializableSkill
                {
                    ID = skill.ID,
                    Name = skill.Name,
                    Description = skill.Description,
                    Public = skill.Published,
                    Cost = (long)skill.BasePrice,
                };

                // Export skill atributes
                Dictionary<int, Int64> skillAttributes = Database.DgmTypeAttributesTable.Where(
                    x => x.ItemID == skill.ID).ToDictionary(
                        attribute => attribute.AttributeID, attribute => attribute.GetInt64Value);

                singleSkill.Rank = skillAttributes.ContainsKey(DBConstants.SkillTimeConstantPropertyID) &&
                                   skillAttributes[DBConstants.SkillTimeConstantPropertyID] > 0
                    ? skillAttributes[DBConstants.SkillTimeConstantPropertyID]
                    : 1;

                singleSkill.PrimaryAttribute = skillAttributes.ContainsKey(DBConstants.PrimaryAttributePropertyID)
                    ? IntToEveAttribute(skillAttributes[DBConstants.PrimaryAttributePropertyID])
                    : EveAttribute.None;
                singleSkill.SecondaryAttribute = skillAttributes.ContainsKey(DBConstants.SecondaryAttributePropertyID)
                    ? IntToEveAttribute(
                        skillAttributes[DBConstants.SecondaryAttributePropertyID])
                    : EveAttribute.None;
                singleSkill.CanTrainOnTrial = !skillAttributes.ContainsKey(DBConstants.CanNotBeTrainedOnTrialPropertyID) ||
                                              skillAttributes[DBConstants.CanNotBeTrainedOnTrialPropertyID] == 0;

                // Export prerequesities
                List<SerializableSkillPrerequisite> listOfPrerequisites = new List<SerializableSkillPrerequisite>();

                for (int i = 0; i < DBConstants.RequiredSkillPropertyIDs.Count; i++)
                {
                    if (!skillAttributes.ContainsKey(DBConstants.RequiredSkillPropertyIDs[i]) ||
                        !skillAttributes.ContainsKey(DBConstants.RequiredSkillLevelPropertyIDs[i]))
                        continue;

                    InvTypes prereqSkill = Database.InvTypesTable[skillAttributes[DBConstants.RequiredSkillPropertyIDs[i]]];

                    SerializableSkillPrerequisite preReq = new SerializableSkillPrerequisite
                    {
                        ID = prereqSkill.ID,
                        Level =
                            skillAttributes[DBConstants.RequiredSkillLevelPropertyIDs[i]],
                        Name = prereqSkill.Name
                    };

                    // Add prerequisites
                    listOfPrerequisites.Add(preReq);
                }

                // Add prerequesites to skill
                singleSkill.SkillPrerequisites.AddRange(listOfPrerequisites);

                // Add skill
                listOfSkillsInGroup.Add(singleSkill);
            }
            return listOfSkillsInGroup;
        }
Exemple #36
0
        /// <summary>
        /// Get's the item requirements. 
        /// </summary>
        /// <param name="srcBlueprint"></param>
        /// <param name="blueprint"></param>
        private static void GetRequirements(IHasID srcBlueprint, SerializableBlueprint blueprint)
        {
            List<SerializablePrereqSkill> prerequisiteSkills = new List<SerializablePrereqSkill>();
            List<SerializableRequiredMaterial> requiredMaterials = new List<SerializableRequiredMaterial>();

            // Find the requirements and add them to the list, ignore any blueprint type
            foreach (RamTypeRequirements requirement in Database.RamTypeRequirementsTable
                .Where(requirement => requirement.ID == srcBlueprint.ID &&
                                      Database.InvBlueprintTypesTable.All(x => x.ID != requirement.RequiredTypeID)))
            {
                // Is it a skill ? Add it to the prerequisities skills list
                if (requirement.Level.HasValue)
                {
                    prerequisiteSkills.Add(new SerializablePrereqSkill
                    {
                        ID = requirement.RequiredTypeID,
                        Level = requirement.Level.Value,
                        Activity = requirement.ActivityID
                    });
                    continue;
                }

                // It is an item (material)
                if (requirement.Quantity.HasValue)
                {
                    requiredMaterials.Add(new SerializableRequiredMaterial
                    {
                        ID = requirement.RequiredTypeID,
                        Quantity = requirement.Quantity.Value,
                        Activity = requirement.ActivityID,
                    });
                }
            }

            // Add prerequisite skills to item
            blueprint.PrereqSkill.AddRange(prerequisiteSkills.OrderBy(x => x.Activity));

            // Add required materials to item
            blueprint.ReqMaterial.AddRange(requiredMaterials.OrderBy(x => x.Activity));
        }
Exemple #37
0
 public static void Send <T> (IHasID sender, T args)
 {
     PerformSend(GetSignatureFor(sender), typeof(T), args);
 }
Exemple #38
0
 public static void Send(IHasID sender)
 {
     PerformSend(GetSignatureFor(sender), null, null);
 }
Exemple #39
0
        /// <summary>
        /// Exports the certificates classes.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableCertificateClass> ExportCertificateClasses(IHasID group)
        {
            List<SerializableCertificateClass> listOfCertClasses = new List<SerializableCertificateClass>();

            // Exclude unused classes
            foreach (CrtClasses certClass in Database.CrtClassesTable)
            {
                Util.UpdatePercentDone(Database.CertificatesTotalCount);

                SerializableCertificateClass crtClass = new SerializableCertificateClass
                {
                    ID = certClass.ID,
                    Name = certClass.ClassName,
                    Description = certClass.Description
                };

                // Export certificate
                SerializableCertificate certificate = Database.CrtCertificatesTable
                    .Where(x => x.ClassID == certClass.ID && x.GroupID == group.ID).Select(ExportCertificate).FirstOrDefault();

                if (certificate == null)
                    continue;

                // Add certificate to class
                crtClass.Certificate = certificate;

                // Add certificate class to classes
                listOfCertClasses.Add(crtClass);
            }
            return listOfCertClasses;
        }
Exemple #40
0
        /// <summary>
        /// Reorders the properties.
        /// </summary>
        /// <param name="gProperties">The properties in general category.</param>
        /// <param name="prop">The prop.</param>
        /// <param name="srcProp">The source prop.</param>
        /// <param name="properties">The properties.</param>
        private static void ReorderProperties(IList<SerializableProperty> gProperties,
            SerializableProperty prop, IHasID srcProp, IList<SerializableProperty> properties)
        {
            int index = properties.IndexOf(prop);

            if (srcProp.ID == PackagedVolumePropertyID)
            {
                properties.Insert(4, prop);
                properties.RemoveAt(index + 1);
                return;
            }

            if (srcProp.ID == BasePricePropertyID)
            {
                gProperties.Insert(0, prop);
                properties.RemoveAt(index);
                return;
            }

            switch (srcProp.ID)
            {
                case DBConstants.StructureHitpointsPropertyID:
                    properties.Insert(0, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.CargoCapacityPropertyID:
                    properties.Insert(1, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.CPUOutputPropertyID:
                    properties.Insert(0, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.VolumePropertyID:
                    properties.Insert(3, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.TechLevelPropertyID:
                    gProperties.Insert(0, prop);
                    properties.RemoveAt(index);
                    break;
                case DBConstants.ShieldRechargeRatePropertyID:
                    properties.Insert(6, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.CapacitorCapacityPropertyID:
                    properties.Insert(0, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.ScanResolutionPropertyID:
                    properties.Insert(4, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.MetaLevelPropertyID:
                    gProperties.Insert(1, prop);
                    properties.RemoveAt(index);
                    break;
                case DBConstants.HullEMResistancePropertyID:
                    properties.Insert(5, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.HullExplosiveResistancePropertyID:
                    properties.Insert(6, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.HullKineticResistancePropertyID:
                    properties.Insert(7, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.HullThermalResistancePropertyID:
                    properties.Insert(8, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.UpgradeCapacityPropertyID:
                    properties.Insert(2, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.RigSlotsPropertyID:
                    properties.Insert(10, prop);
                    properties.RemoveAt(index + 1);
                    break;
                case DBConstants.RigSizePropertyID:
                    properties.Insert(11, prop);
                    properties.RemoveAt(index + 1);
                    break;
            }
        }
Exemple #41
0
        /// <summary>
        /// Exports the stations.
        /// </summary>
        /// <param name="srcSystem">The SRC system.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableStation> ExportStations(IHasID srcSystem)
            => Database.StaStationsTable
                .Where(x => x.SolarSystemID == srcSystem.ID)
                .Select(srcStation =>
                {
                    SerializableStation station = new SerializableStation
                    {
                        ID = srcStation.ID,
                        Name = srcStation.Name,
                        CorporationID = srcStation.CorporationID,
                        CorporationName = Database.InvNamesTable[srcStation.CorporationID].Name,
                        ReprocessingEfficiency = srcStation.ReprocessingEfficiency,
                        ReprocessingStationsTake = srcStation.ReprocessingStationsTake
                    };

                    // Agents
                    station.Agents.AddRange(ExportAgents(srcStation));
                    return station;
                });