Skip to content
Snippets Groups Projects
Commit 68582a37 authored by Reeves, David E's avatar Reeves, David E
Browse files

* code snippets

parent 7e0890b1
No related branches found
No related tags found
No related merge requests found
Showing
with 142 additions and 3 deletions
No preview for this file type
......@@ -66,6 +66,48 @@
<ItemGroup>
<EmbeddedResource Include="res\add_goal.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\add_cm.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\add_goal_specific.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\add_replan_trigger.snp" />
<EmbeddedResource Include="res\create_tactical_unit.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\force_kill.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\log_specific_entity.snp" />
<EmbeddedResource Include="res\print_message.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\remove_replan_trigger.snp" />
<EmbeddedResource Include="res\remove_replan_triggers_all.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\schedule_event_entity.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\schedule_event_unit.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\set_invisible.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\set_invulnerable.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\permit_direct_fire.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\observe_sector_relative.snp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="res\observe_sector_fixed.snp" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -12,21 +12,39 @@ namespace CodeCompleteTool
public string SnippetName { get; protected set; }
public string SnippetHelp { get; protected set; }
public string[] RawData { get; protected set; }
public string[] Code { get; protected set; }
public string[] Import { get; protected set; }
public static bool IsLoaded { get { return snippets != null && snippets.Count > 0; } }
public CodeSnippet(string[] data)
{
string[] descs = data[0].Split('|');
SnippetName = descs[0];
SnippetHelp = descs[1];
SnippetHelp = "Snippet: " + descs[1];
List<string> rd = new List<string>();
List<string> imp = new List<string>();
List<string> cd = new List<string>();
for (int i = 1; i < data.Length; i++)
{
string trimStr = data[i].Trim();
if (trimStr.StartsWith("import"))
{
if (trimStr.Length > 6)
imp.Add(data[i]);
}
else
{
cd.Add(data[i]);
}
rd.Add(data[i]);
}
RawData = rd.ToArray();
Import = imp.ToArray();
Code = cd.ToArray();
if (snippets == null)
{
......@@ -43,7 +61,15 @@ namespace CodeCompleteTool
string desc = "";
CodeSnippet cs = snippets[key];
foreach(string str in cs.RawData)
//foreach(string str in cs.RawData)
//{
// desc += str + Environment.NewLine;
//}
foreach (string str in cs.Import)
{
desc += str + Environment.NewLine;
}
foreach (string str in cs.Code)
{
desc += str + Environment.NewLine;
}
......
add_cm|Add a control measure to the scenario. The entity is used to get the cm side.
import mtry.cxxi.model.HierarchicalTaskNetwork.HTNUtilities as HTNUtilities
addedCM = HTNUtilities._py_addControlMeasure(%ENTITY_OBJ, %LOCATION)
add_goal|Add a goal to an entity
add_goal|Add a goal to an entity. Goal is added to the "default" stack.
UtilityFuncsExp.%NAME(
%NAME, # entity name string
%DELAY, # delay double
......
add_goal_specific|Add a goal to an entity. Goal is added to the specified stack.
UtilityFuncsExp.%NAME(
%NAME, # entity name string
%DELAY, # delay double
%GOALPATH, # goal path string
%STACK, # name of the goal stack to add to
%ARGS, # arguments to tree hashable list
%VARS) # variables to pass to the tree usually None
add_replan_trigger|Add a replan trigger event to the tree
goalContainer.getCurrentExecutingStack().addReplanTrigger("%EVENT_NAME")
create_tactical_unit|Create a tactical unit from a list of entity names
UtilityFuncsExp.createTacticalUnit(
%NAME, # unit name string
%ENTITIES, # list of entities making up the unit
%CMDR_NAME, # entity name of cmdr (must be in list) string
%SIC_NAME, # entity name of sic (must be in list) string
None, None, None)
force_kill|Force kill an entity
import mtry.cxxi.model.HierarchicalTaskNetwork.HTNUtilities as HTNUtilities
HTNUtilities._py_killEntityAt(
%ENTITY_NAME, # name of the entity to kill string
%KILL_TYPE, # name of the KillType to use string
%DELAY) # delay time to kill double
log_specific_entity|Turn on the extra loggers for a specific entity
import mtry.cxxi.model.MtryLog.LogManager as LogManager
LogManager.addSpecificEntityLog(%ENTITY_NAME) # name of the entity to log string
observe_sector_relative|Start observe relative to the entity
sensorName = %SENSOR_NAME
# start observe
if obs.observeSectorFixed(sensorName, %DIRECTION, %FIELDOFREGARD_ANGLE): # direction angle of sensor double, for angle to scan double
printMessage("Starting observe with "+sensorName, True)
else:
printMessage("Observe cannot start. "+sensorName+" unavailable", True)
observe_sector_relative|Start observe relative to the entity
sensorName = %SENSOR_NAME
# start observe
if obs.observeSectorRelative(sensorName, %DIRECTION, %FIELDOFREGARD_ANGLE): # direction angle offset from entity heading double, for angle to scan double
printMessage("Starting observe with "+sensorName, True)
else:
printMessage("Observe cannot start. "+sensorName+" unavailable", True)
permit_direct_fire|Turn on or off direct fire
engage.permitDirectFire(%PERMIT_BOOL) # True or False
print_message|Print a message to std out. This method also print the message to the loggers
printMessage(%CONTENT, %APPEND_ENTITY_NAME) # desc string, append name True/False
remove_replan_trigger|Remove a replan trigger event from the tree
goalContainer.getCurrentExecutingStack().removeReplanTrigger("%EVENT_NAME")
remove_replan_trigger_all|Remove all replan trigger events from the tree
goalContainer.getGoalStack().removeReplanTriggers()
schedule_event_entity|Schedule event for an entity
UtilityFuncsExp.scheduleEvent(
%DM, # decision module of the entity sending the event
%ENTITY_NAME, # entity name to send event to string
%EVENT_TO_SEND, # event name to send to entity string
%DELAY, # delay to send the event double
%PARAMS) # parameters for the event list or None
schedule_event_unit|Schedule event for a unit
UtilityFuncsExp.scheduleEvent(
%DM, # decision module of the entity sending the event
%UNIT_NAME, # entity name to send event to string
%EVENT_TO_SEND, # event name to send to entity string
%DELAY, # delay to send the event double
%PARAMS) # parameters for the event list or None
set_invisible|Make an entity invisible to Observe
import mtry.cxxi.model.HierarchicalTaskNetwork.HTNUtilities as HTNUtilities
HTNUtilities._py_setInvisible(%ENTITY_NAME, %INVISIBLE) # name of the entity string, invisible or not bool
set_invulnerable|Set an entity immune to damage
import mtry.cxxi.model.HierarchicalTaskNetwork.HTNUtilities as HTNUtilities
HTNUtilities._py_setInvulnerable(%ENTITY_NAME, %INVULNERABLE) # entity name string, invulnerable bool
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment