Example #1
0
            public static bool Prefix(
                // ReSharper disable InconsistentNaming
                AI_Movement __instance,
                ref float target,
                ref float speed
                // ReSharper restore InconsistentNaming
                )
            {
                var aiNetworkBehaviourDomestic = __instance.GetComponentInParent(typeof(AI_NetworkBehaviour_Domestic)) as AI_NetworkBehaviour_Domestic;

                if (aiNetworkBehaviourDomestic == null)
                {
                    return(true);
                }

                var speedFactor            = aiNetworkBehaviourDomestic.scaledSize;
                var aiStateMachineDomestic = __instance.GetComponentInParent(typeof(AI_StateMachine_Domestic)) as AI_StateMachine_Domestic;

                // is running
                const int stateRunning = 1;

                if (aiStateMachineDomestic != null &&
                    aiStateMachineDomestic.currentState != null &&
                    aiStateMachineDomestic.currentState.stateIndex == stateRunning &&
                    speedFactor > 3)
                {
                    speedFactor = 3;
                }

                target *= speedFactor;
                speed  *= speedFactor;
                return(true);
            }