private void SwapEquipment(Agent agent, int loadout)
        {
            MWAXConfig      config          = new MWAXConfig();
            CharacterObject characterObject = Game.Current.ObjectManager.GetObject <CharacterObject>("weapon_practice_stage_" + config.MWAXWeaponStage() + "_" + this._settlement.MapFaction.Culture.StringId) ?? Game.Current.ObjectManager.GetObject <CharacterObject>("weapon_practice_stage_1_empire");

            for (int i = 0; i < 4; i++)
            {
                EquipmentElement equipmentFromSlot = characterObject.BattleEquipments.ToList <Equipment>()[loadout].GetEquipmentFromSlot((EquipmentIndex)i);
                agent.RemoveEquippedWeapon((EquipmentIndex)i);
                if (equipmentFromSlot.Item != null)
                {
                    MissionWeapon missionWeapon = new MissionWeapon(equipmentFromSlot.Item, agent.Origin?.Banner);
                    agent.EquipWeaponWithNewEntity((EquipmentIndex)i, ref missionWeapon);
                }
            }

            agent.WieldInitialWeapons();
        }
Exemplo n.º 2
0
        protected void AddLoadoutDialogues(CampaignGameStarter campaignGameStarter, Settlement settlement)
        {
            // Populate weapons list

            if (!visitedCultures.Contains(settlement.MapFaction.Culture))
            {
                MWAXConfig      config          = new MWAXConfig();
                CharacterObject characterObject = Game.Current.ObjectManager.GetObject <CharacterObject>("weapon_practice_stage_" + config.MWAXWeaponStage() + "_" + settlement.MapFaction.Culture.StringId);

                for (int i = 0; i < characterObject.BattleEquipments.Count <Equipment>(); i++)
                {
                    string[] dialogueIdArr   = new string[4];
                    string[] dialogueTextArr = new string[4];
                    string   dialogueId      = "mwax_arena_loadout_";
                    string   dialogueText    = "";
                    int      loadout         = i;

                    for (int x = 0; x < 4; x++)
                    {
                        EquipmentElement equipmentFromSlot = characterObject.BattleEquipments.ToList <Equipment>()[i].GetEquipmentFromSlot((EquipmentIndex)x);
                        if (equipmentFromSlot.Item != null)
                        {
                            dialogueIdArr[x]   = equipmentFromSlot.Item.StringId;
                            dialogueTextArr[x] = equipmentFromSlot.Item.Name.ToString();
                        }
                    }
                    dialogueId   = string.Join("_", dialogueIdArr.Where(s => !string.IsNullOrEmpty(s)));
                    dialogueText = string.Join(", ", dialogueTextArr.Where(s => !string.IsNullOrEmpty(s)));

                    campaignGameStarter.AddPlayerLine(dialogueId, "mwax_arena_weapons_list", "close_window", dialogueText, new ConversationSentence.OnConditionDelegate(() => this.MWAX_conversation_culture_match(settlement.MapFaction.Culture)), new ConversationSentence.OnConsequenceDelegate(() => this.MWAX_conversation_join_arena_with_selected_loadout(loadout)), 100, (ConversationSentence.OnClickableConditionDelegate)null, (ConversationSentence.OnPersuasionOptionDelegate)null);
                }

                visitedCultures.Add(settlement.MapFaction.Culture);

                // Return
                campaignGameStarter.AddPlayerLine("mwax_arena_return", "mwax_arena_weapons_list", "arena_master_enter_practice_fight", "{=mwax_arena_5}Actually, nevermind.", new ConversationSentence.OnConditionDelegate(() => this.MWAX_conversation_culture_match(settlement.MapFaction.Culture)), (ConversationSentence.OnConsequenceDelegate)null, 100, (ConversationSentence.OnClickableConditionDelegate)null, (ConversationSentence.OnPersuasionOptionDelegate)null);
            }
        }