Example #1
0
    public void AddLootItem(Vector3 pos, int itemProtoID, int num)
    {
        if (num < 1)
        {
            return;
        }
        ItemProto proto     = ItemProto.Mgr.Instance.Get(itemProtoID);
        int       itemCount = (num - 1) / proto.maxStackNum + 1;

        for (int i = 0; i < itemCount; ++i, num -= proto.maxStackNum)
        {
            ItemObject itemObj = ItemMgr.Instance.CreateItem(itemProtoID);
            if (num >= proto.maxStackNum)
            {
                itemObj.SetStackCount(proto.maxStackNum);
            }
            else
            {
                itemObj.SetStackCount(num);
            }
            LootItemData data = new LootItemData();
            data.id       = itemObj.instanceId;
            data.position = pos;
            data.dropTime = GameTime.Timer.Second;
            AddLootItem(data, true);
        }
    }
Example #2
0
        void Awake()
        {
            logger = Logger;

            Registry.Init("scarcitybundle", "assets", true, false);

            Registry.registerString("copperWireName", "Copper Wire");
            Registry.registerString("copperWireDesc", "By extruding copper we can make a component which allows current to be carried");

            Registry.registerString("oxygenName", "Oxygen");
            Registry.registerString("oxygenDesc", "One of the most plenty and perhaps one of the most important elements in the cluster. We can use this to support life but also as an oxidiser");



            ItemProto oxygen = Registry.registerItem(10002, "oxygenName", "oxygenDesc", "assets/oxygen", 1710);
            ItemProto wire   = Registry.registerItem(10001, "copperWireName", "copperWireDesc", "assets/copper_wire", 1711);

            Registry.registerRecipe(10001, ERecipeType.Assemble, 60, new[] { 1104 }, new[] { 2 }, new[] { wire.ID }, new[] { 1 }, "copperWireDesc", 1);
            Registry.registerRecipe(10002, ERecipeType.Refine, 120, new[] { 1000 }, new[] { 2 }, new[] { oxygen.ID, 1120 }, new[] { 1, 2 }, "oxygenDesc", 1102);



            LDBTool.PostAddDataAction += EditRecipes;

            logger.LogInfo("Scarcity ALPHA has initialized!");
        }
Example #3
0
        public static int registerBuilding(String name, String description, String iconPath, int gridIndex, int modelIndex)
        {
            int id = findAvailableID(2000, LDB.items, items);

            ItemProto proto = new ItemProto
            {
                Type        = EItemType.Production,
                StackSize   = 50,
                IconPath    = iconPath,
                Name        = name,
                Description = description,
                GridIndex   = gridIndex,
                DescFields  = new [] { 22, 11, 12, 1 },
                ID          = id,
                ModelIndex  = modelIndex,
                ModelCount  = 1,
                BuildIndex  = 703,
                BuildMode   = 1,
                IsEntity    = true,
                CanBuild    = true
            };

            LDBTool.PreAddProto(ProtoType.Item, proto);

            items.Add(proto.ID, proto);
            itemLookup.Add(name, proto.ID);
            return(proto.ID);
        }
Example #4
0
    void InitVoxelPage()
    {
        if (!_initVoxelPage)
        {
            UISkillWndCtrl uiSkill = GameUI.Instance.mSkillWndCtrl;
            if (uiSkill._SkillMgr != null)
            {
                if (!uiSkill._SkillMgr.CheckUnlockBuildBlockVoxel())
                {
                    return;
                }
            }

            m_VoxelProtoItems = BSVoxelMatMap.GetAllProtoItems();
            foreach (int id in m_VoxelProtoItems)
            {
                ItemProto proto = ItemProto.Mgr.Instance.Get(id);
                int       index = mWndCtrl.AddVoxelMatListItem(proto.icon[0], "Icon");
                mWndCtrl.mVoxelMatList[index].SetItemID(proto.id);
            }

            mWndCtrl.ToolTip            += OnItemToolTip;
            mWndCtrl.TextureItemOnClick += OnVoxelMatItemClick;
            mWndCtrl.VoxelTypeOnClick   += OnVoxelTypeClick;

            mWndCtrl.ResetVoxelPostion();
            _initVoxelPage = true;
        }
    }
        public static bool CheckBpForGasGiants(PlayerController __instance, BlueprintData blueprint)
        {
            if (GameMain.history.blueprintLimit == 0)
            {
                return(false);
            }
            if (blueprint == null)
            {
                blueprint = __instance.actionBuild.blueprintClipboard;
            }
            if (BlueprintData.IsNullOrEmpty(blueprint))
            {
                return(false);
            }

            if (__instance.gameData.localPlanet?.gasItems == null || __instance.gameData.localPlanet.gasItems.Length == 0)
            {
                return(true);
            }

            foreach (BlueprintBuilding building in blueprint.buildings)
            {
                ItemProto item = LDB.items.Select(building.itemId);
                if (!item.BuildInGas)
                {
                    UIRealtimeTip.Popup("CantPasteThisInGasGiantWarn".Translate());
                    return(false);
                }
            }

            return(true);
        }
Example #6
0
        public override void ProcessPacket(StorageSyncResponsePacket packet, NebulaConnection conn)
        {
            if (IsHost)
            {
                return;
            }

            StorageComponent storageComponent = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.factoryStorage?.storagePool[packet.StorageIndex];

            if (storageComponent != null)
            {
                using (BinaryUtils.Reader reader = new BinaryUtils.Reader(packet.StorageComponent))
                {
                    storageComponent.Import(reader.BinaryReader);
                }
                ItemProto itemProto = LDB.items.Select((int)GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.entityPool[storageComponent.entityId].protoId);

                //Imitation of UIStorageWindow.OnStorageIdChange()
                Multiplayer.Session.Storage.ActiveWindowTitle.text = itemProto.name;
                Multiplayer.Session.Storage.ActiveUIStorageGrid._Free();
                Multiplayer.Session.Storage.ActiveUIStorageGrid._Init(storageComponent);
                Multiplayer.Session.Storage.ActiveStorageComponent = storageComponent;
                Multiplayer.Session.Storage.ActiveUIStorageGrid.SetStorageData(Multiplayer.Session.Storage.ActiveStorageComponent);
                Multiplayer.Session.Storage.ActiveUIStorageGrid._Open();
                Multiplayer.Session.Storage.ActiveUIStorageGrid.OnStorageDataChanged();
                Multiplayer.Session.Storage.ActiveBansSlider.maxValue = storageComponent.size;
                Multiplayer.Session.Storage.ActiveBansSlider.value    = storageComponent.size - storageComponent.bans;
                Multiplayer.Session.Storage.ActiveBansValueText.text  = Multiplayer.Session.Storage.ActiveBansSlider.value.ToString();
                GameMain.galaxy.PlanetById(packet.PlanetId).factory.factoryStorage.storagePool[packet.StorageIndex] = storageComponent;
            }
        }
Example #7
0
        private static bool PreloadPatch(ItemProto __instance, int _index)
        {
            ModelProto modelProto = LDB.models.modelArray[__instance.ModelIndex];

            if (modelProto != null)
            {
                Vector3 lapJoint = Vector3.zero;
                if (__instance.ID == 2303 || __instance.ID == 2304 || __instance.ID == 2305)
                {
                    lapJoint = new Vector3(0, 5.1f, 0);
                }
                else if (__instance.ID == 2302)
                {
                    lapJoint = new Vector3(0, 4.3f, 0);
                }
                else if (__instance.ID == 2309)
                {
                    lapJoint = new Vector3(0, 7.0f, 0);
                }
                else if (__instance.ID == 2308)
                {
                    lapJoint = new Vector3(0, 16.0f, 0);
                }
                if (lapJoint != Vector3.zero)
                {
                    LDB.models.modelArray[__instance.ModelIndex].prefabDesc.multiLevel = true;
                    LDB.models.modelArray[__instance.ModelIndex].prefabDesc.multiLevelAllowInserter = true;
                    LDB.models.modelArray[__instance.ModelIndex].prefabDesc.lapJoint = lapJoint;
                }
            }
            return(true);
        }
Example #8
0
    void OnIsoClick(int index)
    {
        if (mWndCtrl.IsoListSelectIndex > -1)
        {
            mWndCtrl.ClearCostList();

            BSIsoHeadData header = m_IsoHeaders[mWndCtrl.IsoListSelectIndex];
            foreach (var kvp in header.costs)
            {
                int item_id = PEBuildingMan.GetBlockItemProtoID(kvp.Key);

                //				if (item_id < PEBuildingMan.c_MinItemProtoID || item_id > PEBuildingMan.c_MaxItemProtoID)
                //					continue;
                if (item_id == -1)
                {
                    return;
                }

                ItemProto proto = ItemProto.Mgr.Instance.Get(item_id);
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                int player_cnt = pkg.GetItemCount(item_id);
                int final_cnt  = Mathf.Clamp(player_cnt, 0, 9999);
                mWndCtrl.AddCostListItem(proto.GetName(), Mathf.CeilToInt(kvp.Value / 4.0f).ToString() + '/' + final_cnt.ToString(), proto.icon[0], "Icon");
            }
            IsoRePos = true;
            //mWndCtrl.ResetCostPostion();
        }
    }
