// Token: 0x0600141C RID: 5148
        internal void PostMapProcessInit()
        {
            if (this.mSimInitializationState != Sim.InitializationState.MapLoaded)
            {
                return;
            }
            SimMapDependencies mapDependencies;

            this.mSimStartupDependencies.Get <SimMapDependencies>(out mapDependencies);
            this.AIManager = new AIManager(this.SimEventSystem, this.CommanderManager.CPUCommanders);
            if (this.Settings.GameMode != null)
            {
                this.Settings.GameMode.Initialize();
            }
            SessionChangeReason sessionChangeReason;

            if (!this.mSimStartupDependencies.Get <SessionChangeReason>(out sessionChangeReason))
            {
                sessionChangeReason = SessionChangeReason.NewGame;
            }
            MissionDependencies missionDependencies;

            if (this.mSimStartupDependencies.Get <MissionDependencies>(out missionDependencies) && !missionDependencies.EntityDescriptors.IsNullOrEmpty <SceneEntityDescriptor>())
            {
                SceneEntityCreator.CreateSceneEntitiesForGameSession(missionDependencies.EntityGroupDescriptors, missionDependencies.EntityDescriptors, missionDependencies.RandomWreckArtifacts, missionDependencies.MaxSpawnedWreckArtifacts, sessionChangeReason == SessionChangeReason.Transition);
            }
            AllEntityProcessor.Initialize();
            if (sessionChangeReason != SessionChangeReason.LoadGame)
            {
                foreach (KeyValuePair <CommanderID, CommanderAttributes> keyValuePair in this.Settings.CommanderAttributesMap)
                {
                    Commander commanderFromID = Sim.Instance.CommanderManager.GetCommanderFromID(keyValuePair.Key);
                    if (commanderFromID != null)
                    {
                        this.InitializeResearchForCommander(commanderFromID);
                        this.ApplyInitialBuffsForCommander(commanderFromID, true);
                        this.GrantStartingGrantedAbilitiesForCommander(commanderFromID, true);
                        this.SpawnInitialUnitsForCommander(commanderFromID, this.Settings, mapDependencies);
                        commanderFromID.GrantStartingWreckArtifacts();
                    }
                }
            }
            // MOD
            MapModManager.LoadMapLayout();
            // MOD
            this.mSimInitializationState = Sim.InitializationState.Initialized;
        }
