コード例 #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);
        }
コード例 #2
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();
            }
        }