Example #9
0
        private void AddItem()
        {
            itemSapling             = LDB.items.Select(1201).Copy();
            itemSapling.ID          = 9150;
            itemSapling.GridIndex   = 1506;
            itemSapling.Type        = EItemType.Resource;
            itemSapling.Name        = "sapling";
            itemSapling.name        = itemSapling.Name.Translate();
            itemSapling.Description = "";
            itemSapling.description = "";
            Traverse.Create(itemSapling).Field("_iconSprite").SetValue(_iconSapling);
            LDBTool.PostAddProto(ProtoType.Item, itemSapling);

            itemCharcoal             = LDB.items.Select(1109).Copy();
            itemCharcoal.ID          = 9151;
            itemCharcoal.GridIndex   = 1507;
            itemCharcoal.Type        = EItemType.Resource;
            itemCharcoal.HeatValue   = 2700000;
            itemCharcoal.ReactorInc  = 0.0f;
            itemCharcoal.Name        = "charcoal";
            itemCharcoal.name        = itemCharcoal.Name.Translate();
            itemCharcoal.Description = "charcoalDesc";
            itemCharcoal.description = itemCharcoal.Description.Translate();
            Traverse.Create(itemCharcoal).Field("_iconSprite").SetValue(_iconCharcoal);
            LDBTool.PostAddProto(ProtoType.Item, itemCharcoal);
        }
        public static void SetPlanetTheme(
            ref PlanetData planet,
            ref StarData star,
            int theme_seed
            )
        {
            planet.theme = GasThemes[UnityRandom.Range(0, GasThemes.Length - 1)];
            ThemeProto themeProto1 = LDB.themes.Select(planet.theme);
            int        length1     = themeProto1.GasItems.Length;
            int        length2     = themeProto1.GasSpeeds.Length;

            int[]   numArray1 = new int[length1];
            float[] numArray2 = new float[length2];
            float[] numArray3 = new float[length1];
            for (int index = 0; index < length1; ++index)
            {
                numArray1[index] = themeProto1.GasItems[index];
            }
            double num1 = 0.0;

            System.Random random = new System.Random(theme_seed);
            for (int index = 0; index < length2; ++index)
            {
                float num2 = themeProto1.GasSpeeds[index] * (float)(random.NextDouble() * 0.190909147262573 + 0.909090876579285);
                numArray2[index] = num2 * Mathf.Pow(star.resourceCoef, 0.3f);
                ItemProto itemProto = LDB.items.Select(numArray1[index]);
                numArray3[index] = (float)itemProto.HeatValue;
                num1            += (double)numArray3[index] * (double)numArray2[index];
            }
            planet.gasItems      = numArray1;
            planet.gasSpeeds     = numArray2;
            planet.gasHeatValues = numArray3;
            planet.gasTotalHeat  = num1;
        }
        public void ProcessPacket(UpgradeEntityRequest packet, NebulaConnection conn)
        {
            PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

            // We only execute the code if the client has loaded the factory at least once.
            // Else he will get it once it goes to the planet for the first time.
            if (planet.factory != null)
            {
                using (FactoryManager.EventFromServer.On())
                {
                    if (packet.PlanetId != GameMain.localPlanet?.id)
                    {
                        planet.physics = new PlanetPhysics(planet);
                        planet.physics.Init();
                        planet.audio = new PlanetAudio(planet);
                        planet.audio.Init();
                    }

                    ItemProto itemProto = LDB.items.Select(packet.UpgradeProtoId);
                    FactoryManager.TargetPlanet = packet.PlanetId;
                    planet.factory.UpgradeFinally(GameMain.mainPlayer, packet.ObjId, itemProto);
                    FactoryManager.TargetPlanet = -2;

                    if (packet.PlanetId != GameMain.localPlanet?.id)
                    {
                        planet.physics.Free();
                        planet.physics = null;
                        planet.audio.Free();
                        planet.audio = null;
                    }
                }
            }
        }
Example #12
0
        private BoxGizmo CreateEntityGizmo(EntityData entityData)
        {
            YHDebug.LogFormat("create gizmo {0}", entityData.id);
            if (entityData.id <= 0)                     //|| entityData.beltId != 0
            {
                return(null);
            }

            BoxGizmo gizmo = null;

            ItemProto itemProto2 = LDB.items.Select(entityData.protoId);
            Vector3   position   = entityData.pos;
            float     num        = itemProto2.prefabDesc.buildCollider.ext.magnitude * 0.7f;

            if (entityData.inserterId == 0)
            {
                gizmo = BoxGizmo.Create(entityData.pos, entityData.rot, itemProto2.prefabDesc.selectCenter, itemProto2.prefabDesc.selectSize);
            }
            else
            {
                ColliderData colliderData2 = player.planetData.physics.GetColliderData(entityData.colliderId);
                colliderData2.ext.x += 0.1f;
                gizmo = BoxGizmo.Create(colliderData2.pos, colliderData2.q, Vector3.zero, colliderData2.ext * 2f);
            }
            gizmo.multiplier      = 1f;
            gizmo.alphaMultiplier = itemProto2.prefabDesc.selectAlpha;
            gizmo.fadeInScale     = 1.3f;
            gizmo.fadeInTime      = 0.05f;
            gizmo.fadeInFalloff   = 0.5f;
            gizmo.fadeOutScale    = 1.3f;
            gizmo.fadeOutTime     = 0.05f;
            gizmo.fadeOutFalloff  = 0.5f;
            gizmo.color           = Color.white;
            return(gizmo);
        }
Example #13
0
    void RPC_S2C_NewItemList(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        ItemSample[] newItems = stream.Read <ItemSample[]>();

        if (null == newItems || newItems.Length <= 0)
        {
            return;
        }

        foreach (ItemSample item in newItems)
        {
            if (null == item)
            {
                continue;
            }

            if (null != MissionManager.Instance)
            {
                MissionManager.Instance.ProcessCollectMissionByID(item.protoId);
            }
//			GlobalShowGui_N.Instance.AddShow(item);

            ItemProto protoData = ItemProto.Mgr.Instance.Get(item.protoId);
            if (protoData == null)
            {
                continue;
            }

            string msg = protoData.GetName() + " X " + item.stackCount.ToString();
            /*PeTipMsg tips = */ new PeTipMsg(msg, protoData.icon[0], PeTipMsg.EMsgLevel.Norm, PeTipMsg.EMsgType.Misc);
        }
    }
Example #14
0
        public static void OnStationIdChangePre(UIStationWindow __instance, ref string __state)
        {
            if (__instance.stationId == 0 || __instance.factory == null || __instance.transport?.stationPool == null)
            {
                return;
            }

            StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId];

            ItemProto itemProto = LDB.items.Select(__instance.factory.entityPool[stationComponent.entityId].protoId);

            if (itemProto.ID != GigaStationsPlugin.pls.ID && itemProto.ID != GigaStationsPlugin.ils.ID && itemProto.ID != GigaStationsPlugin.collector.ID)
            {
                return;
            }

            if (!__instance.active)
            {
                return;
            }

            string text = (!string.IsNullOrEmpty(stationComponent.name))
                ? stationComponent.name
                : ((!stationComponent.isStellar)
                    ? ("Planetary Giga Station #" + stationComponent.id)
                    : ((stationComponent.isCollector)
                        ? ("Orbital Giga Collector #" + stationComponent.gid)
                        : ("Interstellar Giga Station #" + stationComponent.gid)));

            __state = text;
        }
Example #15
0
 //lz-2016.08.08 通过ItemID找到所有可以合成这个Item的脚本
 private void AddScriptItemData(int itemID)
 {
     if (!this.m_Formulas.ContainsKey(itemID))
     {
         List <Pathea.Replicator.Formula> formulaList = Pathea.Replicator.Formula.Mgr.Instance.FindAllByProDuctID(itemID);
         if (null == formulaList || formulaList.Count <= 0)
         {
             return;
         }
         List <Pathea.Replicator.KnownFormula> knownFormulaList = new List <Replicator.KnownFormula>();
         for (int i = 0; i < formulaList.Count; i++)
         {
             Pathea.Replicator.KnownFormula knownFormula = UIGraphControl.GetReplicator().GetKnownFormula(formulaList[i].id);
             if (null != knownFormula)
             {
                 knownFormulaList.Add(knownFormula);
             }
         }
         ItemProto item = ItemProto.GetItemData(itemID);
         this.m_ItemDataList.Add(item);
         this.m_Formulas.Add(itemID, knownFormulaList);
     }
     if (this.m_Formulas.ContainsKey(itemID) && itemID != this.m_CurItemID)
     {
         this.UpdateCurItemScriptList(itemID);
         this.SelectFirstScritItem(false);
     }
 }
Example #16
0
        public override void OnUpdate()
        {
            tmpHintList.Clear();

            foreach (BlueprintBuilding blueprintBuilding in inspector.blueprint.buildings)
            {
                int       protoId = blueprintBuilding.itemId;
                ItemProto proto   = LDB.items.Select(protoId);

                if (proto.prefabDesc.isBelt)
                {
                    if (blueprintBuilding.parameters != null && blueprintBuilding.parameters.Length == 1)
                    {
                        tmpHintList.Add(blueprintBuilding.parameters[0]);
                    }
                }
            }

            int num = 0;

            foreach (int itemId in tmpHintList)
            {
                SetItem(num, itemId);
                num++;
            }

            ClearComponentItems(num);
        }
Example #17
0
        public void ChangeHint(int oldSignalId, int newSignal)
        {
            foreach (BlueprintBuilding blueprintBuilding in inspector.blueprint.buildings)
            {
                int       protoId = blueprintBuilding.itemId;
                ItemProto proto   = LDB.items.Select(protoId);

                if (!proto.prefabDesc.isBelt)
                {
                    continue;
                }
                if (blueprintBuilding.parameters == null)
                {
                    continue;
                }
                if (blueprintBuilding.parameters.Length != 1)
                {
                    continue;
                }

                if (blueprintBuilding.parameters[0] == oldSignalId)
                {
                    blueprintBuilding.parameters[0] = newSignal;
                }
            }


            if (inspector.usage == UIBlueprintInspector.EUsage.Paste)
            {
                inspector.pasteBuildTool.ResetStates();
            }

            inspector.Refresh(true, true, true);
        }
Example #18
0
 public frmClone(ItemProto proto, ushort suggestedPid)
 {
     InitializeComponent();
     this.Text += string.Format("{0} ({1})", proto.Name, proto.ProtoId);
     this.numPid.Maximum = ushort.MaxValue;
     this.numPid.Value = suggestedPid;
 }
 /// <summary>
 /// 移除建筑
 /// </summary>
 /// <param name="player">玩家</param>
 /// <param name="factory">工厂</param>
 /// <param name="objId">实体id/预建筑id</param>
 /// <returns></returns>
 public static bool RemoveBuild(Player player, PlanetFactory factory, int objId)
 {
     try
     {
         if (player.package.isFull)
         {
             UIRealtimeTip.Popup(ST.背包不足);
             return(false);
         }
         int       num       = -objId;
         ItemProto itemProto = null;
         if (objId > 0)
         {
             itemProto = LDB.items.Select((int)factory.entityPool[objId].protoId);
         }
         if (num > 0)
         {
             itemProto = LDB.items.Select((int)factory.prebuildPool[num].protoId);
         }
         int itemId = (itemProto == null) ? 0 : itemProto.ID;
         factory.DestructFinally(player, objId, ref itemId);
         player.package.AddItemStacked(itemId, 1);
         UIItemup.Up(itemId, 1);
         return(true);
     }
     catch (Exception e)
     {
         Debug.LogError(e.Message);
         Debug.LogError(e.StackTrace);
         return(false);
     }
 }