Ejemplo n.º 2
0
    // Run on every game tick
    // 1 is the first tick *I think*
    public static void Tick(BBI.Game.Commands.SimFrameNumber frameNumber)
    {
        lock (artUiLock) {
            FrameNumber = frameNumber.FrameNumber;

            if (CustomLayout)
            {
                // Checking if any artifacts need respawning
                if (frameNumber.FrameNumber >= 10u && (Sim.Instance.Settings.GameMode.GameSessionSettings.VictoryConditions & VictoryConditions.Retrieval) != 0)
                {
                    for (int i = 0; i < artifacts.Count; i++)
                    {
                        if (artifacts[i].NeedsRespawning)
                        {
                            Entity e = SceneEntityCreator.CreateCollectibleEntity("Artifact", CollectibleType.Artifact, artifacts[i].position, default(Orientation2));
                            artifacts[i] = new MapArtifactData {
                                entity   = e,
                                position = artifacts[i].position,
                            };
                        }
                    }
                }

                // Creating extraction zones (waiting till frame 10 until SExtractionZoneViewController is set)
                if (frameNumber.FrameNumber == 10u && (Sim.Instance.Settings.GameMode.GameSessionSettings.VictoryConditions & VictoryConditions.Retrieval) != 0)
                {
                    while (SExtractionZoneViewController == null)
                    {
                        ;                                                              // Spin wait for SExtractionZoneViewController to be set
                    }
                    // Hiding existing extraction zones
                    foreach (Entity entity in Sim.Instance.EntitySystem)
                    {
                        if (entity.HasComponent(14))
                        {
                            SExtractionZoneViewController.ShowExtractionZone(entity, false);
                        }
                    }

                    // Loading extraction zones
                    foreach (MapEzData ez in ezs)
                    {
                        ExtractionZoneDescriptor descriptorEz = new ExtractionZoneDescriptor("ExtractionZone", ez.position, default(Orientation2), new string[] { "G2-Zone2" }, new SceneExtractionZoneEntity(), new ExtractionZoneAttributesData {
                            m_RadiusMeters = ez.radius,
                            m_Query        = new QueryContainer {
                                UseEntityTypeQuery = true,
                                QEntityTypeNames   = new List <string>(new string[] {
                                    "C_Baserunner",
                                    "G_Baserunner",
                                    "C_Baserunner_MP",
                                    "G_Baserunner_MP",
                                    "C_Harvester_MP",
                                    "G_Harvester_MP",
                                    "C_Sob_Baserunner_MP",
                                    "K_Baserunner_MP",                                     // For some reason harvesters were in this array for other extraction zones so keeping them in just in case
                                })
                            }
                        }, ez.team);
                        // SceneEntityCreator.CreateEntityFromDescriptor(descriptorRelic, ref fgh); (doesn't work)

                        // Creating the extraction zone entity
                        int    artifactCount = 0;                      // Used for nothing
                        Entity entityEz      = SceneEntityCreator.CreateEntityFromDescriptor(descriptorEz, ref artifactCount);
                        SExtractionZoneViewController.OnSceneEntityCreated(new SceneEntityCreatedEvent(entityEz, descriptorEz));
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    // Loads a map layout onto a map
    // Map layouts include spawn, artifact, resource and extraction zone locations
    // This function also removes certain aspects of the level that are already there e.g. wrecks
    public static void LoadMapLayout()
    {
        // No map loaded anymore
        MapXml     = "";
        LayoutName = "";

        Subsystem.AttributeLoader.PatchOverrideData = "";
        PatchName = "";

        if (CustomLayout)
        {
            // Move DoK engine objects
            foreach (Entity entity in Sim.Instance.EntitySystem)
            {
                if (entity.HasComponent(11))
                {
                    entity.GetComponent <Position>(10).Position2D = new Vector2r(Fixed64.FromInt(1000000), Fixed64.FromInt(1000000)); // Move off the map
                    entity.GetComponent <Resource>(11).Disabled   = true;                                                             // Make unminable, keeping these in just in case the AI tries to mine from these resources
                }
                else if (entity.HasComponent(36) || entity.HasComponent(14))
                {
                    entity.GetComponent <Position>(10).Position2D = new Vector2r(Fixed64.FromInt(1000000), Fixed64.FromInt(1000000));                    // Move off the map
                }
            }

            // Disable the pesky black box at the start of levels
            // Its there to be a transition from what I can tell
            GameObject blackBox = GameObject.Find("BlackPolygon");
            if (blackBox != null)
            {
                blackBox.transform.position = new Vector3(1000000.0f, 1000000.0f, 1000000.0f);
            }

            // Loading resource layout
            foreach (MapResourceData resource in resources)
            {
                DetectableAttributesData detectableAttributesData = new DetectableAttributesData()
                {
                    m_SetHasBeenSeenBeforeOnSpawn = true,
                };
                SceneEntityCreator.CreateResourcePoint((resource.type == 0) ? "Resource_CU" : "Resource_RU", resource.position, default(Orientation2), new string[0], new ResourceAttributesData((ResourceType)resource.type, resource.amount, resource.collectors), detectableAttributesData, false, default(ResourcePositionalVariations), false);
            }

            // Delete starting units of commanders with no starting fleet
            foreach (MapSpawnData spawn in spawns)
            {
                if (spawn.fleet)
                {
                    continue;
                }
                foreach (Commander commander in Sim.Instance.CommanderManager.Commanders)
                {
                    CommanderDirectorAttributes director = Sim.Instance.CommanderManager.GetCommanderDirectorFromID(commander.ID);
                    if (director.PlayerType == PlayerType.AI)
                    {
                        continue;                                                           // AI needs starting carrier
                    }
                    if (((GameMode == TeamSetting.Team) ? (1 - spawn.team) * 3 : spawn.team) + spawn.index == director.SpawnIndex)
                    {
                        foreach (Entity entity in Sim.Instance.EntitySystem.Query().Has(2))                           // All units
                        {
                            if (entity.GetComponent <OwningCommander>(5).ID == commander.ID)                          // Check if the faction is correct
                            {
                                entity.GetComponent <Unit>(2).RetireDespawn();
                            }
                        }
                    }
                }
            }

            // Loading units
            foreach (MapUnitData unit in units)
            {
                // Convert team + index to commander ID then spawn unit
                foreach (Commander commander in Sim.Instance.CommanderManager.Commanders)
                {
                    CommanderDirectorAttributes director = Sim.Instance.CommanderManager.GetCommanderDirectorFromID(commander.ID);
                    if (((GameMode == TeamSetting.Team) ? (1 - unit.team) * 3 : unit.team) + unit.index == director.SpawnIndex)
                    {
                        if (commander.CommanderAttributes.Name == "SPECTATOR")
                        {
                            continue;                             // Don't spawn units for spectators
                        }
                        else if (sobanUnits.Contains(unit.type) && commander.CommanderAttributes.Faction.ID != FactionID.Soban)
                        {
                            continue;                             // Don't spawn Soban units for non Soban players
                        }
                        else if (khaanUnits.Contains(unit.type) && commander.CommanderAttributes.Faction.ID != FactionID.Khaaneph)
                        {
                            continue;                             // Don't spawn Khaaneph units for non Khaaneph players
                        }
                        SceneEntityCreator.CreateEntity(unit.type, commander.ID, unit.position, unit.orientation);
                        break;
                    }
                }
            }

            // Loading wrecks
            foreach (MapWreckData wreck in wrecks)
            {
                DetectableAttributesData detectableAttributes = new DetectableAttributesData {
                    m_SetHasBeenSeenBeforeOnSpawn = true,
                };

                ResourcePositionalVariations positions = new ResourcePositionalVariations {
                    ModelOrientationEulersDegrees = new Vector3r(Fixed64.FromConstFloat(0.0f), Fixed64.FromConstFloat(wreck.angle), Fixed64.FromConstFloat(0.0f)),
                };

                ShapeAttributesData shape = new ShapeAttributesData {
                    m_Radius           = 100.0f,
                    m_BlocksLOF        = wreck.blockLof,
                    m_BlocksAllHeights = wreck.blockLof,
                };

                ResourceAttributesData res = new ResourceAttributesData {
                    m_ResourceType = ResourceType.Resource3,                     // Type = Wreck
                };

                SimWreckSectionResourceSpawnableAttributesData[] childResources = new SimWreckSectionResourceSpawnableAttributesData[wreck.resources.Count];
                for (int i = 0; i < wreck.resources.Count; i++)
                {
                    childResources[i] = new SimWreckSectionResourceSpawnableAttributesData {
                        m_DetectableAttributes         = new DetectableAttributesData(),
                        m_OverrideDetectableAttributes = true,
                        m_Tags = new string[0],
                        m_EntityTypeToSpawn                     = (wreck.resources[i].type == 1) ? "Resource_RU" : "Resource_CU",
                        m_ResourceAttributes                    = new ResourceAttributesData((ResourceType)wreck.resources[i].type, wreck.resources[i].amount, wreck.resources[i].collectors),
                        m_OverrideResourceAttributes            = true,
                        m_SpawnPositionOffsetFromSectionCenterX = Fixed64.IntValue((wreck.resources[i].position - wreck.position).X),
                        m_SpawnPositionOffsetFromSectionCenterY = Fixed64.IntValue((wreck.resources[i].position - wreck.position).Y),
                        m_UseNonRandomSpawnPositionOffset       = true,
                    };
                }

                SimWreckAttributesData wreckData = new SimWreckAttributesData {
                    m_WreckSections = new SimWreckSectionAttributesData[] {
                        new SimWreckSectionAttributesData {
                            m_ExplosionChance    = 100,
                            m_Health             = 1,
                            m_ResourceSpawnables = childResources,
                        },
                    },
                };

                // Orientation2.LocalForward -> (1.0, 0.0)
                SceneEntityCreator.CreateWreck("Resource_Wreck_MP", wreck.position, Orientation2.LocalForward, new string[0], wreckData, "", shape, res, detectableAttributes, false, positions, false);
            }
        }
    }
Ejemplo n.º 4
0
 // Mono methods
 void Awake()
 {
     self = this;
 }