Exemplo n.º 1
0
        private (float flankWidth, float flankDepth) PlanFlankDeployment(
            FormationDeploymentFlank flankFlank,
            Vec2 deployPosition,
            Vec2 deployDirection,
            float verticalOffset   = 0.0f,
            float horizontalOffset = 0.0f,
            bool isReinforcement   = false)
        {
            Mat3 identity = Mat3.Identity;

            identity.RotateAboutUp(deployDirection.RotationInRadians);
            float val1   = 0.0f;
            float num1   = 0.0f;
            Vec2  vec2_1 = deployDirection.LeftVec();

            foreach (KeyValuePair <FormationDeploymentOrder, FormationDeploymentPlan> keyValuePair in this._deploymentFlanks[(int)flankFlank])
            {
                FormationDeploymentPlan formationDeploymentPlan = keyValuePair.Value;
                Vec2          vec2_2     = deployPosition - (num1 + verticalOffset) * deployDirection + horizontalOffset * vec2_1;
                WorldPosition origin     = new WorldPosition(Mission.Current.Scene, UIntPtr.Zero, vec2_2.ToVec3(), false);
                IntPtr        navMesh    = (IntPtr)origin.GetNavMesh();
                WorldFrame    worldFrame = new WorldFrame(identity, origin);
                formationDeploymentPlan.SetFrame(new WorldFrame?(worldFrame), isReinforcement);
                float num2 = formationDeploymentPlan.PlannedDepth + 3f;
                num1 += num2;
                val1  = Math.Max(val1, formationDeploymentPlan.PlannedWidth);
            }
            float num3 = Math.Max(num1 - 3f, 0.0f);

            return(val1, num3);
        }
Exemplo n.º 2
0
        private float ComputeFlankWidth(FormationDeploymentFlank flank)
        {
            float val1 = 0.0f;

            foreach (KeyValuePair <FormationDeploymentOrder, FormationDeploymentPlan> keyValuePair in this._deploymentFlanks[(int)flank])
            {
                val1 = Math.Max(val1, keyValuePair.Value.PlannedWidth);
            }
            return(val1);
        }
Exemplo n.º 3
0
        private float ComputeFlankDepth(FormationDeploymentFlank flank, bool countPositiveTroops = false)
        {
            float num = 0.0f;

            foreach (KeyValuePair <FormationDeploymentOrder, FormationDeploymentPlan> keyValuePair in this._deploymentFlanks[(int)flank])
            {
                if (!countPositiveTroops)
                {
                    num += keyValuePair.Value.PlannedDepth + 3f;
                }
                else if (keyValuePair.Value.PlannedTroopCount > 0)
                {
                    num += keyValuePair.Value.PlannedDepth + 3f;
                }
            }
            return(num - 3f);
        }
Exemplo n.º 4
0
        public FormationDeploymentFlank GetDefaultFlank(bool spawnWithHorses)
        {
            FormationDeploymentFlank formationDeploymentFlank = FormationDeploymentFlank.Count;

            if (!spawnWithHorses && this.Class.IsMounted())
            {
                if (this.Class == FormationClass.HeavyCavalry || this.Class == FormationClass.Cavalry)
                {
                    formationDeploymentFlank = FormationDeploymentFlank.Front;
                }
                else if (this.Class == FormationClass.LightCavalry || this.Class == FormationClass.HorseArcher)
                {
                    formationDeploymentFlank = FormationDeploymentFlank.Rear;
                }
            }
            else
            {
                switch (this.Class)
                {
                case FormationClass.Ranged:
                case FormationClass.NumberOfRegularFormations:
                case FormationClass.Bodyguard:
                case FormationClass.NumberOfAllFormations:
                    formationDeploymentFlank = FormationDeploymentFlank.Rear;
                    break;

                case FormationClass.Cavalry:
                case FormationClass.HeavyCavalry:
                    formationDeploymentFlank = FormationDeploymentFlank.Left;
                    break;

                case FormationClass.HorseArcher:
                case FormationClass.LightCavalry:
                    formationDeploymentFlank = FormationDeploymentFlank.Right;
                    break;

                default:
                    formationDeploymentFlank = FormationDeploymentFlank.Front;
                    break;
                }
            }
            return(formationDeploymentFlank);
        }
Exemplo n.º 5
0
        public void PlanFieldBattleDeploymentAtPosition(
            Vec2 deployPosition,
            Vec2 deployDirection,
            bool isReinforcement = false)
        {
            for (int index = 0; index < this._formationDeploymentPlans.Length; ++index)
            {
                int formationTroopCount = this._formationTroopCounts[index];
                FormationDeploymentPlan  formationDeploymentPlan = this._formationDeploymentPlans[index];
                FormationDeploymentFlank defaultFlank            = formationDeploymentPlan.GetDefaultFlank(this.SpawnWithHorses);
                (float width2, float depth2) = MissionDeploymentPlan.GetFormationSpawnWidthAndDepth(formationDeploymentPlan.Class, formationTroopCount, !this.SpawnWithHorses);
                formationDeploymentPlan.SetPlannedDimensions(width2, depth2);
                formationDeploymentPlan.SetPlannedTroopCount(formationTroopCount);
                int offset = formationTroopCount > 0 ? 0 : 1;
                FormationDeploymentOrder deploymentOrder = formationDeploymentPlan.GetDeploymentOrder(offset);
                this._deploymentFlanks[(int)defaultFlank].Add(deploymentOrder, formationDeploymentPlan);
            }
            (float flankWidth, float flankDepth)tuple = this.PlanFlankDeployment(FormationDeploymentFlank.Front, deployPosition, deployDirection, isReinforcement: isReinforcement);
            float flankWidth1       = tuple.flankWidth;
            float verticalOffset1   = tuple.flankDepth + 3f;
            float flankWidth2       = this.PlanFlankDeployment(FormationDeploymentFlank.Rear, deployPosition, deployDirection, verticalOffset1, isReinforcement: isReinforcement).flankWidth;
            float num               = Math.Max(flankWidth1, flankWidth2);
            float verticalOffset2   = this.ComputeFlankDepth(FormationDeploymentFlank.Front, true) + 3f;
            float flankWidth3       = this.ComputeFlankWidth(FormationDeploymentFlank.Left);
            float horizontalOffset1 = (float)(2.0 + 0.5 * ((double)num + (double)flankWidth3));

            this.PlanFlankDeployment(FormationDeploymentFlank.Left, deployPosition, deployDirection, verticalOffset2, horizontalOffset1, isReinforcement);
            float flankWidth4       = this.ComputeFlankWidth(FormationDeploymentFlank.Right);
            float horizontalOffset2 = (float)(-1.0 * (2.0 + 0.5 * ((double)num + (double)flankWidth4)));

            this.PlanFlankDeployment(FormationDeploymentFlank.Right, deployPosition, deployDirection, verticalOffset2, horizontalOffset2, isReinforcement);
            for (int index = 0; index < this._deploymentFlanks.Length; ++index)
            {
                this._deploymentFlanks[index].Clear();
            }
        }