- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TaleWorlds.Core;
- using TaleWorlds.GauntletUI;
- using TaleWorlds.Library;
- using TaleWorlds.MountAndBlade;
- using TaleWorlds.MountAndBlade.GauntletUI;
- using TaleWorlds.MountAndBlade.GauntletUI.Mission;
- using TaleWorlds.MountAndBlade.GauntletUI.Widgets.Mission;
- using TaleWorlds.MountAndBlade.View.MissionViews;
- using TaleWorlds.MountAndBlade.View;
- using TaleWorlds.ScreenSystem;
- using TaleWorlds.MountAndBlade.ViewModelCollection;
- using TaleWorlds.Engine.GauntletUI;
- using TaleWorlds.Engine;
- namespace WoW
- {
- [OverrideView(typeof(WoW_MissionAgentStatusUIHandler))]
- internal class WoW_MainAgentStatus : MissionGauntletBattleUIBase
- {
- private WoW_MainAgentStatusVM _dataSource;
- private GauntletLayer _gauntletLayer;
- protected override void OnCreateView()
- {
- this._dataSource = new WoW_MainAgentStatusVM(base.Mission, base.MissionScreen.CombatCamera, new Func<float>(base.MissionScreen.GetCameraToggleProgress));
- this._gauntletLayer = new GauntletLayer(this.ViewOrderPriority, "GauntletLayer", false);
- this._gauntletLayer.LoadMovie("WoW_AgentStatus", this._dataSource);
- base.MissionScreen.AddLayer(this._gauntletLayer);
- }
- protected override void OnDestroyView()
- {
- MissionScreen.RemoveLayer(this._gauntletLayer);
- _dataSource = null;
- _gauntletLayer = null;
- }
- public override void OnMissionScreenTick(float dt)
- {
- base.OnMissionScreenTick(dt);
- if (_dataSource != null)
- _dataSource?.UpdateAgentStatuses();
- }
- }
- public class WoW_MainAgentStatusVM : ViewModel
- {
- private Mission mission;
- private Camera combatCamera;
- private Func<float> func;
- private int _Stamina;
- private int _Mana;
- private int _Time;
- private int _ClipRemaininAmmunition;
- private int _Clip;
- private float _spellChargeDur;
- public bool IsInDeployement { get; set; }
- public WoW_MainAgentStatusVM(Mission mission, Camera combatCamera, Func<float> func)
- {
- this.mission = mission;
- this.combatCamera = combatCamera;
- this.func = func;
- }
- [DataSourceProperty]
- public int Stamina
- {
- get
- {
- return this._Stamina;
- }
- set
- {
- if (value != this._Stamina)
- {
- this._Stamina = value;
- base.OnPropertyChangedWithValue(value, "Stamina");
- }
- }
- }
- [DataSourceProperty]
- public int Mana
- {
- get
- {
- return this._Mana;
- }
- set
- {
- if (value != this._Mana)
- {
- this._Mana = value;
- base.OnPropertyChangedWithValue(value, "Mana");
- }
- }
- }
- [DataSourceProperty]
- public int Time
- {
- get
- {
- return this._Time;
- }
- set
- {
- if (value != this._Time)
- {
- this._Time = value;
- base.OnPropertyChangedWithValue(value, "Time");
- }
- }
- }
- [DataSourceProperty]
- public int ClipRemaininAmmunition
- {
- get
- {
- return this._ClipRemaininAmmunition;
- }
- set
- {
- if (value != this._ClipRemaininAmmunition)
- {
- this._ClipRemaininAmmunition = value;
- base.OnPropertyChangedWithValue(value, "ClipRemaininAmmunition");
- }
- }
- }
- [DataSourceProperty]
- public int Clip
- {
- get
- {
- return this._Clip;
- }
- set
- {
- if (value != this._Clip)
- {
- this._Clip = value;
- base.OnPropertyChangedWithValue(value, "Clip");
- }
- }
- }
- [DataSourceProperty]
- public float SpellChargeDur
- {
- get
- {
- return this._spellChargeDur;
- }
- set
- {
- if (value != this._spellChargeDur)
- {
- this._spellChargeDur = value;
- base.OnPropertyChangedWithValue(value, "SpellChargeDur");
- }
- }
- }
- internal void UpdateAgentStatuses()
- {
- if (this.mission != null && this.mission.MainAgent == null)
- {
- this._Stamina = 0;
- this._Mana = 0;
- this._Clip = 0;
- this._ClipRemaininAmmunition = 0;
- SpellChargeDur = 0;
- return;
- }
- if (this.mission != null && WoW_MissionSetting.WoW_Agents.TryGetValue(mission.MainAgent.Index, out var MainAgent))
- {
- this.Stamina = (int)MainAgent.Stamina;
- this.Mana = (int)MainAgent.Mana;
- this.SpellChargeDur = MainAgent.SpellChargeDur;
- this.Clip = MainAgent.Clip;
- this.ClipRemaininAmmunition = MainAgent.ClipRemaininAmmunition;
- }
- }
- }
- public class WoW_MissionAgentStatusUIHandler : MissionAgentStatusUIHandlerBase
- {
- // Token: 0x06000329 RID: 809 RVA: 0x0001C138 File Offset: 0x0001A338
- public override void HideUI()
- {
- }
- // Token: 0x0600032A RID: 810 RVA: 0x0001C13A File Offset: 0x0001A33A
- public override void ShowUI()
- {
- }
- }
- }
复制代码
- using HarmonyLib;
- using SandBox.GameComponents;
- using System;
- using System.Reflection;
- using System.Xml.Linq;
- using TaleWorlds.CampaignSystem;
- using TaleWorlds.Core;
- using TaleWorlds.MountAndBlade;
- using TaleWorlds.MountAndBlade.CustomBattle;
- using TaleWorlds.MountAndBlade.View;
- using TaleWorlds.MountAndBlade.View.MissionViews;
- using TaleWorlds.MountAndBlade.View.Screens;
- using TaleWorlds.ObjectSystem;
- using TaleWorlds.ScreenSystem;
- namespace WoW
- {
- public class SubModule : MBSubModuleBase
- {
- protected override void OnSubModuleLoad()
- {
- base.OnSubModuleLoad();
- }
- protected override void OnSubModuleUnloaded()
- {
- base.OnSubModuleUnloaded();
- }
- protected override void OnBeforeInitialModuleScreenSetAsRoot()
- {
- base.OnBeforeInitialModuleScreenSetAsRoot();
- }
- public override void OnMissionBehaviorInitialize(Mission mission)
- {
- base.OnMissionBehaviorInitialize(mission);
- mission.AddMissionBehavior(new WoW_MissionSetting());
- mission.AddMissionBehavior(new WoW_MainAgentStatus());
- MissionScreen missionScreen = ScreenManager.TopScreen as MissionScreen;
- missionScreen.AddMissionView(ViewCreatorManager.CreateMissionView<WoW_MissionAgentStatusUIHandler>(mission != null, mission, Array.Empty<object>()));
- }
- public override void OnAfterGameInitializationFinished(Game game, object starterObject)
- {
- base.OnAfterGameInitializationFinished(game, starterObject);
- ExtendedData extendedData = new ExtendedData();
- // 确定游戏模式是战役模式
- if (game.GameType is Campaign)
- {
- // 访问所有角色的集合
- var characters = Campaign.Current.Characters;
- // 在这里你可以遍历或查询characters
- extendedData.CreateOrRetrieveMyDataForCharacter();
- extendedData.InitializeCharacterData(characters);
- }
- }
- protected override void InitializeGameStarter(Game game, IGameStarter gameStarterObject)
- {
- ExtendedData extendedData = new ExtendedData();
- //默认使用的代码
- extendedData.CreateOrRetrieveDataForGun();
- gameStarterObject.AddModel(new WOW_DefaultStrikeMagnitudeModel());
- gameStarterObject.AddModel(new WOW_CustomBattleAgentStatCalculateModel());
- gameStarterObject.AddModel(new WOW_CustomAgentApplyDamageModel());
- gameStarterObject.AddModel(new WOW_DefaultRidingModel());
- gameStarterObject.AddModel(new WOW_DefaultPartySpeedCalculatingModel());
- new Harmony("WoW").PatchAll(Assembly.GetExecutingAssembly());
- if (game.GameType is Campaign)
- {
- //战役里使用的代码
- gameStarterObject.AddModel(new WoW_DefaultClanTierModel());
- gameStarterObject.AddModel(new WOW_SandboxAgentApplyDamageModel());
- gameStarterObject.AddModel(new WOW_SandboxStrikeMagnitudeModel());
- gameStarterObject.AddModel(new WOW_SandboxAgentStatCalculateModel());
- }
- }
- }
- }
复制代码
|