Skip to content

Commit

Permalink
Merge pull request #187 from SmashPhil/feature/unstable-testing
Browse files Browse the repository at this point in the history
Feature/unstable testing
  • Loading branch information
SmashPhil authored Aug 7, 2024
2 parents 91c32ec + db338ea commit 523cb1a
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 80 deletions.
Binary file modified 1.5/Assemblies/UpdateLogTool.dll
Binary file not shown.
Binary file modified 1.5/Assemblies/Vehicles.dll
Binary file not shown.
8 changes: 6 additions & 2 deletions 1.5/Defs/WorldObjectDefs/WorldObjects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@
<li>WITab_Caravan_Gear</li>
<li>WITab_Caravan_Social</li>
<li>WITab_Caravan_Items</li>
<li MayRequireAnyOf = "Mlie.RoadsOfTheRim,Mlie.RoadsOfTheRim_steam,Vampiresbane.RailsAndRoadsOfTheRim,Vampiresbane.RailsAndRoadsOfTheRim_steam">RoadsOfTheRim.WITab_Caravan_Build</li>
<li MayRequireAnyOf = "Mlie.RoadsOfTheRim,Mlie.RoadsOfTheRim_steam">RoadsOfTheRim.WITab_Caravan_Build</li>
<li MayRequireAnyOf = "Mlie.RailsAndRoadsOfTheRim,Mlie.RailsAndRoadsOfTheRim_steam">RailsAndRoadsOfTheRim.WITab_Caravan_Build</li>
</inspectorTabs>

<comps>
<li MayRequireAnyOf = "Mlie.RoadsOfTheRim,Mlie.RoadsOfTheRim_steam,Vampiresbane.RailsAndRoadsOfTheRim,Vampiresbane.RailsAndRoadsOfTheRim_steam">
<li MayRequireAnyOf = "Mlie.RoadsOfTheRim,Mlie.RoadsOfTheRim_steam">
<compClass>RoadsOfTheRim.WorldObjectComp_Caravan</compClass>
</li>
<li MayRequireAnyOf = "Mlie.RailsAndRoadsOfTheRim,Mlie.RailsAndRoadsOfTheRim_steam">
<compClass>RailsAndRoadsOfTheRim.WorldObjectComp_Caravan</compClass>
</li>
</comps>
</WorldObjectDef>

Expand Down
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<name>Vehicle Framework</name>
<author>Smash Phil</author>
<packageId>SmashPhil.VehicleFramework</packageId>
<modVersion>1.5.1701</modVersion>
<modVersion>1.5.1704</modVersion>
<supportedVersions>
<li>1.4</li>
<li>1.5</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public void RemoveOverlays(string key)
}
}

