示例#1
0
        // Parser post apply event
        void IParserEventSubscriber.PostApply(ConfigNode node)
        {
            // Recalculate with the new values and store
            CalculatedMembers(Value);
            AtmosphereInfo.StoreAfg(Value);

            // Fire event
            Events.OnAFGLoaderPostApply.Fire(this, node);
        }
示例#2
0
 public SimulationStep()
 {
     Pitch        = new PitchInfo();
     Control      = new ControlInfo();
     Coordinates  = new CoordinatesInfo();
     Velocity     = new VelocityInfo();
     Acceleration = new AccelerationInfo();
     Atmosphere   = new AtmosphereInfo();
     Aerodynamics = new AerodynamicsInfo();
     Control      = new ControlInfo();
 }
 public MissionInitializerRecord(string name)
 {
     this.SceneName   = name;
     this.TerrainType = -1;
     this.DamageToPlayerMultiplier  = 1f;
     this.DamageToFriendsMultiplier = 1f;
     this.SceneLevels                     = "";
     this.TimeOfDay                       = 6f;
     this.NeedsRandomTerrain              = false;
     this.RandomTerrainSeed               = 0;
     this.PlayingInCampaignMode           = false;
     this.EnableSceneRecording            = false;
     this.SceneUpgradeLevel               = 0;
     this.DisableDynamicPointlightShadows = false;
     this.DoNotUseLoadingScreen           = false;
     this.AtmosphereOnCampaign            = (AtmosphereInfo)null;
 }