Example #20
0
    void SetMenuListItemContent(int index, GameObject go)
    {
        UICompoundWndListItem item = go.GetComponent <UICompoundWndListItem>();

        if (item == null)
        {
            return;
        }
        if (index < 0 || index >= m_ItemDataList.Count)
        {
            return;
        }

        ItemProto data = m_ItemDataList[index];

        if (!this.m_Formulas.ContainsKey(data.id))
        {
            return;
        }

        //lz-2016.08.08 有任何可以合成这个Item的新脚本就标记为new
        bool newFlag = this.m_Formulas[data.id].Any(a => a.flag == true);

        item.SetItem(data.name, data.id, newFlag, data.icon, data.GetName(), index, ListItemType.mItem);
        item.SetSelectmState(false);

        item.mItemClick -= OnMenuListItemClick;
        item.mItemClick += OnMenuListItemClick;
    }
Example #21
0
    void OnPlayerItemPackageEvent(object sender, PlayerPackageCmpt.GetItemEventArg e)
    {
//		ItemPackage.EventArg.Op type = e.;


        PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();

        if (pkg == null)
        {
            return;
        }

//		ItemObject io = e.itemObj;
//		if (io == null)
//			return;
        ItemProto item = ItemProto.Mgr.Instance.Get(e.protoId);

        if (item == null)
        {
            return;
        }

        //lz-2018.1.19 获取东西的时候显示背包数量
        string msg = string.Format("{0} X {1} ({2})", item.GetName(), e.count, pkg.GetItemCount(e.protoId));

        new PeTipMsg(msg, item.icon[0], PeTipMsg.EMsgLevel.Norm, PeTipMsg.EMsgType.Misc);
//		PeTipMsg tips = new PeTipMsg(msg, PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
    }
Example #22
0
 public frmClone(ItemProto proto, ushort suggestedPid)
 {
     InitializeComponent();
     this.Text          += string.Format("{0} ({1})", proto.Name, proto.ProtoId);
     this.numPid.Maximum = ushort.MaxValue;
     this.numPid.Value   = suggestedPid;
 }
    // Update is called once per frame
    void Update()
    {
        if (m_RefCommon == null)
        {
            return;
        }

        m_NameUI.text = m_RefCommon.Name;
        ItemProto itemData = ItemProto.GetItemData(m_RefCommon.ItemID);

        if (itemData != null)
        {
            string[] iconStr = ItemProto.GetItemData(m_RefCommon.ItemID).icon;
            if (iconStr.Length != 0)
            {
                m_IconUI.spriteName = iconStr[0];
            }
            else
            {
                m_IconUI.spriteName = "";
            }
        }

        float percent = m_RefCommon.BaseData.m_Durability / m_RefCommon.m_Info.m_Durability;

        m_LifeProgressUI.sliderValue = percent;

        string str = "";

        str          += Mathf.RoundToInt(m_RefCommon.BaseData.m_Durability).ToString();
        str          += " / ";
        str          += Mathf.RoundToInt(m_RefCommon.m_Info.m_Durability).ToString();
        m_LifeUI.text = str;
    }
Example #24
0
        void ResetStackSize(ItemProto itemProto, InputField inputField)
        {
            try
            {
                //ItemProto tmpProto = originalItemProtos.Select(itemProto.ID);
                //var tmpProto = originalItemProtoArray.Where(x => x.ID == itemProto.ID).First();
                int oss = StackSizeEditorPlugin.originalStackSizes[itemProto.ID];

                inputField.text = oss.ToString();

                if (itemProto.StackSize != oss)
                {
                    LDB.items.Select(itemProto.ID).StackSize      = oss;
                    StorageComponent.itemStackCount[itemProto.ID] = oss;
                }

                if (saveData == null || saveData.StackSizesDict == null || saveData.StackSizesDict.Count == 0)
                {
                    return;
                }

                if (saveData.StackSizesDict.ContainsKey(itemProto.ID))
                {
                    saveData.StackSizesDict.Remove(itemProto.ID);
                    SaveSaveData();
                }
            }
            catch
            {
            }
        }
Example #25
0
        public void ProcessPacket(UpgradeEntityRequest packet, NebulaConnection conn)
        {
            using (FactoryManager.EventFromClient.On())
            {
                PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

                // Physics could be null, if the host is not on the requested planet
                if (packet.PlanetId != GameMain.localPlanet?.id)
                {
                    planet.physics = new PlanetPhysics(planet);
                    planet.physics.Init();
                    planet.audio = new PlanetAudio(planet);
                    planet.audio.Init();
                }

                ItemProto itemProto = LDB.items.Select(packet.UpgradeProtoId);
                FactoryManager.TargetPlanet = packet.PlanetId;
                planet.factory.UpgradeFinally(GameMain.mainPlayer, packet.ObjId, itemProto);
                FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE;

                if (packet.PlanetId != GameMain.localPlanet?.id)
                {
                    planet.physics.Free();
                    planet.physics = null;
                    planet.audio.Free();
                    planet.audio = null;
                }
            }
        }
        public void ProcessPacket(StorageSyncResponsePacket packet, NebulaConnection conn)
        {
            StorageComponent storageComponent = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.factoryStorage?.storagePool[packet.StorageIndex];

            if (storageComponent != null)
            {
                using (BinaryUtils.Reader reader = new BinaryUtils.Reader(packet.StorageComponent))
                {
                    storageComponent.Import(reader.BinaryReader);
                }
                ItemProto itemProto = LDB.items.Select((int)GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.entityPool[storageComponent.entityId].protoId);

                //Imitation of UIStorageWindow.OnStorageIdChange()
                StorageManager.ActiveWindowTitle.text = itemProto.name;
                StorageManager.ActiveUIStorageGrid._Free();
                StorageManager.ActiveUIStorageGrid._Init(storageComponent);
                StorageManager.ActiveStorageComponent = storageComponent;
                MethodInvoker.GetHandler(AccessTools.Method(typeof(UIStorageGrid), "SetStorageData")).Invoke(StorageManager.ActiveUIStorageGrid, StorageManager.ActiveStorageComponent);
                StorageManager.ActiveUIStorageGrid._Open();
                StorageManager.ActiveUIStorageGrid.OnStorageDataChanged();
                StorageManager.ActiveBansSlider.maxValue = (float)storageComponent.size;
                StorageManager.ActiveBansSlider.value    = (float)(storageComponent.size - storageComponent.bans);
                StorageManager.ActiveBansValueText.text  = StorageManager.ActiveBansSlider.value.ToString();
                GameMain.galaxy.PlanetById(packet.PlanetId).factory.factoryStorage.storagePool[packet.StorageIndex] = storageComponent;
            }
        }
Example #27
0
        public override void ProcessPacket(UpgradeEntityRequest packet, NebulaConnection conn)
        {
            using (Multiplayer.Session.Factories.IsIncomingRequest.On())
            {
                PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

                // We only execute the code if the client has loaded the factory at least once.
                // Else they will get it once they go to the planet for the first time.
                if (planet?.factory == null)
                {
                    return;
                }

                Multiplayer.Session.Factories.TargetPlanet = packet.PlanetId;
                Multiplayer.Session.Factories.PacketAuthor = packet.AuthorId;

                Multiplayer.Session.Factories.AddPlanetTimer(packet.PlanetId);
                ItemProto itemProto = LDB.items.Select(packet.UpgradeProtoId);

                // setting specifyPlanet here to avoid accessing a null object (see GPUInstancingManager activePlanet getter)
                PlanetData pData = GameMain.gpuiManager.specifyPlanet;

                GameMain.gpuiManager.specifyPlanet = planet;
                planet.factory.UpgradeFinally(GameMain.mainPlayer, packet.ObjId, itemProto);
                GameMain.gpuiManager.specifyPlanet = pData;

                Multiplayer.Session.Factories.TargetPlanet = NebulaModAPI.PLANET_NONE;
                Multiplayer.Session.Factories.PacketAuthor = NebulaModAPI.AUTHOR_NONE;
            }
        }
Example #28
0
        /// <summary>
        /// Registers a RecipeProto
        /// </summary>
        /// <param name="id">UNIQUE id of your recipe</param>
        /// <param name="type">Recipe type</param>
        /// <param name="time">Time in ingame ticks. How long item is being made</param>
        /// <param name="input">Array of input IDs</param>
        /// <param name="inCounts">Array of input COUNTS</param>
        /// <param name="output">Array of output IDs</param>
        /// <param name="outCounts">Array of output COUNTS</param>
        /// <param name="description">LocalizedKey of description of this item</param>
        /// <param name="techID">Tech id, which unlock this recipe</param>
        public static void registerRecipe(int id, ERecipeType type, int time, int[] input, int[] inCounts,
                                          int[] output,
                                          int[] outCounts, string description, int techID = 1)
        {
            if (output.Length > 0)
            {
                ItemProto first = items[output[0]];
                TechProto tech  = LDB.techs.Select(techID);

                RecipeProto proto = new RecipeProto
                {
                    Type         = type,
                    Handcraft    = true,
                    TimeSpend    = time,
                    Items        = input,
                    ItemCounts   = inCounts,
                    Results      = output,
                    ResultCounts = outCounts,
                    Description  = description,
                    GridIndex    = first.GridIndex,
                    IconPath     = first.IconPath,
                    Name         = first.Name + "Recipe",
                    preTech      = tech,
                    ID           = id
                };

                LDBTool.PreAddProto(ProtoType.Recipe, proto);
                recipes.Add(id, proto);
            }
        }
Example #29
0
        public void ChangeItem(int stationId, int slotId, ItemProto newItem)
        {
            if (stationId < 0 || stationId >= inspector.blueprint.buildings.Length)
            {
                return;
            }

            BlueprintBuilding building = inspector.blueprint.buildings[stationId];

            int       protoId = building.itemId;
            ItemProto proto   = LDB.items.Select(protoId);

            if (!proto.prefabDesc.isStation || proto.prefabDesc.isCollectStation)
            {
                return;
            }

            int[] parameters = building.parameters;
            if (parameters == null || parameters.Length < 2048)
            {
                return;
            }

            if (parameters[slotId * 6] > 0)
            {
                parameters[slotId * 6] = newItem.ID;
            }

            if (inspector.usage == UIBlueprintInspector.EUsage.Paste)
            {
                inspector.pasteBuildTool.ResetStates();
            }

            inspector.Refresh(true, true, true);
        }
