public LauncherArchetype(string datapath, FLDataFile.Section sec, ILogController log) : base(datapath, sec, log) { if (sec.SettingExists("damage_per_fire")) { DamagePerFire = sec.GetSetting("damage_per_fire").Float(0); } if (sec.SettingExists("power_usage")) { PowerUsage = sec.GetSetting("power_usage").Float(0); } if (sec.SettingExists("refire_delay")) { RefireDelay = sec.GetSetting("refire_delay").Float(0); } if (sec.SettingExists("muzzle_velocity")) { MuzzleVelocity = new Vector(0, 0, -sec.GetSetting("muzzle_velocity").Float(0)); } if (sec.SettingExists("projectile_archetype")) { uint projectileArchID = FLUtility.CreateID(sec.GetSetting("projectile_archetype").Str(0)); ProjectileArch = ArchetypeDB.Find(projectileArchID) as ProjectileArchetype; if (ProjectileArch == null) { log.AddLog(LogType.ERROR, "error: projectile not found: " + sec.Desc); } } }
private static void LoadWeaponModDB(string datapath, string path, ILogController log) { var ini = new FLDataFile(path, true); foreach (var sec in ini.Sections) { string sectionName = sec.SectionName.ToLowerInvariant(); if (sectionName == "weapontype") { var wt = new WeaponType { Nickname = sec.GetSetting("nickname").Str(0) }; foreach (FLDataFile.Setting set in sec.Settings) { if (set.SettingName.ToLowerInvariant() == "shield_mod") { uint shieldTypeID = FLUtility.CreateID(set.Str(0)); float shieldFactor = set.Float(1); wt.ShieldMods.Add(shieldTypeID, shieldFactor); } } WeaponTypes[FLUtility.CreateID(wt.Nickname)] = wt; } } }
public MunitionArchetype(string datapath, FLDataFile.Section sec, ILogController log) : base(datapath, sec, log) { if (sec.SettingExists("hull_damage")) { HullDamage = sec.GetSetting("hull_damage").Float(0); } if (sec.SettingExists("energy_damage")) { EnergyDamage = sec.GetSetting("energy_damage").Float(0); } if (sec.SettingExists("weapon_type")) { WeaponType = ArchetypeDB.FindWeaponType(sec.GetSetting("weapon_type").Str(0)); if (WeaponType == null) { log.AddLog(LogType.ERROR, "error: weapon_type not found " + sec.Desc); } } if (sec.SettingExists("seeker")) { Seeker = sec.GetSetting("seeker").Str(0); } if (sec.SettingExists("time_to_lock")) { TimeToLock = sec.GetSetting("time_to_lock").Float(0); } if (sec.SettingExists("seeker_range")) { SeekerRange = sec.GetSetting("seeker_range").Float(0); } if (sec.SettingExists("seeker_fov_deg")) { SeekerFovDeg = sec.GetSetting("seeker_fov_deg").Float(0); } if (sec.SettingExists("detonation_dist")) { DetonationDist = sec.GetSetting("detonation_dist").Float(0); } if (sec.SettingExists("cruise_disruptor")) { CruiseDisruptor = sec.GetSetting("cruise_disruptor").Str(0) == "true"; } if (sec.SettingExists("max_angular_velocity")) { MaxAngularVelocity = sec.GetSetting("max_angular_velocity").Float(0); } if (sec.SettingExists("motor")) { uint motorID = FLUtility.CreateID(sec.GetSetting("motor").Str(0)); MotorArch = ArchetypeDB.Find(motorID) as MotorArchetype; if (MotorArch == null) { log.AddLog(LogType.ERROR, "error: motor not found " + sec.Desc); } } }
public static WeaponType FindWeaponType(string nickname) { uint weaponTypeID = FLUtility.CreateID(nickname); if (WeaponTypes.ContainsKey(weaponTypeID)) { return(WeaponTypes[weaponTypeID]); } return(null); }
public Archetype(string datapath, FLDataFile.Section sec, ILogController log) { Nickname = sec.GetSetting("nickname").Str(0); ArchetypeID = FLUtility.CreateID(Nickname); // Load the hardpoints and animation data for the model Hardpoints = new Dictionary <string, HardpointData>(); if (sec.SettingExists("loot_appearance")) { LootAppearance = sec.GetSetting("loot_appearance").Str(0); } if (sec.SettingExists("pod_appearance")) { PodAppearance = sec.GetSetting("loot_appearance").Str(0); } if (sec.SettingExists("DA_archetype")) { ModelPath = datapath + Path.DirectorySeparatorChar + sec.GetSetting("DA_archetype").Str(0); var utf = new UTFFile(); TreeNode root = utf.LoadUTFFile(ModelPath); CmpFixData fix; CmpRevData rev; CmpPrisData pris; CmpSphereData sphere; var file_to_object = new Dictionary <string, string>(); var cons_parent = new Dictionary <string, string>(); var cons_position = new Dictionary <string, Vector>(); var cons_orientation = new Dictionary <string, Matrix>(); if (root.Nodes.ContainsKey("Cmpnd")) { TreeNode cmpnd = root.Nodes["Cmpnd"]; foreach (TreeNode n in cmpnd.Nodes) { if (n.Name == "Cons") { TreeNode cons = n; if (cons.Nodes.ContainsKey("Fix")) { TreeNode fixNode = cons.Nodes["Fix"]; try { fix = new CmpFixData(fixNode.Tag as byte[]); foreach (CmpFixData.Part p in fix.Parts) { cons_parent[p.ChildName] = p.ParentName; cons_position[p.ChildName] = new Vector(p.OriginX, p.OriginY, p.OriginZ); var m = new Matrix { M00 = p.RotMatXX, M01 = p.RotMatXY, M02 = p.RotMatXZ, M10 = p.RotMatYX, M11 = p.RotMatYY, M12 = p.RotMatYZ, M20 = p.RotMatZX, M21 = p.RotMatZY, M22 = p.RotMatZZ }; cons_orientation[p.ChildName] = m; } } catch (Exception) { fix = null; } } if (cons.Nodes.ContainsKey("Pris")) { TreeNode prisNode = cons.Nodes["Pris"]; try { pris = new CmpPrisData(prisNode.Tag as byte[]); foreach (CmpPrisData.Part p in pris.Parts) { cons_parent[p.ChildName] = p.ParentName; cons_position[p.ChildName] = new Vector(p.OriginX, p.OriginY, p.OriginZ); var m = new Matrix { M00 = p.RotMatXX, M01 = p.RotMatXY, M02 = p.RotMatXZ, M10 = p.RotMatYX, M11 = p.RotMatYY, M12 = p.RotMatYZ, M20 = p.RotMatZX, M21 = p.RotMatZY, M22 = p.RotMatZZ }; cons_orientation[p.ChildName] = m; } } catch (Exception) { pris = null; } } if (cons.Nodes.ContainsKey("Rev")) { TreeNode revNode = cons.Nodes["Rev"]; try { rev = new CmpRevData(revNode.Tag as byte[]); foreach (CmpRevData.Part p in rev.Parts) { cons_parent[p.ChildName] = p.ParentName; cons_position[p.ChildName] = new Vector(p.OriginX, p.OriginY, p.OriginZ); var m = new Matrix { M00 = p.RotMatXX, M01 = p.RotMatXY, M02 = p.RotMatXZ, M10 = p.RotMatYX, M11 = p.RotMatYY, M12 = p.RotMatYZ, M20 = p.RotMatZX, M21 = p.RotMatZY, M22 = p.RotMatZZ }; cons_orientation[p.ChildName] = m; } } catch (Exception) { rev = null; } } if (cons.Nodes.ContainsKey("Sphere")) { TreeNode sphereNode = cons.Nodes["Sphere"]; try { sphere = new CmpSphereData(sphereNode.Tag as byte[]); foreach (CmpSphereData.Part p in sphere.Parts) { cons_parent[p.ChildName] = p.ParentName; cons_position[p.ChildName] = new Vector(p.OriginX, p.OriginY, p.OriginZ); var m = new Matrix { M00 = p.RotMatXX, M01 = p.RotMatXY, M02 = p.RotMatXZ, M10 = p.RotMatYX, M11 = p.RotMatYY, M12 = p.RotMatYZ, M20 = p.RotMatZX, M21 = p.RotMatZY, M22 = p.RotMatZZ }; cons_orientation[p.ChildName] = m; } } catch (Exception) { sphere = null; } } } else { if (n.Nodes.ContainsKey("Object name") && n.Nodes.ContainsKey("File name")) { file_to_object.Add(Utilities.GetString(n.Nodes["File name"]), Utilities.GetString(n.Nodes["Object name"])); } } } } foreach (TreeNode hp in utf.Hardpoints.Nodes) { TreeNode hpnode = null, parentnode = null; TreeNode[] matches = root.Nodes.Find(hp.Name, true); foreach (TreeNode m in matches) { hpnode = m; parentnode = hpnode.Parent.Parent.Parent; if (file_to_object.ContainsKey(parentnode.Name)) { break; } } if (hpnode == null) { continue; } var hpd = new HardpointData(hpnode); if (parentnode != root) { string consName = file_to_object[parentnode.Name]; var positionOffset = new Vector(); var rotationOffset = new Matrix(); while (consName.ToLowerInvariant() != "root") { positionOffset += cons_position[consName]; rotationOffset *= cons_orientation[consName]; consName = cons_parent[consName]; } hpd.Position += positionOffset; hpd.Rotation *= rotationOffset; } Hardpoints[hpd.Name.ToLowerInvariant()] = hpd; if (hpd.Name.ToLowerInvariant() == "hpmount") { HpMount = hpd; } } } if (ModelPath != null) { string surPath = Path.ChangeExtension(ModelPath, ".sur"); if (File.Exists(surPath)) { try { new SurFile(surPath); } catch { log.AddLog(LogType.ERROR, "sur load failed for " + surPath); } } } if (sec.SettingExists("mass")) { Mass = sec.GetSetting("mass").Float(0); } if (sec.SettingExists("hit_pts")) { HitPts = sec.GetSetting("hit_pts").Float(0); } if (sec.SettingExists("type")) { try { Type = (ObjectType)Enum.Parse(typeof(ObjectType), sec.GetSetting("type").Str(0).ToUpperInvariant()); } catch (Exception) { Type = ObjectType.NONE; } } // Load the docking points for the model foreach (FLDataFile.Setting set in sec.Settings) { if (set.SettingName == "docking_sphere") { string moortype = set.Str(0).ToLowerInvariant(); string hpname = set.Str(1).ToLowerInvariant(); float dockingRadius = set.Float(2); AddDockingPoint(moortype, hpname, dockingRadius, Hardpoints, log); } } if (sec.SettingExists("loadout")) { Loadout = sec.GetSetting("loadout").Str(0); } // If this is a tradelane ring, load the docking points for it if (Type == ObjectType.TRADELANE_RING) { AddDockingPoint("tradelane_ring", "hpleftlane", 0, Hardpoints, log); AddDockingPoint("tradelane_ring", "hprightlane", 0, Hardpoints, log); } // FIXME: Load or build and surface used for collision detection for this model. }