Skip to content

Commit

Permalink
Merge pull request #11 from PapaJoesSoup/support
Browse files Browse the repository at this point in the history
Support
  • Loading branch information
DoctorDavinci committed Jul 11, 2018
2 parents d3b4f64 + cb50b72 commit b23e192
Show file tree
Hide file tree
Showing 352 changed files with 23,916 additions and 14,204 deletions.
37 changes: 37 additions & 0 deletions .github/issue_template.md
@@ -0,0 +1,37 @@
When reporting issues please provide the following information:

[See this for more information on reporting issues for KSP Mods](http://forum.kerbalspaceprogram.com/?showtopic=83212)

[See the Original Forum Post (OP) for additional info](http://forum.kerbalspaceprogram.com/?showtopic=155014)

##### ISSUE TYPE
<!-- Pick one below and delete the rest: -->
- Support ( Need help getting something to work)
- Bug Report (Something is broken)
- Feature Idea (Something new you want to see)
- Enhancement (Expand on existing features)


##### KSP and BDA Version

```
```

##### OS / ENVIRONMENT


##### SUMMARY
<!-- Explain the problem briefly -->

##### STEPS TO REPRODUCE
<!--
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->


##### Log Files
<!-- /KSP Directory/KSP.log -->
<!-- /KSP Directory/KSP_x64_Data/Output.txt -->
<!-- You can also paste gist.github.com links for larger files -->
9 changes: 8 additions & 1 deletion .gitignore
Expand Up @@ -34,7 +34,9 @@ BDArmory/LocalDev/ksp_production_dir.txt
BDArmory/LocalDev/mono_exe.txt
BDArmory/LocalDev/pdb2mdb_exe.txt
BDArmory/BahaTurret.userprefs
BDArmory/Distribution/GameData/BDArmory/Plugins/
BDArmory/Distribution/GameData/BDArmory/Plugins/BDArmory.Core.dll
BDArmory/Distribution/GameData/BDArmory/Plugins/BDArmory.dll

BDArmory/packages

BDArmory.Core/obj/Debug/BDArmory.Core.csproj.FileListAbsolute.txt
Expand Down Expand Up @@ -144,3 +146,8 @@ BDArmory/LocalDev/Refs/UnityEngine.dll
/BDArmory.Guidance/bin/Release
/BDArmory.Guidance/obj/Release
/BDArmory/BDArmory.sln.DotSettings.user
/BDArmory.Events/obj/Debug
/BDArmory/LocalDev/Refs
/BDArmory.Events/obj/Release
/Binaries
/BDArmory/Distribution/GameData/BDArmory/Plugins
109 changes: 109 additions & 0 deletions BDArmory.Core/BDAPersistantSettingsField.cs
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UniLinq;
using UnityEngine;

namespace BDArmory.Core
{
[AttributeUsage(AttributeTargets.Field)]
public class BDAPersistantSettingsField : Attribute
{
public BDAPersistantSettingsField()
{
}

public static void Save()
{
ConfigNode fileNode = ConfigNode.Load(BDArmorySettings.settingsConfigURL);

if (!fileNode.HasNode("BDASettings"))
{
fileNode.AddNode("BDASettings");
}

ConfigNode settings = fileNode.GetNode("BDASettings");
IEnumerator<FieldInfo> field = typeof(BDArmorySettings).GetFields().AsEnumerable().GetEnumerator();
while (field.MoveNext())
{
if (field.Current == null) continue;
if (!field.Current.IsDefined(typeof(BDAPersistantSettingsField), false)) continue;

settings.SetValue(field.Current.Name, field.Current.GetValue(null).ToString(), true);
}
field.Dispose();
fileNode.Save(BDArmorySettings.settingsConfigURL);
}

public static void Load()
{
ConfigNode fileNode = ConfigNode.Load(BDArmorySettings.settingsConfigURL);
if (!fileNode.HasNode("BDASettings")) return;

ConfigNode settings = fileNode.GetNode("BDASettings");

IEnumerator<FieldInfo> field = typeof(BDArmorySettings).GetFields().AsEnumerable().GetEnumerator();
while (field.MoveNext())
{
if (field.Current == null) continue;
if (!field.Current.IsDefined(typeof(BDAPersistantSettingsField), false)) continue;

if (!settings.HasValue(field.Current.Name)) continue;
object parsedValue = ParseValue(field.Current.FieldType, settings.GetValue(field.Current.Name));
if (parsedValue != null)
{
field.Current.SetValue(null, parsedValue);
}
}
field.Dispose();
}
public static object ParseValue(Type type, string value)
{
if (type == typeof(string))
{
return value;
}

if (type == typeof(bool))
{
return Boolean.Parse(value);
}
else if (type.IsEnum)
{
return System.Enum.Parse(type, value);
}
else if (type == typeof(float))
{
return Single.Parse(value);
}
else if (type == typeof(int))
{
return int.Parse(value);
}
else if (type == typeof(Single))
{
return Single.Parse(value);
}
else if (type == typeof(Rect))
{
string[] strings = value.Split(',');
int xVal = Int32.Parse(strings[0].Split(':')[1].Split('.')[0]);
int yVal = Int32.Parse(strings[1].Split(':')[1].Split('.')[0]);
int wVal = Int32.Parse(strings[2].Split(':')[1].Split('.')[0]);
int hVal = Int32.Parse(strings[3].Split(':')[1].Split('.')[0]);
Rect rectVal = new Rect
{
x = xVal,
y = yVal,
width = wVal,
height = hVal
};
return rectVal;
}
Debug.LogError("[BDArmory]: BDAPersistantSettingsField to parse settings field of type " + type +
" and value " + value);

return null;
}
}
}
37 changes: 22 additions & 15 deletions BDArmory.Core/BDArmory.Core.csproj
Expand Up @@ -19,49 +19,56 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="BDAPersistantSettingsField.cs" />
<Compile Include="Bootstrapper.cs" />
<Compile Include="BuildingDamage.cs" />
<Compile Include="Dependencies.cs" />
<Compile Include="Enum\DamageOperation.cs" />
<Compile Include="Extension\DamageFX.cs" />
<Compile Include="Extension\PartExtensions.cs" />
<Compile Include="Events\DamageEventArgs.cs" />
<Compile Include="Extension\VesselExtensions.cs" />
<Compile Include="Module\HitpointTracker.cs" />
<Compile Include="PartExploderSystem.cs" />
<Compile Include="PerformanceLogger.cs" />
<Compile Include="Services\DamageService.cs" />
<Compile Include="Interface\INotificableService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\NotificableService.cs" />
<Compile Include="Services\TemperatureDamageService.cs" />
<Compile Include="Services\ModuleDamageService.cs" />
<Compile Include="BDArmorySettings.cs" />
<Compile Include="Utils\BlastPhysicsUtils.cs" />
<Compile Include="Utils\BulletPhysics.cs" />
<Compile Include="Utils\DebugUtils.cs" />
<Compile Include="Utils\BDAMath.cs" />
<Compile Include="Utils\LayerMask.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\BDArmory\LocalDev\Refs\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\_LocalDev\KSPRefs\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAssets, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\BDArmory\LocalDev\Refs\KSPAssets.dll</HintPath>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\_LocalDev\KSPRefs\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\BDArmory\LocalDev\Refs\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>..\..\_LocalDev\KSPRefs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\BDArmory\LocalDev\Refs\UnityEngine.UI.dll</HintPath>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\_LocalDev\KSPRefs\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
59 changes: 59 additions & 0 deletions BDArmory.Core/BDArmorySettings.cs
@@ -0,0 +1,59 @@

namespace BDArmory.Core
{
public class BDArmorySettings
{
public static string settingsConfigURL = "GameData/BDArmory/settings.cfg";

[BDAPersistantSettingsField] public static bool INSTAKILL = false;
[BDAPersistantSettingsField] public static bool BULLET_HITS = true;
[BDAPersistantSettingsField] public static bool BULLET_DECALS = true;
[BDAPersistantSettingsField] public static float PHYSICS_RANGE = 0; //TODO: remove all references to this so it can be deprecated!
[BDAPersistantSettingsField] public static bool EJECT_SHELLS = true;
[BDAPersistantSettingsField] public static bool SHELL_COLLISIONS = true;
[BDAPersistantSettingsField] public static bool INFINITE_AMMO = false;
[BDAPersistantSettingsField] public static bool DRAW_DEBUG_LINES = false;
[BDAPersistantSettingsField] public static bool DRAW_DEBUG_LABELS = false;
[BDAPersistantSettingsField] public static bool DRAW_AIMERS = true;
[BDAPersistantSettingsField] public static bool AIM_ASSIST = true;
[BDAPersistantSettingsField] public static bool REMOTE_SHOOTING = false;
[BDAPersistantSettingsField] public static bool BOMB_CLEARANCE_CHECK = true;
[BDAPersistantSettingsField] public static float MAX_BULLET_RANGE = 8000f; //TODO: remove all references to this so it can be deprecated! all ranges should be supplied in part config!
[BDAPersistantSettingsField] public static float TRIGGER_HOLD_TIME = 0.3f;
[BDAPersistantSettingsField] public static bool ALLOW_LEGACY_TARGETING = true; //TODO: remove all references to this so it can be deprecated! legacy targeting should not be support anymore in future versions.
[BDAPersistantSettingsField] public static float TARGET_CAM_RESOLUTION = 1024f;
[BDAPersistantSettingsField] public static bool BW_TARGET_CAM = true;
[BDAPersistantSettingsField] public static float SMOKE_DEFLECTION_FACTOR = 10f;
[BDAPersistantSettingsField] public static float RWR_WINDOW_SCALE_MIN = 0.50f;
[BDAPersistantSettingsField] public static float RWR_WINDOW_SCALE = 1f;
[BDAPersistantSettingsField] public static float RWR_WINDOW_SCALE_MAX = 1.50f;
[BDAPersistantSettingsField] public static float RADAR_WINDOW_SCALE_MIN = 0.50f;
[BDAPersistantSettingsField] public static float RADAR_WINDOW_SCALE = 1f;
[BDAPersistantSettingsField] public static float RADAR_WINDOW_SCALE_MAX = 1.50f;
[BDAPersistantSettingsField] public static float TARGET_WINDOW_SCALE_MIN = 0.50f;
[BDAPersistantSettingsField] public static float TARGET_WINDOW_SCALE = 1f;
[BDAPersistantSettingsField] public static float TARGET_WINDOW_SCALE_MAX = 2f;
[BDAPersistantSettingsField] public static float BDARMORY_UI_VOLUME = 0.35f;
[BDAPersistantSettingsField] public static float BDARMORY_WEAPONS_VOLUME = 0.32f;
[BDAPersistantSettingsField] public static float MAX_GUARD_VISUAL_RANGE = 40000f;
[BDAPersistantSettingsField] public static float MAX_ACTIVE_RADAR_RANGE = 40000f; //NOTE: used ONLY for display range of radar windows! Actual radar range provided by part configs!
[BDAPersistantSettingsField] public static float MAX_ENGAGEMENT_RANGE = 40000f; //NOTE: used ONLY for missile dlz parameters!
[BDAPersistantSettingsField] public static float GLOBAL_LIFT_MULTIPLIER = 0.20f;
[BDAPersistantSettingsField] public static float GLOBAL_DRAG_MULTIPLIER = 4f;
[BDAPersistantSettingsField] public static float IVA_LOWPASS_FREQ = 2500f;
[BDAPersistantSettingsField] public static bool PEACE_MODE = false;
[BDAPersistantSettingsField] public static bool IGNORE_TERRAIN_CHECK = false;
[BDAPersistantSettingsField] public static bool DISPLAY_PATHING_GRID = false; //laggy when the grid gets large
[BDAPersistantSettingsField] public static bool ADVANCED_EDIT = false; //Used for debug fields not nomrally shown to regular users

[BDAPersistantSettingsField] public static float RECOIL_FACTOR = 0.75f;
[BDAPersistantSettingsField] public static float DMG_MULTIPLIER = 100f;
[BDAPersistantSettingsField] public static float HITPOINT_MULTIPLIER = 2.0f;
[BDAPersistantSettingsField] public static float EXP_DMG_MOD_BALLISTIC;
[BDAPersistantSettingsField] public static float EXP_DMG_MOD_MISSILE;
[BDAPersistantSettingsField] public static float EXP_IMP_MOD;
[BDAPersistantSettingsField] public static int MAX_FIRES_PER_VESSEL = 10; //controls fx for penetration only for landed or splashed
[BDAPersistantSettingsField] public static float FIRELIFETIME_IN_SECONDS = 90f; //controls fx for penetration only for landed or splashed
[BDAPersistantSettingsField] public static bool PERFORMANCE_LOGGING = false;
}
}
4 changes: 2 additions & 2 deletions BDArmory.Core/Bootstrapper.cs
Expand Up @@ -7,8 +7,8 @@ namespace BDArmory.Core
public class Bootstrapper :MonoBehaviour
{
private void Awake()
{
Dependencies.Register<DamageService, TemperatureDamageService>();
{
Dependencies.Register<DamageService, ModuleDamageService>();
}
}
}
26 changes: 26 additions & 0 deletions BDArmory.Core/BuildingDamage.cs
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace BDArmory.Core
{
[KSPAddon(KSPAddon.Startup.MainMenu, false)]
public class BuildingDamage : ScenarioDestructibles
{
public override void OnAwake()
{
Debug.Log("[BDArmory]: Modifying Buildings");

foreach (KeyValuePair<string, ProtoDestructible> bldg in protoDestructibles)
{
DestructibleBuilding building = bldg.Value.dBuildingRefs[0];
building.damageDecay = 600f;
building.impactMomentumThreshold *= 150;
}

}

}
}
3 changes: 2 additions & 1 deletion BDArmory.Core/Events/DamageEventArgs.cs
Expand Up @@ -8,7 +8,8 @@ public class DamageEventArgs : EventArgs
{
public int VesselId { get; set; }
public int PartId { get; set; }
public double Damage { get; set; }
public float Damage { get; set; }
public float Armor { get; set; }
public DamageOperation Operation { get; set; }
}
}
47 changes: 47 additions & 0 deletions BDArmory.Core/Extension/DamageFX.cs
@@ -0,0 +1,47 @@
using UnityEngine;

namespace BDArmory.Core.Extension
{
public class DamageFX : MonoBehaviour
{
public static bool engineDamaged = false;

public void Start()
{

}

public void FixedUpdate()
{
if (engineDamaged)
{
float probability = Utils.BDAMath.RangedProbability(new[] { 50f, 25f, 20f, 2f });
if (probability >= 3)
{
ModuleEngines engine = gameObject.GetComponent<ModuleEngines>();
engine.flameout = true;
engine.heatProduction *= 1.05f;
engine.maxThrust *= 0.825f;
}
}
}


public static void SetEngineDamage(Part part)
{
ModuleEngines engine;
engine = part.GetComponent<ModuleEngines>();
engine.flameout = true;
engine.heatProduction *= 1.0125f;
engine.maxThrust *= 0.825f;
}

public static void SetWingDamage(Part part)
{
ModuleLiftingSurface wing;
wing = part.GetComponent<ModuleLiftingSurface>();
wing.deflectionLiftCoeff *= 0.825f;

}
}
}

0 comments on commit b23e192

Please sign in to comment.