Example #30
0
        private void WindowFunc(int id)
        {
            GUILayout.BeginVertical(GUILayout.Width(550), GUILayout.Height(700));
            sv = GUILayout.BeginScrollView(sv, UnityEngine.GUI.skin.box);
            for (int veinGroupIndex = 1; veinGroupIndex < localPlanet.veinGroups.Length; veinGroupIndex++)
            {
                PlanetData.VeinGroup veinGroup = localPlanet.veinGroups[veinGroupIndex];
                int       veinProduct          = PlanetModelingManager.veinProducts[(int)veinGroup.type];
                ItemProto itemProto            = veinProduct != 0 ? LDB.items.Select(veinProduct) : null;
                Texture2D texture  = null;
                string    veinName = null;
                if (itemProto != null)
                {
                    texture  = itemProto.iconSprite.texture;
                    veinName = itemProto.name.Translate();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Box(texture, VeinIconLayoutOptions);
                GUILayout.Box("Type " + veinGroup.type + "\n" + veinName);

                GUILayout.Label("Count " + veinGroup.count);
                GUILayout.Label("Amount " + veinGroup.amount);

                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            UnityEngine.GUI.DragWindow();
        }
Example #31
0
        /// <summary>
        /// Registers a ItemProto for a BUILDING
        /// </summary>
        /// <param name="id">UNIQUE id of your building</param>
        /// <param name="name">LocalizedKey of name of the item</param>
        /// <param name="description">LocalizedKey of description of the item</param>
        /// <param name="iconPath">Path to icon, starting from assets folder of your unity project</param>
        /// <param name="gridIndex">Index in craft menu, format : PYXX, P - page</param>
        /// <param name="modelIndex">Index of model for this building</param>
        /// <param name="descFields">int Array of used description fields</param>
        /// <param name="buildIndex">Index in build Toolbar, FSS, F - first submenu, S - second submenu</param>
        /// <param name="grade">Grade of the building, used to add upgrading</param>
        /// <param name="upgradesIDs">List of buildings ids, that are upgradable to this one. You need to include all of them here in order. ID of this building should be zero</param>
        public static ItemProto registerBuilding(int id, string name, string description, string iconPath,
                                                 int gridIndex, int modelIndex, int[] descFields, int buildIndex, int grade = 0,
                                                 int[] upgradesIDs = null)
        {
            ItemProto proto = registerItem(id, name, description, iconPath, gridIndex);

            proto.Type       = EItemType.Production;
            proto.ModelIndex = modelIndex;
            proto.ModelCount = 1;
            proto.BuildIndex = buildIndex;
            proto.BuildMode  = 1;
            proto.IsEntity   = true;
            proto.CanBuild   = true;
            proto.DescFields = descFields;
            if (grade != 0 && upgradesIDs != null)
            {
                proto.Grade = grade;
                for (int i = 0; i < upgradesIDs.Length; i++)
                {
                    int itemID = upgradesIDs[i];
                    if (itemID == 0)
                    {
                        continue;
                    }

                    itemUpgradeList.Add(itemID, i + 1);
                }

                upgradesIDs[grade - 1] = proto.ID;
                proto.Upgrades         = upgradesIDs;
            }

            return(proto);
        }
Example #32
0
        private void SetNewProto(ItemProto Prot)
        {
            if (CurrentProto != null)
                SetProtoGUI(CurrentProto, false); // Save data to proto
            CurrentProto = Prot;
            SetProtoGUI(CurrentProto, true);
            if (Config.SwitchTab)
            {
                TabPage Page = GetTabPageByItemType(CurrentProto.Type);
                if(Page==null)
                {
                    foreach(TabPage TopPage in panelProperties.Controls)
                    {
                        String ItemType = (String)TopPage.Tag;
                        if (ItemType == null)
                            continue;
                        if (Data.ItemTypes.ContainsKey(ItemType) || Data.ItemTypes.ContainsKey("ITEM_TYPE_"+ItemType))
                        {
                            Page = TopPage;
                            break;
                        }
                    }

                }

                panelProperties.SelectedTab = Page;
                lstProtos.Focus();
            }
        }
Example #33
0
        void SetProtoGUI(ItemProto Prot, bool ToUI)
        {
            if (Prot == null) return;

            // UI<->Data sync
            // Uncommented stuff are not implemented in GUI yet
            #region SetControl
            try
            {
                FOCommon.Utils.SetControl(numPID, ref Prot.ProtoId, ToUI);
                FOCommon.Utils.SetControl(cmbType, ref Prot.Type, Data.ItemTypes, ToUI);
                FOCommon.Utils.SetControl(txtName, ref Prot.Name, ToUI);
                FOCommon.Utils.SetControl(txtProtoFileName, ref Prot.FileName, ToUI);
                FOCommon.Utils.SetControl(txtDescription, ref Prot.Description, ToUI);
                FOCommon.Utils.SetControl(txtScriptModule, ref Prot.ScriptModule, ToUI);
                FOCommon.Utils.SetControl(txtScriptFunction, ref Prot.ScriptFunction, ToUI);
                FOCommon.Utils.SetControl(txtGroundPic, ref Prot.PicMap, ToUI);
                FOCommon.Utils.SetControl(txtInvPic, ref Prot.PicInv, ToUI);
                FOCommon.Utils.SetControl(chkStackable, ref Prot.Stackable, ToUI);
                FOCommon.Utils.SetControl(chkDeteriorable, ref Prot.Deteriorable, ToUI);
                FOCommon.Utils.SetControl(chkGroundLevel, ref Prot.GroundLevel, ToUI);
                //                                = Prot.Dir;
                FOCommon.Utils.SetControl(numSlot, ref Prot.Slot, ToUI);
                FOCommon.Utils.SetControl(numWeight, ref Prot.Weight, ToUI);
                FOCommon.Utils.SetControl(numVolume, ref Prot.Volume, ToUI);
                FOCommon.Utils.SetControl(numCost, ref Prot.Cost, ToUI);
                FOCommon.Utils.SetControl(numStartCount, ref Prot.StartCount, ToUI);
                FOCommon.Utils.SetControl(numSoundId, ref Prot.SoundId, ToUI);
                FOCommon.Utils.SetControl(numLightDistance, ref Prot.LightDistance, ToUI);
                FOCommon.Utils.SetControl(numLightIntensity, ref Prot.LightIntensity, ToUI);
                FOCommon.Utils.SetControl(chkDisableEgg, ref Prot.DisableEgg, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitBase, ref Prot.AnimWaitBase, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitMin, ref Prot.AnimWaitRndMin, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitMax, ref Prot.AnimWaitRndMax, ToUI);
                FOCommon.Utils.SetControl(numAnimStay0, ref Prot.AnimStay_0, ToUI);
                FOCommon.Utils.SetControl(numAnimStay1, ref Prot.AnimStay_1, ToUI);
                FOCommon.Utils.SetControl(numAnimShow0, ref Prot.AnimShow_0, ToUI);
                FOCommon.Utils.SetControl(numAnimShow1, ref Prot.AnimShow_1, ToUI);
                FOCommon.Utils.SetControl(numAnimHide0, ref Prot.AnimHide_0, ToUI);
                FOCommon.Utils.SetControl(numAnimHide1, ref Prot.AnimHide_1, ToUI);
                FOCommon.Utils.SetControl(numDrawOffsetsX, ref Prot.OffsetX, ToUI);
                FOCommon.Utils.SetControl(numDrawOffsetsY, ref Prot.OffsetY, ToUI);
                FOCommon.Utils.SetControl(numDrawOrderOffsetHexY, ref Prot.DrawOrderOffsetHexY, ToUI);
                FOCommon.Utils.SetControl(numRadioChannel, ref Prot.RadioChannel, ToUI);
                FOCommon.Utils.SetControl(numRadioBroadcastSend, ref Prot.RadioBroadcastSend, ToUI);
                FOCommon.Utils.SetControl(numRadioBroadcastReceive, ref Prot.RadioBroadcastRecv, ToUI);
                FOCommon.Utils.SetControl(numIndicatorStart, ref Prot.IndicatorStart, ToUI);
                FOCommon.Utils.SetControl(numIndicatorMax, ref Prot.IndicatorMax, ToUI);
                FOCommon.Utils.SetControl(numHolodiskNum, ref Prot.HolodiskNum, ToUI);
                FOCommon.Utils.SetControl(numStartValue1, ref Prot.StartValue[0], ToUI);
                FOCommon.Utils.SetControl(numStartValue2, ref Prot.StartValue[1], ToUI);
                FOCommon.Utils.SetControl(numStartValue3, ref Prot.StartValue[2], ToUI);
                FOCommon.Utils.SetControl(numStartValue4, ref Prot.StartValue[3], ToUI);
                FOCommon.Utils.SetControl(numStartValue5, ref Prot.StartValue[4], ToUI);
                FOCommon.Utils.SetControl(numStartValue6, ref Prot.StartValue[5], ToUI);
                FOCommon.Utils.SetControl(numStartValue7, ref Prot.StartValue[6], ToUI);
                FOCommon.Utils.SetControl(numStartValue8, ref Prot.StartValue[7], ToUI);
                FOCommon.Utils.SetControl(numStartValue9, ref Prot.StartValue[8], ToUI);
                FOCommon.Utils.SetControl(numStartValue10, ref Prot.StartValue[9], ToUI);
                FOCommon.Utils.SetControl(txtBlockLines, ref Prot.BlockLines, ToUI);
                FOCommon.Utils.SetControl(numChildPid1, ref Prot.ChildPid[0], ToUI);
                FOCommon.Utils.SetControl(numChildPid2, ref Prot.ChildPid[1], ToUI);
                FOCommon.Utils.SetControl(numChildPid3, ref Prot.ChildPid[2], ToUI);
                FOCommon.Utils.SetControl(numChildPid4, ref Prot.ChildPid[3], ToUI);
                FOCommon.Utils.SetControl(numChildPid5, ref Prot.ChildPid[4], ToUI);
                FOCommon.Utils.SetControl(txtChildLines1, ref Prot.ChildLines[0], ToUI);
                FOCommon.Utils.SetControl(txtChildLines2, ref Prot.ChildLines[1], ToUI);
                FOCommon.Utils.SetControl(txtChildLines3, ref Prot.ChildLines[2], ToUI);
                FOCommon.Utils.SetControl(txtChildLines4, ref Prot.ChildLines[3], ToUI);
                FOCommon.Utils.SetControl(txtChildLines5, ref Prot.ChildLines[4], ToUI);
                // Weapon stuff
                FOCommon.Utils.SetControl(chkIsUnarmed, ref Prot.Weapon_IsUnarmed, ToUI);
                FOCommon.Utils.SetControl(numUnarmedTree, ref Prot.Weapon_UnarmedTree, ToUI);
                FOCommon.Utils.SetControl(numUnarmedPriority, ref Prot.Weapon_UnarmedPriority, ToUI);
                FOCommon.Utils.SetControl(numMinAgility, ref Prot.Weapon_UnarmedMinAgility, ToUI);
                FOCommon.Utils.SetControl(numMinUnarmed, ref Prot.Weapon_UnarmedMinUnarmed, ToUI);
                FOCommon.Utils.SetControl(numMinLevel, ref Prot.Weapon_UnarmedMinLevel, ToUI);
                FOCommon.Utils.SetControl(cmbAnim1, ref Prot.Weapon_Anim1, Data.Anim1, ToUI);
                FOCommon.Utils.SetControl(numMaxAmmoCount, ref Prot.Weapon_MaxAmmoCount, ToUI);
                FOCommon.Utils.SetControl(cmbCaliberWeapon, ref Prot.Weapon_Caliber, Data.Calibers, ToUI);
                FOCommon.Utils.SetControl(cmdWeaponDefaultAmmo, ref Prot.Weapon_DefaultAmmoPid, Data.ItemPid, ToUI);
                FOCommon.Utils.SetControl(numMinStrength, ref Prot.Weapon_MinStrength, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponPerk, ref Prot.Weapon_Perk, Data.WeaponPerks, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill1, ref Prot.Weapon_Skill_0, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill2, ref Prot.Weapon_Skill_1, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill3, ref Prot.Weapon_Skill_2, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_1, ref Prot.Weapon_Anim2_0, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_2, ref Prot.Weapon_Anim2_1, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_3, ref Prot.Weapon_Anim2_2, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType1, ref Prot.Weapon_DmgType_0, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType2, ref Prot.Weapon_DmgType_1, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType3, ref Prot.Weapon_DmgType_2, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove1, ref Prot.Weapon_Remove_0, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove2, ref Prot.Weapon_Remove_1, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove3, ref Prot.Weapon_Remove_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect1, ref Prot.Weapon_FlyEffect_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect2, ref Prot.Weapon_FlyEffect_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect3, ref Prot.Weapon_FlyEffect_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin1, ref Prot.Weapon_DmgMin_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin2, ref Prot.Weapon_DmgMin_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin3, ref Prot.Weapon_DmgMin_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax1, ref Prot.Weapon_DmgMax_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax2, ref Prot.Weapon_DmgMax_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax3, ref Prot.Weapon_DmgMax_2, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics1, ref Prot.Weapon_PicUse_0, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics2, ref Prot.Weapon_PicUse_1, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics3, ref Prot.Weapon_PicUse_2, ToUI);
                FOCommon.Utils.SetControl(numDistance1, ref Prot.Weapon_MaxDist_0, ToUI);
                FOCommon.Utils.SetControl(numDistance2, ref Prot.Weapon_MaxDist_1, ToUI);
                FOCommon.Utils.SetControl(numDistance3, ref Prot.Weapon_MaxDist_2, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound1, ref Prot.Weapon_Round_0, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound2, ref Prot.Weapon_Round_1, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound3, ref Prot.Weapon_Round_2, ToUI);
                FOCommon.Utils.SetControl(numAttackAP1, ref Prot.Weapon_ApCost_0, ToUI);
                FOCommon.Utils.SetControl(numAttackAP2, ref Prot.Weapon_ApCost_1, ToUI);
                FOCommon.Utils.SetControl(numAttackAP3, ref Prot.Weapon_ApCost_2, ToUI);
                FOCommon.Utils.SetControl(txtSoundId1, ref Prot.Weapon_SoundId_0, ToUI);
                FOCommon.Utils.SetControl(txtSoundId2, ref Prot.Weapon_SoundId_1, ToUI);
                FOCommon.Utils.SetControl(txtSoundId3, ref Prot.Weapon_SoundId_2, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable1, ref Prot.Weapon_Aim_0, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable2, ref Prot.Weapon_Aim_1, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable3, ref Prot.Weapon_Aim_2, ToUI);
                FOCommon.Utils.SetControl(cmbCaliberAmmo, ref Prot.Ammo_Caliber, Data.Calibers, ToUI);
                FOCommon.Utils.SetControl(numCriticalFailure, ref Prot.Weapon_CriticalFailture, ToUI);
                FOCommon.Utils.SetControl(numAcMod, ref Prot.Ammo_AcMod, ToUI);
                FOCommon.Utils.SetControl(numDrMod, ref Prot.Ammo_DrMod, ToUI);
                FOCommon.Utils.SetControl(numCrTypeMale, ref Prot.Armor_CrTypeMale, ToUI);
                FOCommon.Utils.SetControl(numCrTypeFemale, ref Prot.Armor_CrTypeFemale, ToUI);

                // Misc
                FOCommon.Utils.SetControl(chkDoorNoBlockLight, ref Prot.Door_NoBlockLight, ToUI);
                FOCommon.Utils.SetControl(chkDoorNoBlockShoot, ref Prot.Door_NoBlockShoot, ToUI);
                FOCommon.Utils.SetControl(chkDoorNoBlockMove, ref Prot.Door_NoBlockMove, ToUI);
                FOCommon.Utils.SetControl(numContainerVolume, ref Prot.Container_Volume, ToUI);
                FOCommon.Utils.SetControl(chkContainerChangable, ref Prot.Container_Changeble, ToUI);
                FOCommon.Utils.SetControl(chkContainerCannotPickup, ref Prot.Container_CannotPickUp, ToUI);
                FOCommon.Utils.SetControl(chkContainerMagicHandsGrnd, ref Prot.Container_MagicHandsGrnd, ToUI);

                FOCommon.Utils.SetControl(numCarSpeed, ref Prot.Car_Speed, ToUI);
                FOCommon.Utils.SetControl(numCarPassability, ref Prot.Car_Passability, ToUI);
                FOCommon.Utils.SetControl(numCarDeteriorationRate, ref Prot.Car_DeteriorationRate, ToUI);
                FOCommon.Utils.SetControl(numCarCritterCapacity, ref Prot.Car_CrittersCapacity, ToUI);
                FOCommon.Utils.SetControl(numCarTankVolume, ref Prot.Car_TankVolume, ToUI);
                FOCommon.Utils.SetControl(numCarMaxDeterioration, ref Prot.Car_MaxDeterioration, ToUI);
                FOCommon.Utils.SetControl(numCarFuelConsumption, ref Prot.Car_FuelConsumption, ToUI);
                FOCommon.Utils.SetControl(numCarEntrance, ref Prot.Car_Entrance, ToUI);

                // Parse flags
                FOCommon.Utils.SetControlFlag(chkColorFlagColorize, ref Prot.Flags, (uint)Data.Defines["ITEM_COLORIZE"], ToUI);
                FOCommon.Utils.SetControlFlag(chkColorFlagColorizeInventory, ref Prot.Flags, (uint)Data.Defines["ITEM_COLORIZE_INV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioEnabled, ref Prot.Flags, (uint)Data.Defines["ITEM_RADIO"], ToUI);

                FOCommon.Utils.SetControlFlag(chkHolodiskEnabled, ref Prot.Flags, (uint)Data.Defines["ITEM_HOLODISK"], ToUI);
                FOCommon.Utils.SetControlFlag(chkLight, ref Prot.Flags, (uint)Data.Defines["ITEM_LIGHT"], ToUI);
                FOCommon.Utils.SetControlFlag(chkShowAnim, ref Prot.Flags, (uint)Data.Defines["ITEM_SHOW_ANIM"], ToUI);
                FOCommon.Utils.SetControlFlag(chkShowAnimExt, ref Prot.Flags, (uint)Data.Defines["ITEM_SHOW_ANIM_EXT"], ToUI);

                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir0, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(0), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir1, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(1), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir2, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(2), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir3, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(3), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir4, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(4), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir5, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(5), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagGlobal, ref Prot.LightFlags, LIGHT_GLOBAL, ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagInverse, ref Prot.LightFlags, LIGHT_INVERSE, ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftBCSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_BC_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftBCRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_BC_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftChannel, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_CHANNEL"], ToUI);

                FOCommon.Utils.SetControl(grpCarMovementType, ref Prot.Car_MovementType, ToUI);
                FOCommon.Utils.SetControl(grpExtInfoMaterial, ref Prot.Material, ToUI);
                FOCommon.Utils.SetControl(grpExtInfoCorner, ref Prot.Corner, ToUI);
                FOCommon.Utils.SetControl(grpSpriteCutting, ref Prot.SpriteCut, ToUI);
                FOCommon.Utils.SetControl(grpGridType, ref Prot.Grid_Type, ToUI);

                // Multiline textbox
                if (ToUI)
                    txtDescription.Text = txtDescription.Text.Replace("\n", "\r\n");
                else
                    txtDescription.Text = txtDescription.Text.Replace("\r\n", "\n");
            }
            catch (ArgumentOutOfRangeException Arg)
            {
                Utils.Log(Prot.Name+"["+Prot.ProtoId+"]: "+ Arg.Message + "::" + Arg.Source);
            }
            #endregion

            // Custom flags from Flags.cfg
            foreach (CheckBox chkBox in grpExtInfoFlags.Controls)
            {
                string Define = (String)chkBox.Tag;
                FOCommon.Utils.SetControlFlag(chkBox, ref Prot.Flags, (uint)Data.Defines[Define], ToUI);
            }

            // For Custom.cfg stuff
            SetCustomData(ref Prot, ToUI);

            // Stuff that needs some special handling
            if (ToUI)
            {
                numColorAlpha.Value = (Prot.LightColor >> 24) & 0xFF;
                numColorRed.Value = (Prot.LightColor >> 16) & 0xFF;
                numColorGreen.Value = (Prot.LightColor >> 8) & 0xFF;
                numColorBlue.Value = (Prot.LightColor) & 0xFF;
                chkActive1.Checked = false;
                chkActive2.Checked = false;
                chkActive3.Checked = false;
                for (uint i = 0; i <= Prot.Weapon_ActiveUses; i++)
                {
                    if (i == 1) chkActive1.Checked = true;
                    if (i == 2) chkActive2.Checked = true;
                    if (i == 3) chkActive3.Checked = true;
                }
            }
            else
            {
                uint ActiveCount = 0;
                if (chkActive1.Checked) ActiveCount++;
                if (chkActive2.Checked) ActiveCount++;
                if (chkActive3.Checked) ActiveCount++;
                Prot.Weapon_ActiveUses = ActiveCount;
                Prot.LightColor = ((Int32)numColorAlpha.Value << 24) | ((Int32)numColorRed.Value << 16) | ((Int32)numColorGreen.Value << 8) | ((Int32)numColorBlue.Value);
            }
        }
Example #34
0
        void SetCustomTabPage(ref ItemProto Prot, TabPage Page, bool ToUI)
        {
            foreach (Control Ctrl in Page.Controls)
            {
                if (Ctrl is NumericUpDown)
                {
                    NumericUpDown Num = (NumericUpDown)Ctrl;
                    FieldObject FieldData;

                    FieldData = (FieldObject)Num.Tag;
                    if (FieldData == null)
                        continue;

                    if (ToUI)
                    {
                        Num.Value = 0;
                        if (Prot.CustomFields.ContainsKey(FieldData.CustomFieldName))
                        {
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is Decimal)
                                Num.Value = (decimal)Prot.CustomFields[FieldData.CustomFieldName].Value;
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is int)
                                Num.Value = (int)Prot.CustomFields[FieldData.CustomFieldName].Value;
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is uint)
                                Num.Value = (uint)Prot.CustomFields[FieldData.CustomFieldName].Value;
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is UInt16)
                                Num.Value = (UInt16)Prot.CustomFields[FieldData.CustomFieldName].Value;
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is Int16)
                                Num.Value = (Int16)Prot.CustomFields[FieldData.CustomFieldName].Value;
                            if (Prot.CustomFields[FieldData.CustomFieldName].Value is SByte)
                                Num.Value = (SByte)Prot.CustomFields[FieldData.CustomFieldName].Value;
                        }
                    }
                    else
                    {
                        if (Prot.CustomFields.ContainsKey(FieldData.CustomFieldName))
                            Prot.CustomFields[FieldData.CustomFieldName].Value = Num.Value;
                        if (Num.Value != 0 && !Prot.CustomFields.ContainsKey(FieldData.CustomFieldName))
                        {
                            ItemProtoCustomField NewField = new ItemProtoCustomField(FieldData.CustomFieldName, FOCommon.Utils.GetTypeFromString(FieldData.DataType));
                            NewField.Value = Num.Value;
                            Prot.CustomFields.Add(FieldData.CustomFieldName, NewField);
                        }
                    }
                }
                else if (Ctrl is CheckBox)
                {
                    CheckBox Chk = (CheckBox)Ctrl;
                    FieldObject FieldData;

                    FieldData = (FieldObject)Chk.Tag;
                    if (FieldData == null)
                        continue;

                    if (ToUI)
                    {
                        if (Prot.CustomFields.ContainsKey(FieldData.CustomFieldName) && Prot.CustomFields[FieldData.CustomFieldName].Value is bool)
                            Chk.Checked = (bool)Prot.CustomFields[FieldData.CustomFieldName].Value;
                        else
                            Chk.Checked = false;
                    }
                    else
                    {
                        if (Prot.CustomFields.ContainsKey(FieldData.CustomFieldName))
                            Prot.CustomFields[FieldData.CustomFieldName].Value = Chk.Checked;
                        if (Chk.Checked && !Prot.CustomFields.ContainsKey(FieldData.CustomFieldName))
                        {
                            ItemProtoCustomField NewField = new ItemProtoCustomField(FieldData.CustomFieldName, FOCommon.Utils.GetTypeFromString(FieldData.DataType));
                            NewField.Value = true;
                            Prot.CustomFields.Add(FieldData.CustomFieldName, NewField);
                        }
                    }
                }
            }
        }
