Skip to content

Commit

Permalink
Version 1.30c
Browse files Browse the repository at this point in the history
Smartparts do not RT delay
RT Bypass now a true bypass
Hide disabled actions
  • Loading branch information
SirDiazo committed Feb 8, 2015
1 parent 475098a commit 61b8a5e
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 35 deletions.
14 changes: 14 additions & 0 deletions AGExt/CommonMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ public void ActivateActionString(string groupStr, bool force, bool forceDir) //m
}
}

public void ActivateActionStringActivation(string groupStr, bool force, bool forceDir) //main activation method
{
if (thisVsl.HoldPhysics)
{
ScreenMessages.PostScreenMessage("AGX cannot activate actions while under timewarp.", 10F, ScreenMessageStyle.UPPER_CENTER);
}
else if (vesselInstanceOK)
{
int group = actionsList.Find(agx => agx.grpName == groupStr).group;
ActivateActionGroupActivation(group, force, forceDir);

}
}

public void ActivateActionGroup(int group, bool force, bool forceDir)
{

Expand Down
8 changes: 4 additions & 4 deletions AGExt/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2247,8 +2247,8 @@ public void SelParts(int WindowID)
string baname = PartActionsList.ElementAt(ActionsCount - 1).name;
string moduleName = PartActionsList.ElementAt(ActionsCount - 1).listParent.module.name;
foreach (AGXPart agP in AGEditorSelectedParts)
{
List<BaseAction> actsToCheck = new List<BaseAction>();
{
List<BaseAction> actsToCheck = new List<BaseAction>();
if (moduleName.Length > 0)
{
foreach (PartModule pm in agP.AGPart.Modules)
Expand Down Expand Up @@ -2283,10 +2283,10 @@ public void SelParts(int WindowID)
foreach (AGXPart agPrt in AGEditorSelectedParts)
{
List<BaseAction> ThisPartActionsList = new List<BaseAction>();
ThisPartActionsList.AddRange(agPrt.AGPart.Actions);
ThisPartActionsList.AddRange(agPrt.AGPart.Actions.Where(a => a.active == true));
foreach (PartModule pm3 in agPrt.AGPart.Modules)
{
ThisPartActionsList.AddRange(pm3.Actions);
ThisPartActionsList.AddRange(pm3.Actions.Where(a => a.active == true));
}
AGXAction ToAdd = new AGXAction();
if (ThisPartActionsList.ElementAt(ActionsCount - 1).guiName == PartActionsList.ElementAt(ActionsCount - 1).guiName)
Expand Down
230 changes: 222 additions & 8 deletions AGExt/External.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,41 @@ public static List<AGXAction> AGXAllActions()//works //all actions on activevess
return AGXFlight.CurrentVesselActions;
}

public static bool AGX2VslToggleGroup(uint FlightID, int group) //7 on test, works
public static bool AGX2VslToggleGroup(uint FlightID, int group) //other vessel direct toggle activate
{
print("AGX Call: toggle action " + group + " for vessel " + FlightID);
if (HighLogic.LoadedSceneIsFlight)
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == FlightID)
{
AGXFlight.ActivateActionGroup(group);
AGXFlight.ActivateActionGroupActivation(group,false,false);
return true;
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(FlightID);
otherVsl.ActivateActionGroupActivation(group, false, false);
return true;
}
}
else
{
ScreenMessages.PostScreenMessage("AGX Action Not Activated, not in flight", 10F, ScreenMessageStyle.UPPER_CENTER);
return false;
}
}

public static bool AGX2VslToggleGroupDelayCheck(uint FlightID, int group) //other vessel toggle, delay check
{
print("AGX Call: toggle action " + group + " for vessel " + FlightID);
if (HighLogic.LoadedSceneIsFlight)
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == FlightID)
{
AGXFlight.ActivateActionGroup(group);
return true;
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(FlightID);
otherVsl.ActivateActionGroup(group, false, false);
Expand Down Expand Up @@ -128,7 +152,35 @@ public static bool AGX2VslGroupState(uint FlightID, int group) //8 on test, owrk
}
}

public static bool AGX2VslActivateGroup(uint FlightID, int group, bool forceDir) //9 on test, works
public static bool AGX2VslActivateGroup(uint FlightID, int group, bool forceDir) //other vessel, direct activate group
{
print("AGX Call: Activate group for " + group + " for vessel " + FlightID + " in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight)
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == FlightID)
{
//print("this vsl");
AGXFlight.ActivateActionGroupActivation(group, true, forceDir);
return true;
}
else
{
//print("other vsl");
//ScreenMessages.PostScreenMessage("AGX Action Fail, other vessels not implemented yet", 10F, ScreenMessageStyle.UPPER_CENTER);
//return false;
AGXOtherVessel otherVsl = new AGXOtherVessel(FlightID);
otherVsl.ActivateActionGroupActivation(group, true, forceDir);
return true;
}
}
else
{
ScreenMessages.PostScreenMessage("AGX Action Not Activated, not in flight", 10F, ScreenMessageStyle.UPPER_CENTER);
return false;
}
}

