public string GetSqf(out string[] sqf, ConvertOptions options, string groupName = null) { var code = new List <string>(); var name = Name ?? $"marker{ID}"; code.Add($"{name} = createMarker [\"{name}\", {Position}];"); code.Add($"\"{name}\" setMarkerType \"{Type}\";"); if (!String.IsNullOrEmpty(Text)) { code.Add($"\"{name}\" setMarkerText \"{Text}\";"); } if (Alpha.HasValue) { code.Add($"\"{name}\" setMarkerAlpha {Alpha.Value};"); } if (!String.IsNullOrEmpty(ColorName)) { code.Add($"\"{name}\" setMarkerColor \"{ColorName}\";"); } if (SizeA.HasValue || SizeB.HasValue) { var a = SizeA.HasValue ? SizeA.Value : 1; var b = SizeB.HasValue ? SizeB.Value : 1; code.Add($"\"{name}\" setMarkerSize [{a},{b}];"); } if (Angle.HasValue) { code.Add($"\"{name}\" setMarkerDir {Angle.Value};"); } if (!String.IsNullOrEmpty(FillName)) { code.Add($"\"{name}\" setMarkerBrush \"{FillName}\";"); } if (!String.IsNullOrEmpty(MarkerType)) { code.Add($"\"{name}\" setMarkerShape \"{MarkerType}\";"); } if (options.AddToGlobalArray) { code.Add($"markers pushBack {name};"); } code.Add(""); sqf = code.ToArray(); VariableName = name; return(name); }
public string GetSqf(out string[] sqf, ConvertOptions options, string groupName = null) { var code = new List <string>(); var name = Attributes.Name ?? $"vehicle{ID.ToString()}"; var position = PositionInfo.Position; if ((Flags & ArmAFlags.Unit) == ArmAFlags.Unit || !String.IsNullOrEmpty(groupName)) { if (string.IsNullOrEmpty(groupName)) { throw new Exception("Tried to create unit without a group"); } if (name.StartsWith("vehicle")) { name = name.Replace("vehicle", "unit"); } code.Add($"{name} = {groupName} createUnit [\"{Type}\", {position}, [], 0, \"CAN_COLLIDE\"];"); } else { code.Add($"{name} = createVehicle [\"{Type}\", {position}, [], 0, \"CAN_COLLIDE\"];"); } var setUpVector = false; if (PositionInfo.Angle != null) { var angle = PositionInfo.Angle; //yaw = X, pitch = Y, roll/bank = Z code.Add($"{name} setDir deg({angle.Z});"); if (angle.X != 0 || angle.Y != 0) { code.Add($"[{name}, {angle.X}, {angle.Y}] call BIS_fnc_setPitchBank;"); } else { setUpVector = true; } } else { setUpVector = true; } code.Add($"{name} setPosASL {position};"); if ((Flags & ArmAFlags.SetOnGround) == ArmAFlags.SetOnGround) { code.Add($"{name} setPosATL [getPosATL {name} select 0, getPosATL {name} select 1, 0];"); } if (ATLOffset.HasValue) { code.Add($"{name} setPosATL [getPosATL {name} select 0, getPosATL {name} select 1, {ATLOffset.Value}];"); } if (setUpVector) { code.Add($"{name} setVectorUp [0,0,1];"); } if (Type == "Land_Carrier_01_base_F") { code.Add($"[{name}] call BIS_fnc_Carrier01PosUpdate;"); } if (Attributes.Health.HasValue) { code.Add($"{name} setDamage {Attributes.Health.Value};"); } if (Attributes.Ammo.HasValue) { code.Add($"{name} setVehicleAmmo {Attributes.Ammo.Value};"); } if (Attributes.Fuel.HasValue) { code.Add($"{name} setFuel {Attributes.Fuel.Value};"); } foreach (var customAttribute in CustomAttributes) { var formattedCode = customAttribute.Expression.Replace("_this", name); if (customAttribute.ValueType == "STRING" || customAttribute.ValueType == "ANY") { formattedCode = formattedCode.Replace("_value", $"\"{customAttribute.Value}\""); } else { formattedCode = formattedCode.Replace("_value", $"{customAttribute.Value}"); } code.Add(formattedCode); } if (options.AddToGlobalArray) { code.Add($"objects pushBack {name};"); } code.Add(""); sqf = code.ToArray(); VariableName = name; return(name); }
public string GetSqf(out string[] sqf, ConvertOptions options, string groupName = null) { var code = new List <string>(); var name = Attributes.Name ?? $"group{ID}"; if (options.AutoDeleteEmptyGroups) { code.Add($"{name} = createGroup [{Side}, true];"); } else { code.Add($"{name} = createGroup {Side};"); } if (!String.IsNullOrEmpty(Attributes.CombatMode)) { code.Add($"{name} setCombatMode \"{Attributes.CombatMode}\";"); } if (!String.IsNullOrEmpty(Attributes.Behaviour)) { code.Add($"{name} setBehaviour \"{Attributes.Behaviour}\";"); } if (!String.IsNullOrEmpty(Attributes.SpeedMode)) { code.Add($"{name} setSpeedMode \"{Attributes.SpeedMode}\";"); } if (!String.IsNullOrEmpty(Attributes.Formation)) { code.Add($"{name} setFormation \"{Attributes.Formation}\";"); } if (Attributes.DynamicSimulation) { code.Add($"{name} enableDynamicSimulation true;"); } foreach (var entity in Entities) { entity.ATLOffset = ATLOffset; var unitName = entity.GetSqf(out var entitySQF, options, name); code.AddRange(entitySQF); } foreach (var link in Links) { var group = Parser.Mission.Groups.Find(g => g.Entities.Find(u => u.ID == link.ObjectToLink) != null); var unit = group.Entities.Find(u => u.ID == link.ObjectToLink); var linker = Parser.Mission.Objects.Find(o => o.ID == link.ObjectToLinkTo); if (unit == null || linker == null) { throw new Exception($"Invalid link: {ID}: {link.ObjectToLink}->{link.ObjectToLinkTo}"); } if ((linker.Flags & ArmAFlags.Unit) != ArmAFlags.Unit) { // Put unit in vehicle switch (link.Role) { // Driver case 1: code.Add($"{unit.VariableName} moveInDriver {linker.VariableName};"); break; // Commander / Gunner case 2: { var action = "moveInCommander"; if (!linker.GunnerSeatUsed) { action = "moveInGunner"; linker.GunnerSeatUsed = true; } code.Add($"{unit.VariableName} {action} {linker.VariableName};"); } break; // Passenger case 3: { if (link.CargoIndex.HasValue) { code.Add($"{unit.VariableName} moveInCargo [{linker.VariableName}, {link.CargoIndex.Value}];"); } else { code.Add($"{unit.VariableName} moveInCargo {linker.VariableName};"); } } break; } } } foreach (var waypoint in Waypoints) { var waypointName = $"waypoint{waypoint.ID}"; code.Add($"{waypointName} = {name} addWaypoint [{waypoint.Position}, 0];"); code.Add($"{waypointName} setWaypointType \"{waypoint.Type}\";"); if (!String.IsNullOrEmpty(waypoint.CombatMode)) { code.Add($"{waypointName} setWaypointCombatMode \"{waypoint.CombatMode}\";"); } if (!String.IsNullOrEmpty(waypoint.Formation)) { code.Add($"{waypointName} setWaypointFormation \"{waypoint.Formation}\";"); } if (!String.IsNullOrEmpty(waypoint.Speed)) { code.Add($"{waypointName} setWaypointSpeed \"{waypoint.Speed}\";"); } if (!String.IsNullOrEmpty(waypoint.Combat)) { code.Add($"{waypointName} setWaypointBehaviour \"{waypoint.Combat}\";"); } waypoint.VariableName = waypointName; } if (options.AddToGlobalArray) { code.Add($"groups pushBack {name};"); } code.Add(""); sqf = code.ToArray(); VariableName = name; return(name); }
public string GetSqf(out string[] sqf, ConvertOptions options, string groupName = null) { throw new NotSupportedException(); }