Example #35
0
        void SetCustomData(ref ItemProto Prot, bool ToUI)
        {
            // Custom data, see Custom.cfg
            // Parse trough all pages in properties panels
            foreach (TabPage Page in panelProperties.TabPages)
            {
                TabControl SubControl = null;
                foreach (Control TopCtrl in Page.Controls)
                {
                    if (TopCtrl is TabControl)
                        SubControl = (TabControl)Page.Controls[0];
                }
                if (SubControl == null)
                    continue;

                foreach (TabPage SubPage in SubControl.TabPages)
                {
                    SetCustomTabPage(ref Prot, SubPage, ToUI);
                }
            }

            foreach (TabPage Page in panelMain.TabPages)
            {
                SetCustomTabPage(ref Prot, Page, ToUI);
            }
        }
Example #36
0
 private void removeSelectedObjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ArrayList Arr = (ArrayList)lstProtos.SelectedObjects;
     List<ItemProto> Prots = new List<ItemProto>((ItemProto[])Arr.ToArray(typeof(ItemProto)));
     foreach (ItemProto Prot in Prots)
     {
         if (CurrentProto!=null && CurrentProto.ProtoId == Prot.ProtoId)
         {
             CurrentProto = null;
             SetProtoGUI(new ItemProto(), true);
         }
         LoadedProtos.Remove(Prot);
     }
     lstProtos.SetObjects(LoadedProtos);
     lstProtos.SelectedObjects = null;
 }