public virtual void RenderGraphicOverlays(Vector3 drawPos, float angle, Rot8 rot)
public virtual void RenderGraphicOverlays(Vector3 drawPos, float extraRotation, Rot8 rot)
{
float extraAngle;
foreach (GraphicOverlay graphicOverlay in Overlays)
{
float overlayAngle = angle;
extraAngle = graphicOverlay.data.rotation;
float overlayAngle = rot.AsRotationAngle;
extraAngle = graphicOverlay.data.rotation + extraRotation;
Vector3 overlayDrawPos = drawPos;
if (graphicOverlay.data.component != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ public static void TrySatisfyPawnNeeds(Pawn pawn)
}
break;
case Need_Comfort _:
need.CurLevel = handler.role.Comfort; //TODO - add comfort factor for roles
if (handler != null)
{
need.CurLevel = handler.role.Comfort; //TODO - add comfort factor for roles
}
break;
case Need_Outdoors _:
if (handler == null || handler.role.Exposed)
Expand Down
17 changes: 9 additions & 8 deletions Source/Vehicles/Comps/FueledTravel/CompFueledTravel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class CompFueledTravel : VehicleComp, IRefundable

public bool FullTank => Mathf.Approximately(fuel, TargetFuelLevel);

public int FuelCountToFull => Mathf.RoundToInt(TargetFuelLevel - Fuel);
public int FuelCountToFull => Mathf.CeilToInt(TargetFuelLevel - Fuel);

public float TargetFuelPercent
{
Expand Down Expand Up @@ -241,6 +241,7 @@ public virtual void Refuel(float amount)
/// </summary>
private void RefuelHalfway()
{
ConsumeFuel(float.MaxValue);
Refuel(FuelCapacity / 2f);
}

Expand Down Expand Up @@ -368,27 +369,27 @@ public virtual IEnumerable<Gizmo> DevModeGizmos()
};
yield return new Command_Action
{
defaultLabel = "Debug: Set fuel to 0.1",
defaultLabel = "Debug: Set fuel to half",
action = delegate ()
{
fuel = 0f;
Refuel(0.1f);
RefuelHalfway();
}
};
yield return new Command_Action
{
defaultLabel = "Debug: Set fuel to half",
defaultLabel = "Debug: Set fuel to max",
action = delegate ()
{
RefuelHalfway();
Refuel(FuelCapacity);
}
};
yield return new Command_Action
{
defaultLabel = "Debug: Set fuel to max",
defaultLabel = "Debug: Set fuel to 99.99%",
action = delegate ()
{
Refuel(FuelCapacity);
ConsumeFuel(float.MaxValue);
Refuel(FuelCapacity * 0.999999f);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public override void ExposeData()
{
Scribe_Values.Look(ref debugSpawnVehicleBuildingGodMode, nameof(debugSpawnVehicleBuildingGodMode));
}


#if DEBUG
Scribe_Values.Look(ref debugUseMultithreading, nameof(debugUseMultithreading), defaultValue: true);
Scribe_Values.Look(ref debugLoadAssetBundles, nameof(debugLoadAssetBundles), defaultValue: true);

#if DEBUG
Scribe_Values.Look(ref debugAllowRaiders, nameof(debugAllowRaiders));
#endif
}
Expand Down
15 changes: 15 additions & 0 deletions Source/Vehicles/Pathing/RegionGrid/VehicleMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,21 @@ public override void MapComponentUpdate()
{
if (owners.Count > 0 && vehicleRegionGridIndexChecking < owners.Count)
{
//if (owners.Count > 0 && vehicleRegionGridIndexChecking < owners.Count)
//{
// VehicleDef vehicleDef = owners[vehicleRegionGridIndexChecking];
// VehiclePathData vehiclePathData = this[vehicleDef];
// AsyncRegionRebuildAction rebuildAction = AsyncPool<AsyncRegionRebuildAction>.Get();
// rebuildAction.Set(this, vehiclePathData);
// dedicatedThread.Queue(rebuildAction);
// //vehiclePathData.VehicleRegionGrid.UpdateClean();
// //vehiclePathData.VehicleRegionAndRoomUpdater.TryRebuildVehicleRegions();
// vehicleRegionGridIndexChecking++;
// if (vehicleRegionGridIndexChecking >= owners.Count)
// {
// vehicleRegionGridIndexChecking = 0;
// }
//}
VehicleDef vehicleDef = owners[vehicleRegionGridIndexChecking];
VehiclePathData vehiclePathData = this[vehicleDef];
vehiclePathData.VehicleRegionGrid.UpdateClean();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using SmashTools.Performance;
using System;
using System.Collections.Generic;
using System.Linq;
using Verse;
using static Vehicles.VehicleMapping;

namespace Vehicles
{
public class AsyncRegionRebuildAction : AsyncAction
{
private VehicleMapping mapping;
private VehiclePathData pathData;

public override bool IsValid => mapping?.map?.Index > -1;

public void Set(VehicleMapping mapping, VehiclePathData pathData)
{
this.mapping = mapping;
this.pathData = pathData;
}

public override void Invoke()
{
pathData.VehicleRegionGrid.UpdateClean();
pathData.VehicleRegionAndRoomUpdater.TryRebuildVehicleRegions();
}

public override void ReturnToPool()
{
mapping = null;
pathData = null;
AsyncPool<AsyncRegionRebuildAction>.Return(this);
}
}
}
1 change: 1 addition & 0 deletions Source/Vehicles/Vehicles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
<Compile Include="Utility\Helpers\AsyncActions\AsyncPathingAction.cs" />
<Compile Include="Utility\Helpers\AsyncActions\AsyncRegionAction.cs" />
<Compile Include="Utility\Helpers\AsyncActions\AsyncReachabilityCacheAction.cs" />
<Compile Include="Utility\Helpers\AsyncActions\AsyncRegionRebuildAction.cs" />
<Compile Include="Utility\Helpers\AsyncActions\AsyncRegionRegisterAction.cs" />
<Compile Include="Utility\Helpers\TranslationHelper.cs" />
<Compile Include="Utility\Helpers\World\CaravanHelper.cs" />
Expand Down
42 changes: 21 additions & 21 deletions Source/Vehicles/World/Caravan/VehicleCaravan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,27 +321,27 @@ public override IEnumerable<Gizmo> GetGizmos()
};
}

Command_Action disembark = new Command_Action();
disembark.icon = VehicleTex.Anchor;
disembark.defaultLabel = "VF_CommandDisembark".Translate(); //settlement != null ? "VF_CommandDockShip".Translate() : "VF_CommandDockShipDisembark".Translate();
disembark.defaultDesc = "VF_CommandDisembarkDesc".Translate(); //settlement != null ? "VF_CommandDockShipDesc".Translate(settlement) : "VF_CommandDockShipObjectDesc".Translate();
disembark.action = delegate ()
{
CaravanHelper.StashVehicles(this);
};

Settlement settlement = Find.WorldObjects.SettlementBaseAt(Tile);

if (Find.World.Impassable(Tile))
{
disembark.Disable("VF_CommandDisembarkImpassableBiome".Translate());
}
if (settlement != null)
{
disembark.Disable("CommandSettleFailAlreadyHaveBase".Translate());
}

yield return disembark;
//Command_Action disembark = new Command_Action();
//disembark.icon = VehicleTex.Anchor;
//disembark.defaultLabel = "VF_CommandDisembark".Translate(); //settlement != null ? "VF_CommandDockShip".Translate() : "VF_CommandDockShipDisembark".Translate();
//disembark.defaultDesc = "VF_CommandDisembarkDesc".Translate(); //settlement != null ? "VF_CommandDockShipDesc".Translate(settlement) : "VF_CommandDockShipObjectDesc".Translate();
//disembark.action = delegate ()
//{
// CaravanHelper.StashVehicles(this);
//};

//Settlement settlement = Find.WorldObjects.SettlementBaseAt(Tile);

//if (Find.World.Impassable(Tile))
//{
// disembark.Disable("VF_CommandDisembarkImpassableBiome".Translate());
//}
//if (settlement != null)
//{
// disembark.Disable("CommandSettleFailAlreadyHaveBase".Translate());
//}

//yield return disembark;
}
foreach (Gizmo gizmo2 in forage.GetGizmos())
{
Expand Down
91 changes: 91 additions & 0 deletions UpdateLog/Previous/UpdateLog_1.5.7001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<UpdateLog>
<!--Can utilize Version.txt file placed in mod's root directory-->
<currentVersion>1.5.1701</currentVersion>
<!--Startup,GameInit,LoadedGame,NewGame-->
<updateOn>GameInit</updateOn>
<!--Full description shown in update page-->
<description>&lt;title&gt;Notes&lt;/title&gt;&lt;font&gt;Small&lt;/font&gt;
This update includes many Quality of Life features such as designating roads, reorienting aerial vehicles upon landing, reorienting vehicles upon pathing to a destination, and more.

Be sure to take a look at the full list down below, and as always if you have feedback feel free to drop by the discord. Thanks!

Note: This version is a hotfix of 1.5.1700, fixing the issue where Camera+'s and Mark That Pawn's patch on vehicle rendering broke.
If you removed either during the wait, you can now safely re-add them.
&lt;title&gt;Bug Fixes&lt;/title&gt;&lt;font&gt;Tiny&lt;/font&gt;
- Upgrading FuelCapacity wouldn't update amount needed to refuel, causing pawns to attempt to refuel in a loop.

- Under specific circumstances a vehicle would become 'incapacitated'

- Overlays would attempt to initialize outside of the main thread when loading a save.

- Vehicle role removal upgrade refunding would add the role copied from the upgrade, rather than checking if it was originally from the vehicle def.

- Compatibility patch for Rails and Roads of the Rim

- AsyncRegionRegisterAction exception when loading a map, causing some regions to become malformed in the process.

- Concurrency issue when updating regions, resulting in invalid regions marked for dirtying not having their cells persist in the dirty set.

- Vehicle leaks would not reset their status when repaired once the fuel count had reached 0.

- CompUpgradeTree attempting to validate listers even if the vehicle is unspawned but being ticked elsewhere (such as in Save Our Ship 2 when traveling between ships).
&lt;title&gt;Performance Optimization&lt;/title&gt;&lt;font&gt;Tiny&lt;/font&gt;
- Parallelized Vehicle Region generation when loading a map.
&lt;title&gt;Additional Changes&lt;/title&gt;&lt;font&gt;Tiny&lt;/font&gt;
&lt;b&gt;Players&lt;/b&gt;
- Added Road zone to direct vehicles over paths, and to note which edges to try and exit from for caravans.

- Items dropped from cargo will be placed outside of the vehicle's hitbox.

- Vehicles can drag-to-rotate by holding right click when ordering to go to a location. This will rotate the vehicle to face this rotation after arriving at the destination.

- Aerial vehicles with forced rotations for animations can now be rotated during landing, which will rotate the vehicle to face this rotation after it has landed.

- Upgrades will refund % of cost if upgrade is reset or vehicle is deconstructed / destroyed.

- Only explosive mortar shells will have their explosion radius reduced when impacting water, as opposed to every shell.

- VehicleTurret aim pies hidden if vehicle is not selected.
&lt;b&gt;Modders&lt;/b&gt;
- Added CompUpgrade for adding / removing comps from upgrades
&lt;title&gt;Final Notes&lt;/title&gt;&lt;font&gt;Tiny&lt;/font&gt;
Please report any issues you find on either &lt;link&gt;https://discord.gg/zXDyfWQ&lt;/link&gt;(discord) or &lt;link&gt;https://github.com/SmashPhil/Vehicle-Framework/issues&lt;/link&gt;(github).</description>
<!--Static parameterless method to execute when update log is executed-->
<actionOnUpdate></actionOnUpdate>
<!--Show update log on next startup.-->
<update>false</update>
<!--Testing mode prevents the update from saving over the UpdateLog file-->
<testing>false</testing>
<!--Icon bar shown to the right of the mod's name.-->
<rightIconBar>
<li>
<name>Github</name>
<icon>githubIcon</icon>
<url>https://github.com/SmashPhil/Vehicles</url>
</li>
<li>
<name>Discord</name>
<icon>discordIcon</icon>
<url>https://discord.gg/zXDyfWQ</url>
</li>
<li>
<name>Steam</name>
<icon>steamIcon</icon>
<url>https://steamcommunity.com/sharedfiles/filedetails/?id=3014915404</url>
</li>
</rightIconBar>
<!--Icon bar shown to the left of the mod's name.-->
<leftIconBar>
<li>
<name>Patreon</name>
<icon>patreonIcon</icon>
<url>https://www.patreon.com/smashphil</url>
</li>
<li>
<name>Cursed Crew</name>
<icon>cursedCrewIcon</icon>
<url>https://discord.gg/NNe2VxAU7Z</url>
</li>
</leftIconBar>
</UpdateLog>
Loading

0 comments on commit 523cb1a

Please sign in to comment.