Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 6ba6ac5

Browse files
committed
added maximum capacity on material display
thanks to https://github.com/msarilar/EDEngineer
1 parent 6528812 commit 6ba6ac5

30 files changed

+42981
-13
lines changed

EDEngineer/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Runtime.CompilerServices;
6+
using System.Text;
7+
using EDEngineer.Models.Utils;
8+
using Newtonsoft.Json;
9+
10+
namespace EDEngineer.Models
11+
{
12+
public class Blueprint
13+
{
14+
private static readonly Dictionary<string, string> technicalTypes = new Dictionary<string, string>
15+
{
16+
["Frame Shift Drive"] = "hyperdrive",
17+
["Heat Sink Launcher"] = "heatsinklauncher",
18+
["Collector Limpet Controller"] = "dronecontrol_collection",
19+
["Prospector Limpet Controller"] = "dronecontrol_prospector",
20+
["Fuel Transfer Limpet Controller"] = "dronecontrol_fuel",
21+
["Hatch Breaker Limpet Controller"] = "dronecontrol_resourcesiphon",
22+
["Thrusters"] = "engine",
23+
["Pulse Laser"] = "pulselaser",
24+
["Beam Laser"] = "beamlaser",
25+
["Shield Booster"] = "shieldbooster",
26+
["Shield Generator"] = "shieldgenerator",
27+
["Sensors"] = "sensors",
28+
["Plasma Accelerator"] = "plasmaaccelerator",
29+
["Life Support"] = "lifesupport",
30+
["Hull Reinforcement Package"] = "hullreinforcement",
31+
["Power Distributor"] = "powerdistributor",
32+
["Power Plant"] = "powerplant",
33+
["Multi-cannon"] = "multicannon",
34+
["Kill Warrant Scanner"] = "crimescanner",
35+
["Rail Gun"] = "railgun",
36+
["Burst Laser"] = "pulselaserburst"
37+
};
38+
39+
public string Type { get; }
40+
41+
[JsonIgnore]
42+
public string TechnicalType => technicalTypes.TryGetValue(Type, out var result) ? result : Type;
43+
44+
public string ShortenedType
45+
{
46+
get
47+
{
48+
switch (Type)
49+
{
50+
case "Electronic Countermeasure":
51+
return "ECM";
52+
case "Hull Reinforcement Package":
53+
return "Hull";
54+
case "Frame Shift Drive Interdictor":
55+
return "FSD Interdictor";
56+
case "Prospector Limpet Controller":
57+
return "Prospector LC";
58+
case "Fuel Transfer Limpet Controller":
59+
return "Fuel Transfer LC";
60+
case "Hatch Breaker Limpet Controller":
61+
return "Hatch Breaker LC";
62+
case "Collector Limpet Controller":
63+
return "Collector LC";
64+
case "Auto Field-Maintenance Unit":
65+
return "AFMU";
66+
default:
67+
return Type;
68+
}
69+
}
70+
}
71+
public string BlueprintName { get; }
72+
public IReadOnlyCollection<string> Engineers { get; }
73+
public IReadOnlyCollection<BlueprintIngredient> Ingredients { get; }
74+
public int? Grade { get; }
75+
public IReadOnlyCollection<BlueprintEffect> Effects { get; }
76+
public Guid? CoriolisGuid { get; set; }
77+
78+
79+
[JsonIgnore]
80+
public BlueprintCategory Category
81+
{
82+
get
83+
{
84+
if (Engineers.FirstOrDefault() == "@Synthesis")
85+
{
86+
return BlueprintCategory.Synthesis;
87+
}
88+
89+
if (Type == "Unlock")
90+
{
91+
return BlueprintCategory.Unlock;
92+
}
93+
94+
if (Engineers.FirstOrDefault() == "@Technology")
95+
{
96+
return BlueprintCategory.Technology;
97+
}
98+
99+
if (Grade == null)
100+
{
101+
return BlueprintCategory.Experimental;
102+
}
103+
104+
return BlueprintCategory.Module;
105+
}
106+
}
107+
108+
public Blueprint(
109+
string type,
110+
string blueprintName,
111+
int? grade,
112+
IReadOnlyCollection<BlueprintIngredient> ingredients,
113+
IReadOnlyCollection<string> engineers,
114+
IReadOnlyCollection<BlueprintEffect> effects,
115+
Guid? coriolisGuid)
116+
{
117+
Type = type;
118+
BlueprintName = blueprintName;
119+
Grade = grade;
120+
Engineers = engineers;
121+
Ingredients = ingredients;
122+
Effects = effects;
123+
CoriolisGuid = coriolisGuid;
124+
125+
}
126+
127+
private int ComputeCraftCount(Func<BlueprintIngredient, int> countExtractor)
128+
{
129+
return Ingredients.Any() ? Ingredients.Min(i => countExtractor(i)/i.Size) : 0;
130+
}
131+
132+
private double ComputeProgress(Func<BlueprintIngredient, int> countExtractor)
133+
{
134+
return Ingredients.Sum(
135+
ingredient =>
136+
Math.Min(1, countExtractor(ingredient)/(double) ingredient.Size)/Ingredients.Count)*100;
137+
}
138+
139+
public override string ToString()
140+
{
141+
return $"G{Grade} [{Type}] {BlueprintName}";
142+
}
143+
144+
public string GradeString => Grade != null ? $"G{Grade}" : "🔹";
145+
146+
private string Prefix
147+
{
148+
get
149+
{
150+
switch (Category)
151+
{
152+
case BlueprintCategory.Synthesis:
153+
return $"SYN ";
154+
case BlueprintCategory.Experimental:
155+
return $"EXP ";
156+
case BlueprintCategory.Technology:
157+
return $"TEC ";
158+
case BlueprintCategory.Unlock:
159+
return $"ULK ";
160+
default:
161+
return $"";
162+
}
163+
}
164+
}
165+
166+
167+
public object ToSerializable()
168+
{
169+
return new
170+
{
171+
BlueprintName,
172+
Type,
173+
Grade
174+
};
175+
}
176+
177+
public bool HasSameIngredients(IReadOnlyCollection<BlueprintIngredient> ingredients)
178+
{
179+
return ingredients.Count == Ingredients.Count && ingredients.All(Ingredients.Contains);
180+
}
181+
}
182+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace EDEngineer.Models
2+
{
3+
public enum BlueprintCategory
4+
{
5+
Module,
6+
Synthesis,
7+
Experimental,
8+
Technology,
9+
Unlock
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace EDEngineer.Models
2+
{
3+
public class BlueprintEffect
4+
{
5+
public BlueprintEffect(string property, string effect, bool isGood)
6+
{
7+
Property = property;
8+
Effect = effect;
9+
IsGood = isGood;
10+
}
11+
12+
public string Property { get; }
13+
public string Effect { get; }
14+
public bool IsGood { get; }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.ComponentModel;
2+
using System.Runtime.CompilerServices;
3+
using Newtonsoft.Json;
4+
5+
namespace EDEngineer.Models
6+
{
7+
public class BlueprintIngredient
8+
{
9+
public EntryData EntryData { get; }
10+
11+
public BlueprintIngredient(EntryData entryData, int size)
12+
{
13+
EntryData = entryData;
14+
Size = size;
15+
}
16+
17+
public int Size { get; }
18+
19+
protected bool Equals(BlueprintIngredient other)
20+
{
21+
return Equals(EntryData, other.EntryData) && Size == other.Size;
22+
}
23+
24+
public override bool Equals(object obj)
25+
{
26+
if (ReferenceEquals(null, obj)) return false;
27+
if (ReferenceEquals(this, obj)) return true;
28+
if (obj.GetType() != this.GetType()) return false;
29+
return Equals((BlueprintIngredient)obj);
30+
}
31+
32+
public override int GetHashCode()
33+
{
34+
unchecked
35+
{
36+
return ((EntryData != null ? EntryData.GetHashCode() : 0) * 397) ^ Size;
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)