Skip to content

Commit

Permalink
helicopterbox redesign: spawn checkbox and sneak/caution routes
Browse files Browse the repository at this point in the history
  • Loading branch information
folly-ah-duh committed Jul 24, 2019
1 parent 5f1bea9 commit 83a214b
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ function this.TallyGenericTargets(totalTargets, objectiveCompleteCount, objectiv
local targetMessageId = targetInfo.messageId
if isTarget == true then
for _, ObjectiveTypeInfo in ipairs(ObjectiveTypeList.genericTargets) do
if ObjectiveTypeInfo.Check(targetGameId) then
dynamicQuestType = ObjectiveTypeInfo.Type
break
if ObjectiveTypeList.genericTargets ~= nil then
for _, ObjectiveTypeInfo in ipairs(ObjectiveTypeList.genericTargets) do
if ObjectiveTypeInfo.Check(targetGameId) then
dynamicQuestType = ObjectiveTypeInfo.Type
break
end
end
end
Expand Down
56 changes: 42 additions & 14 deletions SOC/QuestObjects/Helicopter/Classes/HelicopterLua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,42 @@ namespace SOC.QuestObjects.Helicopter
{
static class HelicopterLua
{

static readonly LuaFunction setHelicopterAttributes = new LuaFunction("SetHeliAttributes", @"
function this.SetHeliAttributes()
for i,heliInfo in ipairs(this.QUEST_TABLE.heliList)do
local gameObjectId = GetGameObjectId(heliInfo.heliName)
if gameObjectId~=GameObject.NULL_ID then
if heliInfo.commands then
for j,heliCommand in ipairs(heliInfo.commands)do
GameObject.SendCommand(gameObjectId, heliCommand)
end
end
end
end
end");

internal static void GetDefinition(HelicopterDetail questDetail, DefinitionLua definitionLua)
{
if (questDetail.helicopters.Count > 0)
if (questDetail.helicopters.Any(helicopter => helicopter.isSpawn))
{
definitionLua.AddDefinition("hasEnemyHeli = true");
}
else
{
definitionLua.AddDefinition("hasEnemyHeli = false");
definitionLua.AddDefinition($"hasEnemyHeli = {(questDetail.helicopters.Any(helicopter => helicopter.isSpawn) ? "true" : "false")}");
}
}

internal static void GetMain(HelicopterDetail questDetail, MainLua mainLua)
{
if (questDetail.helicopters.Count > 0)
if (questDetail.helicopters.Any(helicopter => helicopter.isSpawn))
{
mainLua.AddToQuestTable(BuildHeliList(questDetail));

mainLua.AddToQStep_Main(QStep_MainCommonMessages.mechaNoCaptureTargetMessages);

mainLua.AddToAuxiliary(setHelicopterAttributes);
if (questDetail.helicopters.Any(helicopter => helicopter.isTarget))
{
mainLua.AddToQStep_Main(QStep_MainCommonMessages.mechaNoCaptureTargetMessages);
CheckQuestGenericEnemy helicopterCheck = new CheckQuestGenericEnemy(mainLua);
foreach (Helicopter heli in questDetail.helicopters)
{
if (heli.isTarget)
mainLua.AddToTargetList(heli.GetObjectName());
}
}
}
}
Expand All @@ -47,10 +55,30 @@ private static Table BuildHeliList(HelicopterDetail questDetail)

foreach (Helicopter heli in questDetail.helicopters)
{
if (!heli.isSpawn)
continue;

string DRouteString;
uint route;
if (uint.TryParse(heli.dRoute, out route)) // no quotations if the route is hashed
DRouteString = heli.dRoute;
else
DRouteString = $@"""{heli.dRoute}""";

string CRouteString;
if (uint.TryParse(heli.cRoute, out route))
CRouteString = heli.cRoute;
else
CRouteString = $@"""{heli.cRoute}""";

string dRouteCommand = $@"{{id = ""SetSneakRoute"", route = {DRouteString}}}";
string cRouteCommand = $@"{{id = ""SetCautionRoute"", route = {CRouteString}}}";

heliList.Add($@"
{{
heliName = ""{heli.GetObjectName()}"",{((heli.heliRoute == "NONE") ? "" : $@"
routeName = ""{heli.heliRoute}"",")} {((heli.heliClass == "DEFAULT") ? "" : $@"
heliName = ""{heli.GetObjectName()}"",
routeName = {DRouteString},
commands = {{{dRouteCommand},{cRouteCommand}}},{((heli.heliClass == "DEFAULT") ? "" : $@"
coloringType = TppDefine.ENEMY_HELI_COLORING_TYPE.{heli.heliClass},")}
}}");
}
Expand Down
83 changes: 62 additions & 21 deletions SOC/QuestObjects/Helicopter/Forms/HelicopterBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions SOC/QuestObjects/Helicopter/Forms/HelicopterBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ public HelicopterBox(Helicopter qObject, List<string> routes)
textBox_rot.Text = qObject.position.rotation.GetDegreeRotY();
*/

checkBox_spawn.Checked = qObject.isSpawn;
ToggleEnable();
checkBox_target.Checked = qObject.isTarget;

comboBox_class.Text = qObject.heliClass;

//comboBox_route.Items.Add("NONE");
comboBox_route.Items.AddRange(routes.ToArray());
SetComboBox(comboBox_route, qObject.heliRoute);
comboBox_dRoute.Items.AddRange(routes.ToArray());
SetComboBox(comboBox_dRoute, qObject.dRoute);

comboBox_cRoute.Items.AddRange(routes.ToArray());
SetComboBox(comboBox_cRoute, qObject.cRoute);
}

public override QuestObject getQuestObject()
Expand All @@ -54,5 +59,20 @@ private void SetComboBox(ComboBox comboBox, string text)
comboBox.SelectedIndex = 0;
}
}

private void checkBox_spawn_CheckedChanged(object sender, EventArgs e)
{
ToggleEnable();
}

private void ToggleEnable()
{
bool enable = checkBox_spawn.Checked;

checkBox_target.Enabled = enable;
comboBox_class.Enabled = enable;
comboBox_cRoute.Enabled = enable;
comboBox_dRoute.Enabled = enable;
}
}
}
15 changes: 10 additions & 5 deletions SOC/QuestObjects/Helicopter/HelicopterDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,29 @@ public Helicopter(int index) // (Position pos, int index)
public Helicopter(HelicopterBox box)
{
ID = box.ID;


isSpawn = box.checkBox_spawn.Checked;
isTarget = box.checkBox_target.Checked;
heliRoute = box.comboBox_route.Text;
dRoute = box.comboBox_dRoute.Text;
cRoute = box.comboBox_cRoute.Text;
heliClass = box.comboBox_class.Text;
//position = new Position(new Coordinates(box.textBox_xcoord.Text, box.textBox_ycoord.Text, box.textBox_zcoord.Text), new Rotation(box.textBox_rot.Text));
}

[XmlElement]
public bool isTarget { get; set; } = false;
public bool isSpawn { get; set; } = false;

[XmlElement]
public bool isSpawn { get; set; } = false;
public bool isTarget { get; set; } = false;

[XmlAttribute]
public int ID { get; set; } = 0;

[XmlElement]
public string heliRoute { get; set; } = "NONE";
public string dRoute { get; set; } = "NONE";

[XmlElement]
public string cRoute { get; set; } = "NONE";

[XmlElement]
public string heliClass { get; set; } = "DEFAULT";
Expand Down

0 comments on commit 83a214b

Please sign in to comment.