Skip to content

Commit

Permalink
Hat FPF checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kaosnyrb committed Dec 12, 2023
1 parent 3671522 commit 23ad50a
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 8 deletions.
102 changes: 95 additions & 7 deletions Armory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,19 @@ public static void LoadClothes(List<string> mods)
{
try
{
//-------------------------------------------
// Armor
//-------------------------------------------
var armours = mod.Value.Mod.Armors.ToList();
StarArmory.log.Info("Loading Mod: " + mod.Value.FileName);
foreach (var armor in armours)
{
bool added = false;
bool Keyword = false;
var link = immutableLoadOrderLinkCache.Resolve<IArmorGetter>(armor.FormKey);
//-------------------------------------------
// Clothing
//-------------------------------------------
if (armor.HasKeyword(Apparel))
{
StarArmory.log.Info("Processing Armor: " + armor.EditorID + " flags " + armor.FirstPersonFlags.Value);
Expand All @@ -100,13 +106,10 @@ public static void LoadClothes(List<string> mods)
}
Keyword = true;
}
if (armor.HasKeyword(Head))
{
hats.Add(link);
added = true;
Keyword = true;
itemsAdded++;
}

//-------------------------------------------
// Spacesuits
//-------------------------------------------
if (armor.HasKeyword(spacesuit))
{
//Check that it actually is a spacesuit.
Expand All @@ -118,6 +121,10 @@ public static void LoadClothes(List<string> mods)
}
Keyword = true;
}

//-------------------------------------------
// Space Helmets
//-------------------------------------------
if (armor.HasKeyword(spacehelmet))
{
//Check that it actually is a helmet
Expand All @@ -131,6 +138,10 @@ public static void LoadClothes(List<string> mods)
}
Keyword = true;
}

//-------------------------------------------
// Boostpacks
//-------------------------------------------
if (armor.HasKeyword(boostpack))
{
boostpacks.Add(link);
Expand All @@ -149,6 +160,9 @@ public static void LoadClothes(List<string> mods)
StarArmory.log.Info("Exception in Armor Processing in Mod: " + mod.Value.FileName);
StarArmory.log.Info("Exception: " + ex);
}
//-------------------------------------------
// Weapons
//-------------------------------------------
try
{
FormKey weapon_ranged = new FormKey(env.LoadOrder[0].ModKey, 177940);//WeaponTypeRanged [KYWD:0002B714]
Expand All @@ -160,18 +174,27 @@ public static void LoadClothes(List<string> mods)
{
bool added = false;
var link = immutableLoadOrderLinkCache.Resolve<IWeaponGetter>(weapon.FormKey);
//-------------------------------------------
// Ranged Weapons
//-------------------------------------------
if (weapon.HasKeyword(weapon_ranged))
{
ranged_weapons.Add(link);
added = true;
itemsAdded++;
}
//-------------------------------------------
// Melee Weapons
//-------------------------------------------
if (weapon.HasKeyword(weapon_melee))
{
melee_weapons.Add(link);
added = true;
itemsAdded++;
}
//-------------------------------------------
// Grenades
//-------------------------------------------
if (weapon.HasKeyword(grenade))
{
grenades.Add(link);
Expand All @@ -189,11 +212,76 @@ public static void LoadClothes(List<string> mods)
StarArmory.log.Info("Exception in Weapon Processing in Mod: " + mod.Value.FileName);
StarArmory.log.Info("Exception: " + ex);
}

//-------------------------------------------
// Aid/Food
//-------------------------------------------
//todo

//-------------------------------------------
// Misc
//-------------------------------------------
//todo

//-------------------------------------------
// Resources
//-------------------------------------------
//todo

StarArmory.log.Info("Finished procressing Mod: " + mod.Value.FileName);
StarArmory.log.Info(mod.Value.FileName + " contained " + itemsAdded + " valid items");
}
}

//-------------------------------------------
// Hats
//-------------------------------------------
//We don't want to add hats that clash with the clothes, so we process clothes first then hats.
foreach (var mod in env.LoadOrder)
{
if (!mods.Contains(mod.Value.FileName))
{
continue;
}
if (mod.Value.Mod != null)
{
try
{
var armours = mod.Value.Mod.Armors.ToList();
StarArmory.log.Info("Loading Mod: " + mod.Value.FileName);
foreach (var armor in armours)
{
var link = immutableLoadOrderLinkCache.Resolve<IArmorGetter>(armor.FormKey);
if (armor.HasKeyword(Head))
{
bool clashing = false;
foreach (var flag in ClothesFPF)
{
if (hasflag(armor.FirstPersonFlags.Value, flag.Key))
{
clashing = true;
StarArmory.log.Info("Clashing FPF: " + armor.EditorID + " flag " + flag.Key.ToString() + " was used in " + flag.Value);
}
}
if (!clashing)
{
hats.Add(link);
itemsAdded++;
}
}
}
}
catch (Exception ex)
{
StarArmory.log.Info("Exception in Armor Processing in Mod: " + mod.Value.FileName);
StarArmory.log.Info("Exception: " + ex);
}
}
}

//-------------------------------------------
// Accessories
//-------------------------------------------
//Some clothes didn't pass the first run. Here we try and add what we can to hats
foreach (var clothing in Leftovers)
{
Expand Down
7 changes: 6 additions & 1 deletion Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void UpdatePlan()
{
originalfaction = originalfaction.Substring(0, originalfaction.IndexOf(" - Male Only"));
}
// Armory.plans[i].faction = Armory.factions[originalfaction];
Armory.plans[i].faction = YamlImporter.getObjectFromYaml<Faction>(YamlExporter.BuildYaml(Armory.factions[originalfaction]));
Armory.plans[i].faction.Name = gendered;
factionPlanTree.Nodes[0].Nodes[i].Nodes.Add("Clear Vanilla: " + Armory.plans[i].clearvanillaitems.ToString());
for (int j = 0; j < Armory.plans[i].mods.Count; j++)
Expand Down Expand Up @@ -187,6 +187,11 @@ private void AddToPlanButton(object sender, EventArgs e)
{
try
{
if (FactionList.SelectedItem == null)
{
log.Error("FactionList.SelectedItem == null");
throw new Exception("FactionList SelectedItem is null! Not sure how.");
}
var factionplan = new FactionPlan
{
faction = YamlImporter.getObjectFromYaml<Faction>(YamlExporter.BuildYaml(Armory.factions[FactionList.SelectedItem.ToString()])), //Yeah, looks stupid but it creates a clone.
Expand Down

0 comments on commit 23ad50a

Please sign in to comment.