public static bool AGX2VslActivateGroupDelayCheck(uint FlightID, int group, bool forceDir) //other vessel, with delay check
{
print("AGX Call: Activate group for " + group + " for vessel " + FlightID + " in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight)
Expand Down Expand Up @@ -156,7 +208,21 @@ public static bool AGX2VslActivateGroup(uint FlightID, int group, bool forceDir)
}
}

public static bool AGXActivateGroup(int i, bool forceDir) //works //activate action group it forceDir direction, true = force activate
public static bool AGXActivateGroup(int i, bool forceDir) //activate action group it forceDir direction, true = force activate
{
print("AGX Call: activate group for " + i + " for active vessel in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight)
{
AGXFlight.ActivateActionGroupActivation(i, true, forceDir);
return true;
}
else
{
return false;
}
}

public static bool AGXActivateGroupDelayCheck(int i, bool forceDir) //activate action group it forceDir direction, true = force activate with delay check
{
print("AGX Call: activate group for " + i + " for active vessel in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight)
Expand All @@ -171,6 +237,44 @@ public static bool AGXActivateGroup(int i, bool forceDir) //works //activate act
}

public static bool AGXToggleGroupName(string grpName) //untested
{
try
{
print("AGX Call: toggle group by name for " + grpName + " for active vessel");
if (HighLogic.LoadedSceneIsFlight) //only workes in flight
{
int grp = 0;
try
{
grp = AGXFlight.AGXguiNames.First(pair => pair.Value.ToLower() == grpName.ToLower()).Key; //compare strings, case does not matter
}
catch//poor man's error trap, name was not found. what is the correct way to do this?
{
return false;
}
if (grp >= 1 && grp <= 250) //check grp is valid
{
AGXFlight.ActivateActionGroupActivation(grp, false, false);
return true;
}
else
{
return false;
}
}
else //not in flight
{
return false;
}
}
catch
{
print("AGX Call FAIL! Catch block hit");
return false;
}
}

public static bool AGXToggleGroupNameDelayCheck(string grpName) //untested
{
try
{
Expand Down Expand Up @@ -220,6 +324,35 @@ public static bool AGX2VslToggleGroupName(uint flightID, string grpName, bool fo
return AGXToggleGroupName(grpName);
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(flightID);
otherVsl.ActivateActionStringActivation(grpName, false, false);
return true;
}
}
else
{
return false;
}
}
catch
{
return false;
}
}

public static bool AGX2VslToggleGroupNameDelayCheck(uint flightID, string grpName, bool forceDir)
{
try
{
print("AGX Call: toggle group by name for " + grpName + " for " + flightID + " in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight) //only workes in flight
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == flightID)
{
return AGXToggleGroupNameDelayCheck(grpName);
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(flightID);
otherVsl.ActivateActionString(grpName, false, false);
Expand All @@ -237,7 +370,7 @@ public static bool AGX2VslToggleGroupName(uint flightID, string grpName, bool fo
}
}

public static bool AGX2VslActivateGroupName(uint flightID, string grpName, bool forceDir)
public static bool AGX2VslActivateGroupNameDelayCheck(uint flightID, string grpName, bool forceDir)
{
try
{
Expand All @@ -246,7 +379,7 @@ public static bool AGX2VslActivateGroupName(uint flightID, string grpName, bool
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == flightID)
{
return AGXActivateGroupName(grpName, forceDir);
return AGXActivateGroupNameDelayCheck(grpName, forceDir);
}
else
{
Expand All @@ -266,7 +399,74 @@ public static bool AGX2VslActivateGroupName(uint flightID, string grpName, bool
}
}

public static bool AGX2VslActivateGroupName(uint flightID, string grpName, bool forceDir)
{
try
{
print("AGX Call: activate group by name for " + grpName + " for " + flightID + " in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight) //only workes in flight
{
if (FlightGlobals.ActiveVessel.rootPart.flightID == flightID)
{
return AGXActivateGroupName(grpName, forceDir);
}
else
{
AGXOtherVessel otherVsl = new AGXOtherVessel(flightID);
otherVsl.ActivateActionStringActivation(grpName, true, forceDir);
return true;
}
}
else
{
return false;
}
}
catch
{
return false;
}
}

public static bool AGXActivateGroupName(string grpName, bool forceDir) //untested
{
try
{
print("AGX Call: activate group by name for " + grpName + " for active vessel in dir " + forceDir);
if (HighLogic.LoadedSceneIsFlight) //only workes in flight
{
int grp = 0;
try
{
grp = AGXFlight.AGXguiNames.First(pair => pair.Value.ToLower() == grpName.ToLower()).Key; //compare strings, case does not matter
}
catch//poor man's error trap, name was not found. what is the correct way to do this?
{
return false;
}
if (grp >= 1 && grp <= 250) //check grp is valid
{
AGXFlight.ActivateActionGroupActivation(grp, true, forceDir);
return true;
}
else
{
return false;
}
}
else //not in flight
{
return false;
}
}
catch
{
print("AGX Call FAIL! Catch block hit");
return false;
}
}

public static bool AGXActivateGroupNameDelayCheck(string grpName, bool forceDir) //untested
{
try
{
Expand Down Expand Up @@ -309,7 +509,7 @@ public static bool AGXToggleGroup(int i) //2 on test, works //toggle action grou
print("AGX Call: toggle group " + i + " for active vessel");
if (HighLogic.LoadedSceneIsFlight)
{
AGXFlight.ActivateActionGroup(i);
AGXFlight.ActivateActionGroupActivation(i,false,false);
return true;
}
else
Expand All @@ -318,6 +518,20 @@ public static bool AGXToggleGroup(int i) //2 on test, works //toggle action grou
}
}

public static bool AGXToggleGroupDelayCheck(int i) //2 on test, works //toggle action group on activevessel
{
print("AGX Call: toggle group " + i + " for active vessel");
if (HighLogic.LoadedSceneIsFlight)
{
AGXFlight.ActivateActionGroup(i);
return true;
}
else
{
return false;
}
}

public static bool AGXGroupState(int i) //is a group activated?
{
print("AGX Call: group gtate " + i + " for active vessel");
Expand Down Expand Up @@ -628,7 +842,7 @@ public static void RTDataReceive(ConfigNode node) //receive data back from RT
}
else
{
ScreenMessages.PostScreenMessage("AGX Action Not Activated, Remotetech passed invalid vessel", 10F, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage("AGX Action Not Activated, Remotetech passed invalid vessel", 10F, ScreenMessageStyle.UPPER_CENTER);

}
}
Expand Down
Loading

0 comments on commit 61b8a5e

Please sign in to comment.