static void PostTranspiler(UnitMovementAgent instance, float?minSpeed) { if (minSpeed.HasValue) { instance.SetMinSpeed(minSpeed.Value); } }
static void Postfix(UnitMovementAgent __instance, ref float?__state) { if (__state.HasValue) { __instance.SetMinSpeed(__state.Value); } }
private static void Postfix(UnitMovementAgent __instance, ref bool __result) { if (UnitEntityDataUtils.CheckUnitEntityData(__instance.Unit?.EntityData, settings.allowMovementThroughSelection)) { __result = true; } }
private static bool JustOverlapping(this UnitEntityData unit, UnitEntityData target) { UnitMovementAgent agentASP = unit.View.AgentASP; Vector3? destination = agentASP.GetDestination(); if (!destination.HasValue) { return(false); } float minDistance = agentASP.Corpulence + target.View.AgentASP.Corpulence; // the destination is not where the unit is intended to stop at, so we have to step back destination = destination.Value - (destination.Value - unit.Position).normalized * (agentASP.IsCharging ? unit.GetAttackApproachRadius(target) : agentASP.ApproachRadius); // if the destination is going to overlap with target, forbid this behavior if (target.DistanceTo(destination.Value) < minDistance) { return(true); } // if the unit doesn't have enough movement to go through the target, forbid it from going through if (unit.IsCurrentUnit() && !agentASP.GetIsInForceMode()) { return(CurrentTurn().GetRemainingMovementRange(true) < Math.Min(unit.DistanceTo(target) + minDistance, unit.DistanceTo(destination.Value))); } return(false); }
static void Postfix(UnitMovementAgent __instance, ref bool __result) { if (IsInCombat() && !__result) { __result = CurrentUnit().CanMoveThrough(__instance.Unit?.EntityData); } }
static void Postfix(UnitMovementAgent __instance) { if (IsEnabled()) { __instance.SetChargeAvoidanceFinishTime(TimeSpan.Zero); } }
static bool Prefix(UnitMovementAgent __instance) { if (IsInCombat() && (__instance.Unit?.EntityData?.IsInCombat ?? false)) { return(false); } return(true); }
private static bool Prefix(UnitMovementAgent __instance, ref bool __result) { if (!UnitEntityDataUtils.CheckUnitEntityData(__instance.Unit?.EntityData, settings.allowMovementThroughSelection)) { __result = !__instance.CombatMode; // this duplicates the logic in the original logic for IsSoftObstacle. If we are not in combat mode and it is not in our allow movement through category then it is a soft obstacle return(false); } return(true); }
static bool Prefix(UnitMovementAgent __instance, ref bool __result) { if (IsInCombat() && DoNotMovingThroughNonAlly) { __result = !__instance.CombatMode; return(false); } return(true); }
static bool Prefix(UnitMovementAgent __instance, ref float deltaTime, ref float?__state) { if (IsInCombat()) { // passing acting ending delaying // not in combat o x x x // in combat - not current x x x x // in combat - current x o x x bool canMove = default; bool isInForceMode = __instance.GetIsInForceMode(); UnitEntityView view = __instance.Unit; if (IsPassing()) { canMove = !(view?.EntityData?.IsInCombat ?? false); } else { canMove = (view?.EntityData).IsCurrentUnit() && IsActing() && !(view.AnimationManager?.IsPreventingMovement ?? false) && !view.IsCommandsPreventMovement && __instance.IsReallyMoving; if (canMove) { CurrentTurn().TickMovement(ref deltaTime, isInForceMode); if (deltaTime <= 0f) { canMove = false; } else if (!isInForceMode) { // disable acceleration effect __state = __instance.GetMinSpeed(); __instance.SetMinSpeed(1f); __instance.SetWarmupTime(0f); __instance.SetSlowDownTime(0f); } } } if (!canMove) { if (!isInForceMode) { __instance.Stop(); } return(false); } } return(true); }
static float?PreTranspiler(UnitMovementAgent instance) { if (IsInCombat()) { // disable acceleration effect float minSpeed = instance.GetMinSpeed(); instance.SetMinSpeed(1f); instance.SetWarmupTime(0f); instance.SetSlowDownTime(0f); return(minSpeed); } return(null); }
static bool Prefix(UnitMovementAgent __instance, ref float deltaTime) { if (IsInCombat()) { // passing acting ending delaying // not in combat o x x x // in combat - not current x x x x // in combat - current x o x x bool canMove = default; bool isInForceMode = __instance.GetIsInForceMode(); UnitEntityView view = __instance.Unit; if (IsPassing()) { canMove = !(view?.EntityData?.IsInCombat ?? false); } else { if (canMove = (view?.EntityData).IsCurrentUnit() && IsActing() && !(view.AnimationManager?.IsPreventingMovement ?? false) && !view.IsCommandsPreventMovement && __instance.IsReallyMoving) { CurrentTurn().TickMovement(ref deltaTime, isInForceMode); canMove = deltaTime > 0f; } else { canMove = false; } } if (!canMove) { if (!isInForceMode) { __instance.Stop(); } return(false); } } return(true); }
public static bool GetIsInForceMode(this UnitMovementAgent unitMovementAgent) { return(unitMovementAgent.GetFieldValue <UnitMovementAgent, bool>("m_IsInForceMode")); }
public static void SetWarmupTime(this UnitMovementAgent unitMovementAgent, float value) { unitMovementAgent.SetFieldValue("m_WarmupTime", value); }
public static void SetSlowDownTime(this UnitMovementAgent unitMovementAgent, float value) { unitMovementAgent.SetFieldValue("m_SlowDownTime", value); }
public static void SetMinSpeed(this UnitMovementAgent unitMovementAgent, float value) { unitMovementAgent.SetFieldValue("m_MinSpeed", value); }
public static void SetChargeAvoidanceFinishTime(this UnitMovementAgent unitMovementAgent, TimeSpan value) { unitMovementAgent.SetFieldValue("m_ChargeAvoidanceFinishTime", value); }
public static Vector3?GetDestination(this UnitMovementAgent unitMovementAgent) { return(unitMovementAgent.GetFieldValue <UnitMovementAgent, Vector3?>("m_Destination")); }
public static IEnumerator <AbilityDeliveryTarget> Deliver(AbilityExecutionContext context, TargetWrapper targetWrapper) { UnitEntityData target = targetWrapper.Unit; if (target == null) { UberDebug.LogError("Target unit is missing"); yield break; } UnitEntityData caster = context.Caster; if (caster.GetThreatHand() == null) { UberDebug.LogError("Invalid caster's weapon"); yield break; } UnitMovementAgent agentASP = caster.View.AgentASP; caster.View.StopMoving(); agentASP.IsCharging = true; agentASP.ForcePath(new ForcedPath(new List <Vector3> { caster.Position, target.Position })); caster.Descriptor.State.IsCharging = true; caster.Descriptor.AddBuff(BlueprintRoot.Instance.SystemMechanics.ChargeBuff, context, 1.Rounds().Seconds); UnitAttack unitAttack = new UnitAttack(target); unitAttack.Init(caster); float timeSinceStart = 0f; while (unitAttack.ShouldUnitApproach) { timeSinceStart += Game.Instance.TimeController.GameDeltaTime; if (timeSinceStart > 6f) { UberDebug.Log("Charge: timeSinceStart > 6f"); yield break; } else if (caster.GetThreatHand() == null) { UberDebug.Log("Charge: caster.GetThreatHand() == null"); yield break; } else if (!caster.Descriptor.State.CanMove) { UberDebug.Log("Charge: !caster.Descriptor.State.CanMove"); yield break; } else if (!(bool)agentASP) { UberDebug.Log("Charge: !(bool)caster.View.AgentASP"); yield break; } else if (!agentASP.IsReallyMoving) { agentASP.ForcePath(new ForcedPath(new List <Vector3> { caster.Position, target.Position })); if (!agentASP.IsReallyMoving) { UberDebug.Log("Charge: !caster.View.AgentASP.IsReallyMoving"); yield break; } } agentASP.MaxSpeedOverride = Math.Max(agentASP.MaxSpeedOverride ?? 0f, caster.CombatSpeedMps * 2f); yield return(null); } caster.View.StopMoving(); unitAttack.IgnoreCooldown(null); unitAttack.IsCharge = true; caster.Commands.AddToQueueFirst(unitAttack); }
public static float GetMinSpeed(this UnitMovementAgent unitMovementAgent) { return(unitMovementAgent.GetFieldValue <UnitMovementAgent, float>("m_MinSpeed")); }