Example #37
0
        private void unloadAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (LoadedFilenames.Count == 0 && LoadedProtos.Count == 0)
                return;

            if (DialogResult.No == Message.Show("Are you sure that you want to unload all loaded items?"+Environment.NewLine+"Any pending changes will be lost.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                return;

            lstProtos.ClearObjects();
            LoadedProtos.Clear();
            LoadedFilenames.Clear();
            CurrentProto = null;
            SetProtoGUI(new ItemProto(), true);
            changeStatus("Unloaded all items.");
        }
Example #38
0
        private bool TextInProto(ItemProto proto, string Text)
        {
            Text = Text.ToLower();

            if (olvName.IsVisible && proto.Name.ToLower().Contains(Text))
                return true;
            if (olvPID.IsVisible && proto.ProtoId.ToString().ToLower().Contains(Text))
                return true;
            if (olvScript.IsVisible && proto.ScriptModule!= null && proto.ScriptModule.ToLower().Contains(Text))
                return true;
            if (olvScriptFunc.IsVisible && proto.ScriptFunction != null && proto.ScriptFunction.ToLower().Contains(Text))
                return true;

            return false;
        }
Example #39
0
        private void ParseData(ref ItemProto Prot, bool CompatibilityMode, bool Load)
        {
            #region ParseData
            ParseLine("ProtoId", "", ref Prot.ProtoId, CompatibilityMode, Load);
            ParseLine("Type", "", ref Prot.Type, CompatibilityMode, Load);
            ParseLine("ScriptModule", "", ref Prot.ScriptModule, CompatibilityMode, Load);
            ParseLine("ScriptFunc", "", ref Prot.ScriptFunction, CompatibilityMode, Load);
            ParseLine("PicMap", "PicMapName", ref Prot.PicMap, CompatibilityMode, Load);
            ParseLine("PicInv", "PicInvName", ref Prot.PicInv, CompatibilityMode, Load);
            ParseLine("Corner", "", ref Prot.Corner, CompatibilityMode, Load);
            ParseLine("Flags", "", ref Prot.Flags, CompatibilityMode, Load);
            ParseLine("DisableEgg", "", ref Prot.DisableEgg, CompatibilityMode, Load);
            ParseLine("Stackable", "Weapon.NoWear", ref Prot.Stackable, CompatibilityMode, Load);
            ParseLine("Deteriorable", "", ref Prot.Deteriorable, CompatibilityMode, Load);
            ParseLine("GroundLevel", "", ref Prot.GroundLevel, CompatibilityMode, Load);

            ParseLine("Dir", "", ref Prot.Dir, CompatibilityMode, Load);
            ParseLine("Slot", "", ref Prot.Slot, CompatibilityMode, Load);
            ParseLine("Weight", "", ref Prot.Weight, CompatibilityMode, Load);
            ParseLine("Volume", "", ref Prot.Volume, CompatibilityMode, Load);
            ParseLine("SoundId", "", ref Prot.SoundId, CompatibilityMode, Load);
            ParseLine("Cost", "", ref Prot.Cost, CompatibilityMode, Load);
            ParseLine("StartCount", "Ammo.StartCount", ref Prot.StartCount, CompatibilityMode, Load);
            ParseLine("Material", "", ref Prot.Material, CompatibilityMode, Load);
            ParseLine("LightFlags", "", ref Prot.LightFlags, CompatibilityMode, Load);
            ParseLine("LightDistance", "", ref Prot.LightDistance, CompatibilityMode, Load);
            ParseLine("LightIntensity", "", ref Prot.LightIntensity, CompatibilityMode, Load);
            ParseLine("LightColor", "", ref Prot.LightColor, CompatibilityMode, Load);
            ParseLine("AnimWaitBase", "", ref Prot.AnimWaitBase, CompatibilityMode, Load);
            ParseLine("AnimWaitRndMin", "", ref Prot.AnimWaitRndMin, CompatibilityMode, Load);
            ParseLine("AnimWaitRndMax", "", ref Prot.AnimWaitRndMax, CompatibilityMode, Load);
            ParseLine("AnimStay_0", "", ref Prot.AnimStay_0, CompatibilityMode, Load);
            ParseLine("AnimStay_1", "", ref Prot.AnimStay_1, CompatibilityMode, Load);
            ParseLine("AnimShow_0", "", ref Prot.AnimShow_0, CompatibilityMode, Load);
            ParseLine("AnimShow_1", "", ref Prot.AnimShow_1, CompatibilityMode, Load);
            ParseLine("AnimHide_0", "", ref Prot.AnimHide_0, CompatibilityMode, Load);
            ParseLine("AnimHide_1", "", ref Prot.AnimHide_1, CompatibilityMode, Load);
            ParseLine("OffsetX", "", ref Prot.OffsetX, CompatibilityMode, Load);
            ParseLine("OffsetY", "", ref Prot.OffsetY, CompatibilityMode, Load);
            ParseLine("SpriteCut", "", ref Prot.SpriteCut, CompatibilityMode, Load);
            ParseLine("DrawOrderOffsetHexY", "", ref Prot.DrawOrderOffsetHexY, CompatibilityMode, Load);
            ParseLine("RadioChannel", "", ref Prot.RadioChannel, CompatibilityMode, Load);
            ParseLine("RadioFlags", "", ref Prot.RadioFlags, CompatibilityMode, Load);
            ParseLine("RadioBroadcastSend", "", ref Prot.RadioBroadcastSend, CompatibilityMode, Load);
            ParseLine("RadioBroadcastRecv", "", ref Prot.RadioBroadcastRecv, CompatibilityMode, Load);
            ParseLine("IndicatorStart", "", ref Prot.IndicatorStart, CompatibilityMode, Load);
            ParseLine("IndicatorMax", "", ref Prot.IndicatorMax, CompatibilityMode, Load);
            ParseLine("HolodiskNum", "", ref Prot.HolodiskNum, CompatibilityMode, Load);
            ParseLine("Weapon_IsUnarmed", "Weapon.IsUnarmed", ref Prot.Weapon_IsUnarmed, CompatibilityMode, Load);
            ParseLine("Weapon_UnarmedTree", "Weapon.UnarmedTree", ref Prot.Weapon_UnarmedTree, CompatibilityMode, Load);
            ParseLine("Weapon_UnarmedPriority", "Weapon.UnarmedPriority", ref Prot.Weapon_UnarmedPriority, CompatibilityMode, Load);
            ParseLine("Weapon_UnarmedMinAgility", "Weapon.UnarmedMinAgility", ref Prot.Weapon_UnarmedMinAgility, CompatibilityMode, Load);
            ParseLine("Weapon_UnarmedMinUnarmed", "Weapon.UnarmedMinUnarmed", ref Prot.Weapon_UnarmedMinUnarmed, CompatibilityMode, Load);
            ParseLine("Weapon_UnarmedMinLevel", "Weapon.UnarmedMinLevel", ref Prot.Weapon_UnarmedMinLevel, CompatibilityMode, Load);
            ParseLine("Weapon_Anim1", "Weapon.Anim1", ref Prot.Weapon_Anim1, CompatibilityMode, Load);
            ParseLine("Weapon_MaxAmmoCount", "Weapon.VolHolder", ref Prot.Weapon_MaxAmmoCount, CompatibilityMode, Load);
            ParseLine("Weapon_Caliber", "Weapon.Caliber", ref Prot.Weapon_Caliber, CompatibilityMode, Load);
            ParseLine("Weapon_DefaultAmmoPid", "Weapon.DefAmmo", ref Prot.Weapon_DefaultAmmoPid, CompatibilityMode, Load);
            ParseLine("Weapon_MinStrength", "Weapon.MinSt", ref Prot.Weapon_MinStrength, CompatibilityMode, Load);
            ParseLine("Weapon_Perk", "Weapon.Perk", ref Prot.Weapon_Perk, CompatibilityMode, Load);
            ParseLine("Weapon_ActiveUses", "Weapon.CountAttack", ref Prot.Weapon_ActiveUses, CompatibilityMode, Load);
            ParseLine("Weapon_CriticalFailture", "Weapon.CrFailture", ref Prot.Weapon_CriticalFailture, CompatibilityMode, Load);
            ParseLine("Weapon_Skill_0", "Weapon.Skill_0", ref Prot.Weapon_Skill_0, CompatibilityMode, Load);
            ParseLine("Weapon_Skill_1", "Weapon.Skill_1", ref Prot.Weapon_Skill_1, CompatibilityMode, Load);
            ParseLine("Weapon_Skill_2", "Weapon.Skill_2", ref Prot.Weapon_Skill_2, CompatibilityMode, Load);
            ParseLine("Weapon_DmgType_0", "Weapon.DmgType_0", ref Prot.Weapon_DmgType_0, CompatibilityMode, Load);
            ParseLine("Weapon_DmgType_1", "Weapon.DmgType_1", ref Prot.Weapon_DmgType_1, CompatibilityMode, Load);
            ParseLine("Weapon_DmgType_2", "Weapon.DmgType_2", ref Prot.Weapon_DmgType_2, CompatibilityMode, Load);
            ParseLine("Weapon_Anim2_0", "Weapon.Anim2_0", ref Prot.Weapon_Anim2_0, CompatibilityMode, Load);
            ParseLine("Weapon_Anim2_1", "Weapon.Anim2_1", ref Prot.Weapon_Anim2_1, CompatibilityMode, Load);
            ParseLine("Weapon_Anim2_2", "Weapon.Anim2_2", ref Prot.Weapon_Anim2_2, CompatibilityMode, Load);
            ParseLine("Weapon_Remove_0", "Weapon.Remove_0", ref Prot.Weapon_Remove_0, CompatibilityMode, Load);
            ParseLine("Weapon_Remove_1", "Weapon.Remove_1", ref Prot.Weapon_Remove_1, CompatibilityMode, Load);
            ParseLine("Weapon_Remove_2", "Weapon.Remove_2", ref Prot.Weapon_Remove_2, CompatibilityMode, Load);
            ParseLine("Weapon_PicUse_0", "Weapon.PicName_0", ref Prot.Weapon_PicUse_0, CompatibilityMode, Load);
            ParseLine("Weapon_PicUse_1", "Weapon.PicName_1", ref Prot.Weapon_PicUse_1, CompatibilityMode, Load);
            ParseLine("Weapon_PicUse_2", "Weapon.PicName_2", ref Prot.Weapon_PicUse_2, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMin_0", "Weapon.DmgMin_0", ref Prot.Weapon_DmgMin_0, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMin_1", "Weapon.DmgMin_1", ref Prot.Weapon_DmgMin_1, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMin_2", "Weapon.DmgMin_2", ref Prot.Weapon_DmgMin_2, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMax_0", "Weapon.DmgMax_0", ref Prot.Weapon_DmgMax_0, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMax_1", "Weapon.DmgMax_1", ref Prot.Weapon_DmgMax_1, CompatibilityMode, Load);
            ParseLine("Weapon_DmgMax_2", "Weapon.DmgMax_2", ref Prot.Weapon_DmgMax_2, CompatibilityMode, Load);
            ParseLine("Weapon_Effect_0", "Weapon.Effect_0", ref Prot.Weapon_FlyEffect_0, CompatibilityMode, Load);
            ParseLine("Weapon_Effect_1", "Weapon.Effect_1", ref Prot.Weapon_FlyEffect_1, CompatibilityMode, Load);
            ParseLine("Weapon_Effect_2", "Weapon.Effect_2", ref Prot.Weapon_FlyEffect_2, CompatibilityMode, Load);
            ParseLine("Weapon_MaxDist_0", "Weapon.MaxDist_0", ref Prot.Weapon_MaxDist_0, CompatibilityMode, Load);
            ParseLine("Weapon_MaxDist_1", "Weapon.MaxDist_1", ref Prot.Weapon_MaxDist_1, CompatibilityMode, Load);
            ParseLine("Weapon_MaxDist_2", "Weapon.MaxDist_2", ref Prot.Weapon_MaxDist_2, CompatibilityMode, Load);
            ParseLine("Weapon_Round_0", "Weapon.Round_0", ref Prot.Weapon_Round_0, CompatibilityMode, Load);
            ParseLine("Weapon_Round_1", "Weapon.Round_1", ref Prot.Weapon_Round_1, CompatibilityMode, Load);
            ParseLine("Weapon_Round_2", "Weapon.Round_2", ref Prot.Weapon_Round_2, CompatibilityMode, Load);
            ParseLine("Weapon_ApCost_0", "Weapon.Time_0", ref Prot.Weapon_ApCost_0, CompatibilityMode, Load);
            ParseLine("Weapon_ApCost_1", "Weapon.Time_1", ref Prot.Weapon_ApCost_1, CompatibilityMode, Load);
            ParseLine("Weapon_ApCost_2", "Weapon.Time_2", ref Prot.Weapon_ApCost_2, CompatibilityMode, Load);
            ParseLine("Weapon_Aim_0", "Weapon.Aim_0", ref Prot.Weapon_Aim_0, CompatibilityMode, Load);
            ParseLine("Weapon_Aim_1", "Weapon.Aim_1", ref Prot.Weapon_Aim_1, CompatibilityMode, Load);
            ParseLine("Weapon_Aim_2", "Weapon.Aim_2", ref Prot.Weapon_Aim_2, CompatibilityMode, Load);
            ParseLine("Weapon_SoundId_0", "Weapon.SoundId_0", ref Prot.Weapon_SoundId_0, CompatibilityMode, Load);
            ParseLine("Weapon_SoundId_1", "Weapon.SoundId_1", ref Prot.Weapon_SoundId_1, CompatibilityMode, Load);
            ParseLine("Weapon_SoundId_2", "Weapon.SoundId_2", ref Prot.Weapon_SoundId_2, CompatibilityMode, Load);
            ParseLine("Ammo_Caliber", "Ammo.Caliber", ref Prot.Ammo_Caliber, CompatibilityMode, Load);
            ParseLine("Ammo_AcMod", "Ammo.ACMod", ref Prot.Ammo_AcMod, CompatibilityMode, Load);
            ParseLine("Ammo_DrMod", "Ammo.DRMod", ref Prot.Ammo_DrMod, CompatibilityMode, Load);
            ParseLine("Door_NoBlockMove", "Door.NoBlockMove", ref Prot.Door_NoBlockMove, CompatibilityMode, Load);
            ParseLine("Door_NoBlockShoot", "Door.NoBlockShoot", ref Prot.Door_NoBlockShoot, CompatibilityMode, Load);
            ParseLine("Door_NoBlockLight", "Door.NoBlockLight", ref Prot.Door_NoBlockLight, CompatibilityMode, Load);
            ParseLine("Container_Volume", "Container.ContVolume", ref Prot.Container_Volume, CompatibilityMode, Load);
            ParseLine("Container_Changeble", "Container.Changeble", ref Prot.Container_Changeble, CompatibilityMode, Load);
            ParseLine("Container_CannotPickUp", "Container.CannotPickUp", ref Prot.Container_CannotPickUp, CompatibilityMode, Load);
            ParseLine("Container_MagicHandsGrnd", "Container.MagicHandsGrnd", ref Prot.Container_MagicHandsGrnd, CompatibilityMode, Load);
            ParseLine("Locker_Condition", "Locker.Condition", ref Prot.Locker_Condition, CompatibilityMode, Load);
            ParseLine("Grid_Type", "Grid.Type", ref Prot.Grid_Type, CompatibilityMode, Load);
            ParseLine("Armor_CrTypeMale", "Armor.Anim0Male", ref Prot.Armor_CrTypeMale, CompatibilityMode, Load);
            ParseLine("Armor_CrTypeFemale", "Armor.Anim0Female", ref Prot.Armor_CrTypeFemale, CompatibilityMode, Load);
            ParseLine("ChildLines_0", "MiscEx.Car.Bag_0", ref Prot.ChildLines[0], CompatibilityMode, Load);
            ParseLine("ChildLines_1", "MiscEx.Car.Bag_1", ref Prot.ChildLines[1], CompatibilityMode, Load);
            ParseLine("ChildLines_2", "", ref Prot.ChildLines[2], CompatibilityMode, Load);
            ParseLine("ChildLines_3", "", ref Prot.ChildLines[3], CompatibilityMode, Load);
            ParseLine("ChildLines_4", "", ref Prot.ChildLines[4], CompatibilityMode, Load);
            ParseLine("BlockLines", "MiscEx.Car.Blocks", ref Prot.BlockLines, CompatibilityMode, Load);

            for (uint i = 0; i < Prot.ChildPid.Length; i++)
                ParseLine("ChildPid_" + i, "" + i, ref Prot.ChildPid[i], CompatibilityMode, Load);

            for (uint k = 1; k <= Prot.StartValue.Length; k++)
                ParseLine("StartValue_" + k, "MiscEx.StartVal" + k, ref Prot.StartValue[k-1], CompatibilityMode, Load);

            ParseLine("Car_Speed", "MiscEx.Car.Speed", ref Prot.Car_Speed, CompatibilityMode, Load);
            ParseLine("Car_Passability", "MiscEx.Car.Negotiability", ref Prot.Car_Passability, CompatibilityMode, Load);
            ParseLine("Car_DeteriorationRate", "MiscEx.Car.WearConsumption", ref Prot.Car_DeteriorationRate, CompatibilityMode, Load);
            ParseLine("Car_CrittersCapacity", "MiscEx.Car.CritCapacity", ref Prot.Car_CrittersCapacity, CompatibilityMode, Load);
            ParseLine("Car_TankVolume", "MiscEx.Car.FuelTank", ref Prot.Car_TankVolume, CompatibilityMode, Load);
            ParseLine("Car_MaxDeterioration", "MiscEx.Car.RunToBreak", ref Prot.Car_MaxDeterioration, CompatibilityMode, Load);
            ParseLine("Car_Entrance", "MiscEx.Car.Entire", ref Prot.Car_Entrance, CompatibilityMode, Load);
            ParseLine("Car_FuelConsumption", "MiscEx.Car.FuelConsumption", ref Prot.Car_FuelConsumption, CompatibilityMode, Load);
            ParseLine("Car_MovementType", "MiscEx.Car.WalkType", ref Prot.Car_MovementType, CompatibilityMode, Load);
            #endregion
        }
Example #40
0
 private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ItemProto NewProt = new ItemProto();
     NewProt.New = true;
     LoadedProtos.Add(NewProt);
     lstProtos.AddObject(NewProt);
     SetNewProto(NewProt);
 }
Example #41
0
 // Convert from 2.14.3
 private void ConvertStuff(ref ItemProto Prot, bool IsCar, bool IsNoOpen)
 {
     if (IsCar)
     {
         Prot.Type = (int)ItemTypes.ITEM_CAR;
         Prot.ChildPid[0] = (ushort)Prot.StartValue[0];
         Prot.ChildPid[1] = (ushort)Prot.StartValue[1];
         Prot.ChildPid[2] = (ushort)Prot.StartValue[2];
         Prot.ChildPid[3] = (ushort)Prot.StartValue[3];
     }
     if (Prot.Type == (int)ItemTypes.ITEM_AMMO ||
         Prot.Type == (int)ItemTypes.ITEM_DRUG ||
         Prot.Type == (int)ItemTypes.ITEM_MISC) Prot.Stackable = true;
     if (Prot.Type == (int)ItemTypes.ITEM_WEAPON) if (!Prot.Stackable) Prot.Deteriorable = true;
     if (Prot.Type == (int)ItemTypes.ITEM_ARMOR) Prot.Deteriorable = true;
     if (Prot.Type == (int)ItemTypes.ITEM_MISC_EX) Prot.Type = (int)ItemTypes.ITEM_MISC;
     if (Prot.Type == (int)ItemTypes.ITEM_CONTAINER) Prot.GroundLevel = Prot.Container_MagicHandsGrnd;
     if (Prot.Weapon_IsUnarmed)
     {
         Prot.Stackable = false;
         Prot.Deteriorable = false;
     }
     if (IsNoOpen) Prot.Locker_Condition = (ushort)(Prot.Locker_Condition | 0x10); // LOCKER_NOOPEN
     for (uint i = 0; i < Prot.ChildLines.Length; i++)
         Prot.ChildLines[i] = ConvertLines(Prot.ChildLines[i]);
 }
Example #42
0
        // TODO: Refactor
        public bool Load(string FilePath, string Version, List<String> Lines, MSGParser FOObj, Dictionary<String, ItemProtoCustomField> CustomFields)
        {
            ItemProto Prot = null;
            bool CompatibilityMode = false;
            bool DuplicateFound = false;

            List<int> ProcessedPids = new List<int>();

            foreach (ItemProto LProt in _loadedProtos)
                ProcessedPids.Add(LProt.ProtoId);

            bool IsCar = false; // Compatibility
            bool IsNoOpen = false; // Compatibility

            int j = Lines.Count;
            for(int i=0;i<j;i++)// String Line in Lines)
            {
                    String Line = Lines[i];
                    if (Line == "[Proto]"||i==Lines.Count-1)
                    {

                        if (Prot != null)
                        {

                            if (FOObj != null)
                            {
                                Prot.Name = FOObj.GetMSGValue(Prot.ProtoId * 100);
                                Prot.Description = FOObj.GetMSGValue(Prot.ProtoId * 100 + 1);
                            }
                            //Prot.FileName = Path.GetFileName(FilePath);
                            Prot.FileName = FilePath;
                            if (CompatibilityMode)
                            {
                                ConvertStuff(ref Prot, IsCar, IsNoOpen);
                                CompatibilityMode = false;
                            }
                            IsCar = false;
                            IsNoOpen = false;

                            if (ProcessedPids.Contains(Prot.ProtoId))
                            {
                                DuplicateFound = true;
                                Utils.Log("An object with the ProtoId " + Prot.ProtoId + " was already loaded. Overwriting proto.");
                                for (ushort u = 0; u < _loadedProtos.Count; u++)
                                    if (_loadedProtos[u].ProtoId == Prot.ProtoId)
                                        _loadedProtos[u] = Prot;
                            }
                            else
                            {
                                if(Prot.ProtoId!=0)
                                    _loadedProtos.Add(Prot);
                            }

                            ProcessedPids.Add(Prot.ProtoId);
                        }
                        Prot = new ItemProto();
                        continue;
                    }

                    if (string.IsNullOrEmpty(Lines[i]) || (Lines[i].Length>0 && Lines[i][0]=='#'))
                        continue;

                    if (FOObj != null && Prot!=null)
                    {
                        Prot.Name = FOObj.GetMSGValue(Prot.ProtoId * 100);
                        Prot.Description = FOObj.GetMSGValue(Prot.ProtoId * 100 + 1);
                    }

                    String[] Parts = Line.Split('=');
                    if (Parts.Length != 2)
                        continue;
                    _fieldName = Parts[0].Trim();
                    _fieldValue = Parts[1].TrimStart(' ','\t');

                    if (Prot == null) continue;

                    if (_fieldName == "Pid") { Prot.ProtoId = ushort.Parse(_fieldValue); CompatibilityMode = true; }
                    if (_fieldName == "MiscEx.IsCar") IsCar=true;
                    if (_fieldName == "Container.IsNoOpen") IsNoOpen = true;

                    if(Prot!=null)
                        ParseData(ref Prot, CompatibilityMode, true);

                    if (CustomFields == null)
                        continue;
                foreach (KeyValuePair<String, ItemProtoCustomField> kvp in CustomFields)
                {
                    if (_fieldName == kvp.Key || _fieldName.Replace('.', '_') == kvp.Key)
                    {
                        try
                        {
                            ItemProtoCustomField NewCustom = new ItemProtoCustomField(kvp.Key,
                                                                                      (Utils.DataType)
                                                                                      kvp.Value.Type);
                            if (NewCustom.Type == (Byte)Utils.DataType.BOOL)
                                NewCustom.Value = (_fieldValue == "1");
                            else if (NewCustom.Type == (Byte)Utils.DataType.SBYTE)
                                NewCustom.Value = SByte.Parse(_fieldValue);
                            else if (NewCustom.Type == (Byte)Utils.DataType.INT)
                                NewCustom.Value = Int32.Parse(_fieldValue);
                            else if (NewCustom.Type == (Byte)Utils.DataType.INT16)
                                NewCustom.Value = Int16.Parse(_fieldValue);
                            else if (NewCustom.Type == (Byte)Utils.DataType.UINT)
                                NewCustom.Value = UInt32.Parse(_fieldValue);
                            else if (NewCustom.Type == (Byte)Utils.DataType.UINT16)
                                NewCustom.Value = UInt16.Parse(_fieldValue);
                            Prot.CustomFields.Add(kvp.Key, NewCustom);
                        }
                        catch (OverflowException ex)
                        {
                            Utils.Log(ex.Message + " in ProtoId " + Prot.ProtoId + " ,field " + _fieldName +
                                      " value: " + _fieldValue);
                        }
                    }
                }
            }
                return DuplicateFound;
        }