Skip to content

Commit

Permalink
Fixed some issues with cooldowns.
Browse files Browse the repository at this point in the history
  • Loading branch information
jecrell committed Jul 26, 2017
1 parent 1e1804b commit 04a151e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 34 deletions.
Binary file modified Assemblies/AbilityUser.dll
Binary file not shown.
Binary file modified Assemblies/CompVehicle.dll
Binary file not shown.
Binary file modified Source/.vs/JecsTools/v15/.suo
Binary file not shown.
25 changes: 8 additions & 17 deletions Source/AllModdingComponents/CompAbilityUser/Command_PawnAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,21 @@ public override void ProcessInput(Event ev)
public override GizmoResult GizmoOnGUI(Vector2 topLeft)
{
Rect rect = new Rect(topLeft.x, topLeft.y, this.Width, 75f);
bool flag = false;
bool isMouseOver = false;
if (Mouse.IsOver(rect))
{
flag = true;
isMouseOver = true;
GUI.color = GenUI.MouseoverColor;
}
Texture2D badTex = this.icon;
if (badTex == null)
{
badTex = BaseContent.BadTex;
}
if (badTex == null) badTex = BaseContent.BadTex;

GUI.DrawTexture(rect, Command.BGTex);
MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);
GUI.color = this.IconDrawColor;
Widgets.DrawTextureFitted(new Rect(rect), badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords);
GUI.color = Color.white;
bool flag2 = false;
bool isUsed = false;
//Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width);

KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;
Expand All @@ -86,14 +83,11 @@ public override GizmoResult GizmoOnGUI(Vector2 topLeft)
GizmoGridDrawer.drawnHotKeys.Add(keyCode);
if (this.hotKey.KeyDownEvent)
{
flag2 = true;
isUsed = true;
Event.current.Use();
}
}
if (Widgets.ButtonInvisible(rect, false))
{
flag2 = true;
}
if (Widgets.ButtonInvisible(rect, false)) isUsed = true;
string labelCap = this.LabelCap;
if (!labelCap.NullOrEmpty())
{
Expand Down Expand Up @@ -125,7 +119,7 @@ public override GizmoResult GizmoOnGUI(Vector2 topLeft)
float y = this.pawnAbility.MaxCastingTicks;
float fill = x / y;
Widgets.FillableBar(rect, fill, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
if (flag2)
if (isUsed)
{
if (this.disabled)
{
Expand All @@ -145,10 +139,7 @@ public override GizmoResult GizmoOnGUI(Vector2 topLeft)
}
else
{
if (flag)
{
return new GizmoResult(GizmoState.Mouseover, null);
}
if (isMouseOver) return new GizmoResult(GizmoState.Mouseover, null);
return new GizmoResult(GizmoState.Clear, null);
}
}
Expand Down
22 changes: 11 additions & 11 deletions Source/AllModdingComponents/CompAbilityUser/CompAbilityUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<PawnAbility> AllPowers
{
PawnAbility pa = new PawnAbility(this.AbilityUser, abilityDef);
if (activenow == false) pa.TicksUntilCasting = (int)(pa.powerdef.MainVerb.SecondsToRecharge * GenTicks.TicksPerRealSecond);
if (savedTicks != -1) pa.TicksUntilCasting = (int)savedTicks;
if (savedTicks != -2) pa.TicksUntilCasting = (int)savedTicks;
thelist.Add(pa);
this.UpdateAbilities();

Expand Down Expand Up @@ -260,8 +260,8 @@ public virtual IEnumerable<Command_PawnAbility> GetPawnAbilityVerbs()
command_CastPower.Disable("CannotOrderNonControlled".Translate());
}
string reason = "";
if (newVerb.CasterIsPawn)
{
//if (newVerb.CasterIsPawn)
//{
if (newVerb.CasterPawn.story.WorkTagIsDisabled(WorkTags.Violent) &&
this.AllPowers[j].powerdef.MainVerb.isViolent)
{
Expand All @@ -270,29 +270,29 @@ public virtual IEnumerable<Command_PawnAbility> GetPawnAbilityVerbs()
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.CasterPawn.drafter.Drafted)
else if (!newVerb.ability.NeedsCooldown)
{
command_CastPower.Disable("IsNotDrafted".Translate(new object[]
command_CastPower.Disable("AU_PawnAbilityRecharging".Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.ability.CanFire)
//This is a hook for modders.
else if (!CanCastPowerCheck(newVerb, out reason))
{
command_CastPower.Disable("AU_PawnAbilityRecharging".Translate(new object[]
command_CastPower.Disable(reason.Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
//This is a hook for modders.
else if (!CanCastPowerCheck(newVerb, out reason))
else if (!newVerb.CasterPawn.drafter.Drafted)
{
command_CastPower.Disable(reason.Translate(new object[]
command_CastPower.Disable("IsNotDrafted".Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
}
//}
yield return command_CastPower;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/AllModdingComponents/CompAbilityUser/PawnAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void PawnAbilityTick()
public virtual string PostAbilityVerbDesc() => "";


public bool CanFire
public virtual bool NeedsCooldown
{
get
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public int MaxCastingTicks
public void ExposeData()
{
//base.ExposeData();
Scribe_Values.Look<int>(ref this.TicksUntilCasting, "TicksUntilcasting", -1);
Scribe_Values.Look<int>(ref this.TicksUntilCasting, "TicksUntilcasting", -2);
Scribe_References.Look<Pawn>(ref this.pawn, "pawn");
Scribe_Defs.Look<AbilityDef>(ref this.powerdef, "powerdef");
if (Scribe.mode == LoadSaveMode.PostLoadInit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Verb_UseAbility_TrueBurst : Verb_UseAbility
// Made it so burst is not burst per each target, but back to the regular burst-over-time.
protected override bool TryCastShot()
{
this.ability.TicksUntilCasting = (int)this.UseAbilityProps.SecondsToRecharge * GenTicks.TicksPerRealSecond;
bool result = false;
this.TargetsAoE.Clear();
UpdateTargets();
Expand All @@ -36,10 +37,9 @@ protected override bool TryCastShot()

// here, might want to have this set each time so people don't force stop on last burst and not hit the cooldown?
//this.burstShotsLeft = 0;
if (this.burstShotsLeft == 0)
{
this.ability.TicksUntilCasting = (int)this.UseAbilityProps.SecondsToRecharge * GenTicks.TicksPerRealSecond;
}
//if (this.burstShotsLeft == 0)
//{
//}
PostCastShot(result, out result);
return result;
}
Expand Down

0 comments on commit 04a151e

Please sign in to comment.