Skip to content

Commit

Permalink
Added component
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Sep 3, 2021
1 parent d05d2d6 commit 1e302cf
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
60 changes: 60 additions & 0 deletions TabletopTweaks/NewComponents/ContextRestoreResourcesFixed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using Kingmaker;
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.EntitySystem.Entities;
using Kingmaker.UnitLogic.Mechanics;
using Kingmaker.UnitLogic.Mechanics.Actions;
using Kingmaker.Utility;
using UnityEngine;
using UnityEngine.Serialization;

namespace TabletopTweaks.NewComponents {
[TypeId("febcdf299ca242a7be5bacfda8e4254f")]
class ContextRestoreResourcesFixed : ContextAction {
public BlueprintAbilityResource Resource {
get {
BlueprintAbilityResourceReference resource = this.m_Resource;
if (resource == null) {
return null;
}
return resource.Get();
}
}

public override string GetCaption() {
return "Restore resource";
}

public override void RunAction() {
TargetWrapper target = base.Target;
UnitEntityData unitEntityData = target?.Unit;
if (unitEntityData == null) {
PFLog.Default.Error("Target is missing", Array.Empty<object>());
return;
}
if (m_IsFullRestoreAllResources) {
unitEntityData.Descriptor.Resources.FullRestoreAll();
return;
}
if (!ContextValueRestoration) {
unitEntityData.Descriptor.Resources.Restore(Resource, 1);
return;
}
unitEntityData.Descriptor.Resources.Restore(Resource, Value.Calculate(base.Context));
}

public bool m_IsFullRestoreAllResources;

[SerializeField]
[FormerlySerializedAs("Resource")]
[HideIf("m_IsFullRestoreAllResources")]
private BlueprintAbilityResourceReference m_Resource;

[HideIf("m_IsFullRestoreAllResources")]
public bool ContextValueRestoration;

[ShowIf("ContextValueRestoration")]
public ContextValue Value;
}
}
1 change: 0 additions & 1 deletion TabletopTweaks/TabletopTweaks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Bugfixes\Abilities\ContextRestoreResourceFixed.cs" />
<Compile Include="Bugfixes\Classes\Alchemist.cs" />
<Compile Include="Bugfixes\Classes\Arcanist.cs" />
<Compile Include="Bugfixes\Classes\Barbarian.cs" />
Expand Down

0 comments on commit 1e302cf

Please sign in to comment.