示例#4
0
        public AtmosphereFromGroundLoader(CelestialBody body)
        {
            // Is this a spawned body?
            if (body.scaledBody == null)
            {
                throw new InvalidOperationException("The body must be already spawned by the PSystemManager.");
            }

            // Store values
            Value = body.afg;

            if (Value == null)
            {
                // Add the material light direction behavior
                MaterialSetDirection materialLightDirection = body.scaledBody.AddOrGetComponent <MaterialSetDirection>();
                materialLightDirection.valueName = "_localLightDirection";

                // Create the atmosphere shell game object
                GameObject scaledAtmosphere = new GameObject("Atmosphere");
                scaledAtmosphere.transform.parent = body.scaledBody.transform;
                scaledAtmosphere.layer            = GameLayers.SCALED_SPACE_ATMOSPHERE;
                MeshRenderer renderer = scaledAtmosphere.AddComponent <MeshRenderer>();
                renderer.sharedMaterial             = new Components.MaterialWrapper.AtmosphereFromGround();
                renderer.sharedMaterial.renderQueue = 3020;
                MeshFilter meshFilter = scaledAtmosphere.AddComponent <MeshFilter>();
                meshFilter.sharedMesh = Templates.ReferenceGeosphere;
                Value            = body.afg = scaledAtmosphere.AddComponent <AtmosphereFromGround>();
                Value.planet     = body;
                Value.sunLight   = Sun.Instance.gameObject;
                Value.mainCamera = ScaledCamera.Instance.transform;
                AtmosphereInfo.StoreAfg(Value);
                AtmosphereInfo.PatchAfg(Value);

                // Set defaults
                SetDefaultValues();
            }

            Value.planet = body;
        }
 void ISerializableObject.DeserializeFrom(IReader reader)
 {
     this.SceneName                       = reader.ReadString();
     this.SceneLevels                     = reader.ReadString();
     this.TimeOfDay                       = reader.ReadFloat();
     this.NeedsRandomTerrain              = reader.ReadBool();
     this.RandomTerrainSeed               = reader.ReadInt();
     this.EnableSceneRecording            = reader.ReadBool();
     this.SceneUpgradeLevel               = reader.ReadInt();
     this.PlayingInCampaignMode           = reader.ReadBool();
     this.DisableDynamicPointlightShadows = reader.ReadBool();
     this.DoNotUseLoadingScreen           = reader.ReadBool();
     if (reader.ReadBool())
     {
         this.AtmosphereOnCampaign = new AtmosphereInfo();
         this.AtmosphereOnCampaign.DeserializeFrom(reader);
     }
     else
     {
         this.AtmosphereOnCampaign = (AtmosphereInfo)null;
     }
 }
        public static Mission OpenEnhancedBattleTestField(
            string scene,
            BattleConfig config,
            IEnhancedBattleTestCombatant playerParty,
            IEnhancedBattleTestCombatant enemyParty,
            float timeOfDay = 12f)
        {
            var playerSide = config.BattleTypeConfig.PlayerSide;
            var enemySide  = config.BattleTypeConfig.PlayerSide.GetOppositeSide();
            var player     = config.PlayerTeamConfig.General;

            if (player == null)
            {
                return(null);
            }

            bool hasPlayer = config.PlayerTeamConfig.HasGeneral;

            bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker;

            IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2];
            bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer;

            troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true);
            troopSuppliers[(int)enemySide]  = CreateTroopSupplier(enemyParty, isMultiplayer, false);
            bool isPlayerGeneral  = config.BattleTypeConfig.PlayerType == PlayerType.Commander;
            bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant;

            List <CharacterObject> charactersInPlayerSideByPriority = null;
            List <CharacterObject> charactersInEnemySideByPriority  = null;
            string playerTeamGeneralName = null;
            string enemyTeamGeneralName  = null;

            if (!isMultiplayer)
            {
                var playerCharacter = player.CharacterObject as CharacterObject;
                if (playerCharacter == null)
                {
                    return(null);
                }
                charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig);
                var playerGeneral = hasPlayer && isPlayerGeneral
                    ? playerCharacter
                    : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter
                        ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault()
                        : charactersInPlayerSideByPriority.FirstOrDefault());
                if (playerGeneral != null)
                {
                    charactersInPlayerSideByPriority.Remove(playerGeneral);
                    playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        playerGeneral.Name
                    }).FirstOrDefault();
                }
                charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig);
                var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault();
                if (enemyGeneral != null)
                {
                    charactersInEnemySideByPriority.Remove(enemyGeneral);
                    enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        enemyGeneral.Name
                    }).FirstOrDefault();
                }
            }


            AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay);

            return(MissionState.OpenNew("EnhancedBattleTestFieldBattle", new MissionInitializerRecord(scene)
            {
                DoNotUseLoadingScreen = false,
                PlayingInCampaignMode = false,
                AtmosphereOnCampaign = atmosphereInfo,
                SceneLevels = "",
                TimeOfDay = timeOfDay
            }, mission =>
                                        new MissionBehaviour[]
            {
                new CommanderLogic(config),
                new MissionOptionsComponent(),
                new BattleEndLogic(),
                new MissionCombatantsLogic(null, playerParty,
                                           !isPlayerAttacker ? playerParty : enemyParty,
                                           isPlayerAttacker ? playerParty : enemyParty,
                                           Mission.MissionTeamAITypeEnum.FieldBattle, isPlayerSergeant),
                new BattleObserverMissionLogic(),
                new CustomBattleAgentLogic(),
                new MissionAgentSpawnLogic(troopSuppliers, playerSide),
                new EnhancedBattleTestMissionSpawnHandler(!isPlayerAttacker ? playerParty : enemyParty,
                                                          isPlayerAttacker ? playerParty : enemyParty),
                new AgentBattleAILogic(),
                new AgentVictoryLogic(),
                new MissionAgentPanicHandler(),
                new MissionHardBorderPlacer(),
                new MissionBoundaryPlacer(),
                new MissionBoundaryCrossingHandler(),
                new BattleMissionAgentInteractionLogic(),
                new FieldBattleController(),
                new AgentFadeOutLogic(),
                new AgentMoraleInteractionLogic(),
                new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, isPlayerInArmy: false, isPlayerSergeant ? Enumerable.Repeat(config.PlayerTeamConfig.General.CharacterObject.StringId, 1).ToList() : new List <string>()),
                new CreateBodyguardMissionBehavior(
                    isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                    !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                    null, null, true),
                new HighlightsController(),
                new BattleHighlightsController()
            }));
        }
        public static Mission OpenEnhancedBattleTestSiege(
            string scene,
            BattleConfig config,
            IEnhancedBattleTestCombatant playerParty,
            IEnhancedBattleTestCombatant enemyParty,
            float[] wallHitPointPercentages,
            Dictionary <SiegeEngineType, int> siegeWeaponsCountOfAttackers,
            Dictionary <SiegeEngineType, int> siegeWeaponsCountOfDefenders,
            bool isSallyOut          = false,
            bool isReliefForceAttack = false,
            float timeOfDay          = 6f)
        {
            bool hasAnySiegeTower = siegeWeaponsCountOfAttackers.ContainsKey(DefaultSiegeEngineTypes.SiegeTower);

            string levelString;

            switch (config.MapConfig.SceneLevel)
            {
            case 1:
                levelString = "level_1";
                break;

            case 2:
                levelString = "level_2";
                break;

            case 3:
                levelString = "level_3";
                break;

            default:
                levelString = "";
                break;
            }

            var sceneLevelString =
                !(isSallyOut | isReliefForceAttack) ? levelString + " siege" : levelString + " sally";
            var playerSide = config.BattleTypeConfig.PlayerSide;
            var enemySide  = config.BattleTypeConfig.PlayerSide.GetOppositeSide();


            var player = config.PlayerTeamConfig.General;

            if (player == null)
            {
                return(null);
            }
            bool hasPlayer        = config.PlayerTeamConfig.HasGeneral;
            bool isPlayerAttacker = playerSide == BattleSideEnum.Attacker;

            IMissionTroopSupplier[] troopSuppliers = new IMissionTroopSupplier[2];
            bool isMultiplayer = EnhancedBattleTestSubModule.IsMultiplayer;

            troopSuppliers[(int)playerSide] = CreateTroopSupplier(playerParty, isMultiplayer, true);
            troopSuppliers[(int)enemySide]  = CreateTroopSupplier(enemyParty, isMultiplayer, false);
            bool isPlayerGeneral  = config.BattleTypeConfig.PlayerType == PlayerType.Commander || !hasPlayer;
            bool isPlayerSergeant = hasPlayer && config.BattleTypeConfig.PlayerType == PlayerType.Sergeant;

            List <CharacterObject> charactersInPlayerSideByPriority = null;
            List <CharacterObject> charactersInEnemySideByPriority  = null;
            string playerTeamGeneralName = null;
            string enemyTeamGeneralName  = null;

            if (!isMultiplayer)
            {
                var playerCharacter = player.CharacterObject as CharacterObject;
                if (playerCharacter == null)
                {
                    return(null);
                }
                charactersInPlayerSideByPriority = Utility.OrderHeroesByPriority(config.PlayerTeamConfig);
                var playerGeneral = hasPlayer && isPlayerGeneral
                    ? playerCharacter
                    : (hasPlayer && charactersInPlayerSideByPriority.First() == playerCharacter
                        ? charactersInPlayerSideByPriority.Skip(1).FirstOrDefault()
                        : charactersInPlayerSideByPriority.FirstOrDefault());
                if (playerGeneral != null)
                {
                    charactersInPlayerSideByPriority.Remove(playerGeneral);
                    playerTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        playerGeneral.Name
                    }).FirstOrDefault();
                }
                charactersInEnemySideByPriority = Utility.OrderHeroesByPriority(config.EnemyTeamConfig);
                var enemyGeneral = charactersInEnemySideByPriority.FirstOrDefault();
                if (enemyGeneral != null)
                {
                    charactersInEnemySideByPriority.Remove(enemyGeneral);
                    enemyTeamGeneralName = TextObject.ConvertToStringList(new List <TextObject>()
                    {
                        enemyGeneral.Name
                    }).FirstOrDefault();
                }
            }

            AtmosphereInfo atmosphereInfo = CreateAtmosphereInfoForMission(config.MapConfig.Season, timeOfDay);

            var attackerSiegeWeapons =
                GetSiegeWeaponTypes(siegeWeaponsCountOfAttackers);
            var defenderSiegeWeapons =
                GetSiegeWeaponTypes(siegeWeaponsCountOfDefenders);

            return(MissionState.OpenNew("EnhancedBattleTestSiegeBattle", new MissionInitializerRecord(scene)
            {
                PlayingInCampaignMode = false,
                AtmosphereOnCampaign = atmosphereInfo,
                SceneLevels = sceneLevelString,
                TimeOfDay = timeOfDay
            }, mission =>
            {
                List <MissionBehaviour> missionBehaviourList = new List <MissionBehaviour>
                {
                    new CommanderLogic(config),
                    new BattleSpawnLogic(isSallyOut
                        ? "sally_out_set"
                        : (isReliefForceAttack ? "relief_force_attack_set" : "battle_set")),
                    new MissionOptionsComponent(),
                    new BattleEndLogic(),
                    new MissionCombatantsLogic(null, playerParty,
                                               !isPlayerAttacker ? playerParty : enemyParty,
                                               isPlayerAttacker ? playerParty : enemyParty,
                                               !isSallyOut ? Mission.MissionTeamAITypeEnum.Siege : Mission.MissionTeamAITypeEnum.SallyOut,
                                               isPlayerSergeant),
                    new SiegeMissionPreparationHandler(isSallyOut, isReliefForceAttack, wallHitPointPercentages,
                                                       hasAnySiegeTower),
                    new MissionAgentSpawnLogic(troopSuppliers, playerSide),
                    new BattleObserverMissionLogic(),
                    new CustomBattleAgentLogic(),
                    new AgentBattleAILogic(),
                    new AmmoSupplyLogic(new List <BattleSideEnum> {
                        BattleSideEnum.Defender
                    }),
                    new AgentVictoryLogic(),
                    new MissionAgentPanicHandler(),
                    new SiegeMissionController(
                        attackerSiegeWeapons,
                        defenderSiegeWeapons,
                        isPlayerAttacker, isSallyOut),
                    new SiegeDeploymentHandler(isPlayerAttacker,
                                               isPlayerAttacker ? attackerSiegeWeapons : defenderSiegeWeapons),
                    new MissionBoundaryPlacer(),
                    new MissionBoundaryCrossingHandler(),
                    new AgentMoraleInteractionLogic(),
                    new HighlightsController(),
                    new BattleHighlightsController(),
                    new AssignPlayerRoleInTeamMissionController(isPlayerGeneral, isPlayerSergeant, hasPlayer, charactersInPlayerSideByPriority?.Select(character => character.StringId).ToList()),
                    new CreateBodyguardMissionBehavior(
                        isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                        !isPlayerAttacker ? playerTeamGeneralName : enemyTeamGeneralName,
                        null, null, false),
                };
                if (isSallyOut)
                {
                    missionBehaviourList.Add(new EnhancedBattleTestSiegeSallyOutMissionSpawnHandler(
                                                 isPlayerAttacker ? enemyParty : playerParty,
                                                 isPlayerAttacker ? playerParty : enemyParty));
                }
                else
                {
                    missionBehaviourList.Add(new EnhancedBattleTestSiegeMissionSpawnHandler(
                                                 isPlayerAttacker ? enemyParty : playerParty,
                                                 isPlayerAttacker ? playerParty : enemyParty));
                    missionBehaviourList.Add(new AgentFadeOutLogic());
                }
                return missionBehaviourList;
            }));
        }