public DeploymentPoint.DeploymentPointState GetDeploymentPointState() { switch (this._deploymentPointType) { case DeploymentPoint.DeploymentPointType.BatteringRam: return(!this.IsDeployed ? DeploymentPoint.DeploymentPointState.NotDeployed : DeploymentPoint.DeploymentPointState.BatteringRam); case DeploymentPoint.DeploymentPointType.TowerLadder: return(!this.IsDeployed ? DeploymentPoint.DeploymentPointState.SiegeLadder : DeploymentPoint.DeploymentPointState.SiegeTower); case DeploymentPoint.DeploymentPointType.Breach: return(DeploymentPoint.DeploymentPointState.Breach); case DeploymentPoint.DeploymentPointType.Ranged: return(!this.IsDeployed ? DeploymentPoint.DeploymentPointState.NotDeployed : DeploymentPoint.DeploymentPointState.Ranged); default: MBDebug.ShowWarning("Undefined deployment point type fetched."); return(DeploymentPoint.DeploymentPointState.NotDeployed); } }
private void ChangeTeamServer(NetworkCommunicator networkPeer, Team team) { MissionPeer component1 = networkPeer.GetComponent <MissionPeer>(); MissionPeer component2 = networkPeer.GetComponent <MissionPeer>(); Team team1 = component1.Team; if (team1 != null && team1 != this.Mission.SpectatorTeam && (team1 != team && component1.ControlledAgent != null)) { component1.ControlledAgent.Die(new Blow(component1.ControlledAgent.Index) { DamageType = DamageTypes.Invalid, BaseMagnitude = 10000f, Position = component1.ControlledAgent.Position }, Agent.KillInfo.Stone); } component1.Team = team; if (team != team1) { if (component2.HasSpawnedAgentVisuals) { component2.HasSpawnedAgentVisuals = false; MBDebug.Print("HasSpawnedAgentVisuals = false for peer: " + component2.Name + " because he just changed his team"); component2.SpawnCountThisRound = 0; Mission.Current.GetMissionBehaviour <MultiplayerMissionAgentVisualSpawnComponent>().RemoveAgentVisuals(component2, true); } if (!this._gameModeServer.IsGameModeHidingAllAgentVisuals && !networkPeer.IsServerPeer) { this._missionNetworkComponent?.OnPeerSelectedTeam(component1); } this._gameModeServer.OnPeerChangedTeam(networkPeer, team1, team); component2.SpawnTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission), 0.1f); component2.WantsToSpawnAsBot = false; component2.HasSpawnTimerExpired = false; } this.UpdateTeams(networkPeer, team1, team); }
public static void LogError(string msg) { DisplayInfoMsg(msg); Debugger.Log(3, nameof(NoDragonBannerTimeoutSubModule), msg + "\n"); MBDebug.ConsolePrint(msg); }
public override void OnPreMissionTick(float dt) { base.OnMissionTick(dt); if (!this.benchmarkStarted) { return; } this._totalTime += dt; Utilities.SetBenchmarkStatus(4, " Battle Size: " + (object)(this._attackerCavCount + this._attackerInfCount + this._attackerRangedCount) + " (" + (object)this.Mission.AttackerTeam.ActiveAgents.Count + ") vs (" + (object)this.Mission.DefenderTeam.ActiveAgents.Count + ") " + (object)(this._defenderCavCount + this._defenderInfCount)); if ((double)this.benchmark_exit != 0.0) { if ((double)this._totalTime - (double)this.benchmark_exit < 3.0) { MBDebug.RenderText(385f, 10f, "Hold 'ESC' to exit benchmark. " + (object)(float)(3.0 - ((double)this._totalTime - (double)this.benchmark_exit)), Colors.Red.ToUnsignedInteger()); } else { MBDebug.RenderText(10f, 10f, "Exiting benchmark in " + (object)(float)(9.0 - ((double)this._totalTime - (double)this.benchmark_exit)) + " sec.", Colors.Green.ToUnsignedInteger()); Utilities.SetBenchmarkStatus(2, ""); MouseManager.ShowCursor(true); this.benchmark_finished = true; } } else if (!this.benchmark_finished) { MBDebug.RenderText(385f, 10f, "Current Time:" + (object)this._totalTime); } if (Input.IsKeyPressed(InputKey.Escape) && (double)this.benchmark_exit == 0.0) { this.benchmark_exit = this._totalTime; } if (Input.IsKeyReleased(InputKey.Escape) && (double)this.benchmark_exit != 0.0 && (double)this._totalTime - (double)this.benchmark_exit < 3.0) { this.benchmark_exit = 0.0f; } if (!this._formationsSetUp && this._missionAgentSpawnLogic.IsInitialSpawnOver) { this.SetupFormations(); Utilities.SetBenchmarkStatus(1, ""); } if (this._formationsSetUp) { this.Check(); } if ((double)this._totalTime > 92.0) { Utilities.SetBenchmarkStatus(2, ""); MouseManager.ShowCursor(true); this.benchmark_finished = true; } if ((double)this.benchmark_exit != 0.0 && (double)this._totalTime - (double)this.benchmark_exit > 9.0) { Utilities.SetBenchmarkStatus(0, " Battle Size: " + (object)(this._attackerCavCount + this._attackerInfCount + this._attackerRangedCount) + " vs " + (object)(this._defenderCavCount + this._defenderInfCount)); Mission.Current.EndMission(); } if (!(ScreenManager.TopScreen is MissionScreen topScreen)) { return; } Camera combatCamera = topScreen.CombatCamera; if (!((NativeObject)combatCamera != (NativeObject)null) || this._curPath >= this._paths.Length) { return; } if ((NativeObject)this.benchmarkCamera == (NativeObject)null) { this.benchmarkCamera = Camera.CreateCamera(); this.benchmarkCamera.SetFovHorizontal(combatCamera.HorizontalFov, combatCamera.GetAspectRatio(), combatCamera.Near, combatCamera.Far); } if ((double)this._cameraPassedDistanceOnPath > (double)this._curPathLenght / 6.0 * 5.0) { this._cameraSpeed = MathF.Lerp(this._curPathSpeed, this._curPath != this._paths.Length - 1 ? (float)(((double)this._nextPathSpeed + (double)this._curPathSpeed) / 2.0) : 5f, (float)(((double)this._cameraPassedDistanceOnPath - (double)this._curPathLenght / 6.0 * 5.0) / ((double)this._curPathLenght / 6.0))); } if ((double)this._cameraPassedDistanceOnPath < (double)this._curPathLenght / 6.0) { this._cameraSpeed = MathF.Lerp(this._curPath != 0 ? (float)(((double)this._curPathSpeed + (double)this._prevPathSpeed) / 2.0) : 5f, this._curPathSpeed, this._cameraPassedDistanceOnPath / (this._curPathLenght / 6f)); } this._cameraPassedDistanceOnPath += this._cameraSpeed * dt; if ((double)this._cameraPassedDistanceOnPath >= (double)this._paths[this._curPath].GetTotalLength()) { if (this._curPath != this._paths.Length - 1) { ++this._curPath; this._curPathLenght = this._paths[this._curPath].GetTotalLength(); this._prevPathSpeed = this._curPathSpeed; this._curPathSpeed = this._nextPathSpeed; this._cameraPassedDistanceOnPath = this._cameraSpeed * dt; if (this._paths.Length > this._curPath + 1) { string name = this._paths[this._curPath + 1].GetName(); int num = name.LastIndexOf('_'); this._nextPathSpeed = float.Parse(name.Substring(num + 1)); } } else { Utilities.SetBenchmarkStatus(0, " Battle Size: " + (object)(this._attackerCavCount + this._attackerInfCount + this._attackerRangedCount) + " vs " + (object)(this._defenderCavCount + this._defenderInfCount)); Mission.Current.EndMission(); } } this.benchmarkCamera.LookAt(this._paths[this._curPath].GetFrameForDistance(Math.Min(this._paths[this._curPath].GetTotalLength(), this._cameraPassedDistanceOnPath)).origin, this._targets[this._curPath].GetFrameForDistance(Math.Min(1f, this._cameraPassedDistanceOnPath / this._paths[this._curPath].GetTotalLength()) * this._targets[this._curPath].GetTotalLength()).origin, Vec3.Up); topScreen.UpdateFreeCamera(this.benchmarkCamera.Frame); topScreen.CustomCamera = topScreen.CombatCamera; }
protected internal override void OnInit() { base.OnInit(); this.SetScriptComponentToTick(this.GetTickRequirement()); MBDebug.Print("AnimatedFlag : OnInit called.", color: Debug.DebugColor.Yellow); }
void IDebugManager.PrintWarning(string warning, ulong debugFilter) => MBDebug.Print(warning, debugFilter: debugFilter);
void IDebugManager.PrintError(string error, string stackTrace, ulong debugFilter) => MBDebug.Print(error, debugFilter: debugFilter);
void IDebugManager.ShowMessageBox(string lpText, string lpCaption, uint uType) => MBDebug.ShowMessageBox(lpText, lpCaption, uType);
void IDebugManager.ShowWarning(string message) => MBDebug.ShowWarning(message);
private void TickMission(float realDt) { if (this._firstMissionTickAfterLoading && this.CurrentMission != null && this.CurrentMission.CurrentState == Mission.State.Continuing) { if (GameNetwork.IsClient) { MBDebug.Print("Client: I finished loading. Sending confirmation to server.", debugFilter: 17179869184UL); GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new FinishedLoading()); GameNetwork.EndModuleEventAsClient(); GameNetwork.SyncRelevantGameOptionsToServer(); } this._firstMissionTickAfterLoading = false; } if (Game.Current.DeterministicMode) { Game.Current.ResetRandomGenerator(this._missionTickCount); } this.Handler?.BeforeMissionTick(this.CurrentMission, realDt); this.CurrentMission.PauseAITick = false; if (GameNetwork.IsSessionActive && (double)this.CurrentMission.ClearSceneTimerElapsedTime < 0.0) { this.CurrentMission.PauseAITick = true; } float dt = realDt; if (this.Paused || MBCommon.IsPaused) { dt = 0.0f; } else { if (this.CurrentMission.FixedDeltaTimeMode) { dt = this.CurrentMission.FixedDeltaTime; } if (this.CurrentMission.Scene.SlowMotionMode) { dt *= this.CurrentMission.Scene.SlowMotionFactor; } } if (!GameNetwork.IsSessionActive && NativeConfig.CheatMode) { if ((double)this.CurrentMission.TimeSpeedPeriod > 0.0) { float num = this.CurrentMission.TimeSpeedTimerElapsedTime / this.CurrentMission.TimeSpeedPeriod; if ((double)num >= 1.0) { this.CurrentMission.TimeSpeed = this.CurrentMission.TimeSpeedEnd; dt *= this.CurrentMission.TimeSpeed; this.CurrentMission.TimeSpeedPeriod = 0.0f; } else { dt *= (float)((double)this.CurrentMission.TimeSpeedEnd * (double)num + (double)this.CurrentMission.TimeSpeed * (1.0 - (double)num)); } } else { dt *= this.CurrentMission.TimeSpeed; } } if ((double)this.CurrentMission.ClearSceneTimerElapsedTime < -0.300000011920929 && !GameNetwork.IsClientOrReplay) { this.CurrentMission.ClearAgentActions(); } if (this.CurrentMission.CurrentState == Mission.State.Continuing || this.CurrentMission.MissionEnded()) { if (this.CurrentMission.IsFastForward) { float num = dt * 9f; while ((double)num > 9.99999997475243E-07) { if ((double)num > 0.100000001490116) { this.TickMissionAux(0.1f, 0.1f, false); if (this.CurrentMission.CurrentState != Mission.State.Over) { num -= 0.1f; } else { break; } } else { if ((double)num > 1.0 / 300.0) { this.TickMissionAux(num, num, false); } num = 0.0f; } } if (this.CurrentMission.CurrentState != Mission.State.Over) { this.TickMissionAux(dt, realDt, true); } } else { this.TickMissionAux(dt, realDt, true); } } if (this.Handler != null) { this.Handler.AfterMissionTick(this.CurrentMission, realDt); } ++this._missionTickCount; int num1 = Game.Current.DeterministicMode ? 1 : 0; }
protected override void StartMultiplayer() { MBDebug.Print("CUSTOM GAME SERVER ADDRESS: " + this._address); GameNetwork.StartMultiplayerOnClient(this._address, this._port, this._sessionKey, this._peerIndex); BannerlordNetwork.StartMultiplayerLobbyMission(LobbyMissionType.Custom); }
public static Mesh CreateBoundaryMesh( Scene scene, ICollection <Vec2> boundaryPoints, uint meshColor = 536918784) { if (boundaryPoints == null || boundaryPoints.Count < 3) { return((Mesh)null); } Mesh mesh = Mesh.CreateMesh(); UIntPtr num = mesh.LockEditDataWrite(); Vec3 min; Vec3 max; scene.GetBoundingBox(out min, out max); max.z += 50f; min.z -= 50f; for (int index = 0; index < boundaryPoints.Count; ++index) { Vec2 point1 = boundaryPoints.ElementAt <Vec2>(index); Vec2 point2 = boundaryPoints.ElementAt <Vec2>((index + 1) % boundaryPoints.Count); float height1 = 0.0f; float height2 = 0.0f; if (!scene.IsAtmosphereIndoor) { if (!scene.GetHeightAtPoint(point1, BodyFlags.CommonCollisionExcludeFlagsForCombat, ref height1)) { MBDebug.ShowWarning("GetHeightAtPoint failed at CreateBoundaryEntity!"); return((Mesh)null); } if (!scene.GetHeightAtPoint(point2, BodyFlags.CommonCollisionExcludeFlagsForCombat, ref height2)) { MBDebug.ShowWarning("GetHeightAtPoint failed at CreateBoundaryEntity!"); return((Mesh)null); } } else { height1 = min.z; height2 = min.z; } Vec3 vec3_1 = point1.ToVec3(height1); Vec3 vec3_2 = point2.ToVec3(height2); Vec3 vec3_3 = Vec3.Up * 2f; Vec3 vec3_4 = vec3_1; Vec3 vec3_5 = vec3_2; Vec3 vec3_6 = vec3_1; Vec3 vec3_7 = vec3_2; vec3_4.z = Math.Min(vec3_4.z, min.z); vec3_5.z = Math.Min(vec3_5.z, min.z); vec3_6.z = Math.Max(vec3_6.z, max.z); vec3_7.z = Math.Max(vec3_7.z, max.z); Vec3 p1 = vec3_4 - vec3_3; Vec3 p2 = vec3_5 - vec3_3; vec3_6 += vec3_3; Vec3 p3 = vec3_7 + vec3_3; mesh.AddTriangle(p1, p2, vec3_6, Vec2.Zero, Vec2.Side, Vec2.Forward, meshColor, num); mesh.AddTriangle(vec3_6, p2, p3, Vec2.Forward, Vec2.Side, Vec2.One, meshColor, num); } mesh.SetMaterial("editor_map_border"); mesh.VisibilityMask = VisibilityMaskFlags.Final | VisibilityMaskFlags.EditModeBorders; mesh.SetColorAlpha(150U); mesh.SetMeshRenderOrder(250); mesh.CullingMode = MBMeshCullingMode.None; float vectorArgument0 = 25f; if (MBEditor.IsEditModeOn && scene.IsEditorScene()) { vectorArgument0 = 100000f; } IEnumerable <GameEntity> entitiesWithTag = scene.FindEntitiesWithTag("walk_area_vertex"); float vectorArgument1 = entitiesWithTag.Count <GameEntity>() > 0 ? entitiesWithTag.Average <GameEntity>((Func <GameEntity, float>)(ent => ent.GlobalPosition.z)) : 0.0f; mesh.SetVectorArgument(vectorArgument0, vectorArgument1, 0.0f, 0.0f); mesh.ComputeNormals(); mesh.ComputeTangents(); mesh.RecomputeBoundingBox(); mesh.UnlockEditDataWrite(num); return(mesh); }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { Initialize(); Module.CurrentModule.GlobalTextManager.LoadGameTexts( ModuleHelper.GetXmlPath(ModuleId, "module_strings")); Module.CurrentModule.GlobalTextManager.LoadGameTexts( ModuleHelper.GetXmlPath(ModuleId, "MissionLibrary")); _successPatch = true; _harmony.Patch( typeof(Formation).GetMethod("LeaveDetachment", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod( typeof(Patch_Formation).GetMethod("LeaveDetachment_Prefix", BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(RangedSiegeWeaponView).GetMethod("HandleUserInput", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod( typeof(Patch_RangedSiegeWeaponView).GetMethod("HandleUserInput_Prefix", BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(CommonVillagersCampaignBehavior).GetMethod("CheckIfConversationAgentIsEscortingThePlayer", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod(typeof(Patch_CommonVillagersCampaignBehavior).GetMethod( "CheckIfConversationAgentIsEscortingThePlayer_Prefix", BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(ArenaPracticeFightMissionController).GetMethod("StartPractice", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod( typeof(Patch_ArenaPracticeFightMissionController).GetMethod("StartPractice_Prefix", BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(PassageUsePoint).GetMethod(nameof(PassageUsePoint.IsDisabledForAgent), BindingFlags.Instance | BindingFlags.Public), new HarmonyMethod(typeof(Patch_PassageUsePoint).GetMethod( nameof(Patch_PassageUsePoint.IsDisabledForAgent_Prefix), BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(TeamAIComponent).GetMethod("TickOccasionally", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod(typeof(Patch_TeamAIComponent).GetMethod( nameof(Patch_TeamAIComponent.TickOccasionally_Prefix), BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(MissionAgentLabelView).GetMethod("IsAllyInAllyTeam", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod(typeof(Patch_MissionAgentLabelView).GetMethod("IsAllyInAllyTeam_Prefix", BindingFlags.Static | BindingFlags.Public))); _harmony.Patch( typeof(MissionBoundaryCrossingHandler).GetMethod("TickForMainAgent", BindingFlags.Instance | BindingFlags.NonPublic), prefix: new HarmonyMethod( typeof(Patch_MissionBoundaryCrossingHandler).GetMethod("TickForMainAgent_Prefix", BindingFlags.Static | BindingFlags.Public))); var missionListenerOnMissionModeChange = typeof(IMissionListener).GetMethod("OnMissionModeChange", BindingFlags.Instance | BindingFlags.Public); var mapping = typeof(MissionScreen).GetInterfaceMap(missionListenerOnMissionModeChange.DeclaringType); var index = Array.IndexOf(mapping.InterfaceMethods, missionListenerOnMissionModeChange); _harmony.Patch( mapping.TargetMethods[index], prefix: new HarmonyMethod(typeof(Patch_MissionScreen).GetMethod("OnMissionModeChange_Prefix", BindingFlags.Static | BindingFlags.Public))); } catch (Exception e) { _successPatch = false; MBDebug.ConsolePrint(e.ToString()); } }
// Token: 0x060001BD RID: 445 RVA: 0x0000E03C File Offset: 0x0000C23C private GameEntity AddItem(Scene scene, ItemObject item, MatrixFrame itemFrame, MatrixFrame itemFrame1, MatrixFrame itemFrame2) { ItemRosterElement rosterElement = new ItemRosterElement(item, 0, null); MetaMesh itemMeshForInventory = rosterElement.GetItemMeshForInventory(false); if (item.IsCraftedWeapon) { MatrixFrame frame = itemMeshForInventory.Frame; frame.Elevate(-item.WeaponDesign.CraftedWeaponLength / 2f); itemMeshForInventory.Frame = frame; } GameEntity gameEntity = null; if (itemMeshForInventory != null && rosterElement.EquipmentElement.Item.ItemType == ItemObject.ItemTypeEnum.HandArmor) { gameEntity = GameEntity.CreateEmpty(scene, true); AnimationSystemData animationSystemData = Game.Current.HumanMonster.FillAnimationSystemData(MBGlobals.PlayerMaleActionSet, 1f, false); AgentVisualsNativeData agentVisualsNativeData = Game.Current.HumanMonster.FillAgentVisualsNativeData(); gameEntity.CreateSkeletonWithActionSet(ref agentVisualsNativeData, ref animationSystemData); gameEntity.SetFrame(ref itemFrame); gameEntity.Skeleton.SetAgentActionChannel(0, this.act_tableau_hand_armor_pose, 0f, -0.2f); gameEntity.AddMultiMeshToSkeleton(itemMeshForInventory); gameEntity.Skeleton.TickAnimationsAndForceUpdate(0.01f, itemFrame, true); } else if (itemMeshForInventory != null) { if (item.WeaponComponent != null) { WeaponClass weaponClass = item.WeaponComponent.PrimaryWeapon.WeaponClass; if (weaponClass == WeaponClass.ThrowingAxe || weaponClass == WeaponClass.ThrowingKnife || weaponClass == WeaponClass.Javelin || weaponClass == WeaponClass.Bolt) { gameEntity = GameEntity.CreateEmpty(scene, true); MetaMesh metaMesh = itemMeshForInventory.CreateCopy(); metaMesh.Frame = itemFrame; gameEntity.AddMultiMesh(metaMesh, true); MetaMesh metaMesh2 = itemMeshForInventory.CreateCopy(); metaMesh2.Frame = itemFrame1; gameEntity.AddMultiMesh(metaMesh2, true); MetaMesh metaMesh3 = itemMeshForInventory.CreateCopy(); metaMesh3.Frame = itemFrame2; gameEntity.AddMultiMesh(metaMesh3, true); } else { gameEntity = scene.AddItemEntity(ref itemFrame, itemMeshForInventory); } } else { gameEntity = scene.AddItemEntity(ref itemFrame, itemMeshForInventory); if (item.Type == ItemObject.ItemTypeEnum.HorseHarness && item.ArmorComponent != null) { MetaMesh copy = MetaMesh.GetCopy(item.ArmorComponent.ReinsMesh, true, true); if (copy != null) { gameEntity.AddMultiMesh(copy, true); } } } } else { MBDebug.ShowWarning("[DEBUG]Item with " + rosterElement.EquipmentElement.Item.StringId + "[DEBUG] string id cannot be found"); } gameEntity.SetVisibilityExcludeParents(false); return gameEntity; }
public void SetCharacter(BasicCharacterObject character) { this.Character = character; Game.Current.LastFaceEditedCharacter = character; MBDebug.Print("FaceGen set character> character face key: " + (object)character.GetBodyProperties(character.Equipment)); }