// Token: 0x06000C55 RID: 3157 RVA: 0x00056FE4 File Offset: 0x000551E4 private void UpdateDynamicDataForUnit(Entity entity) { UnitState unitState = ShipbreakersMain.CurrentSimFrame.FindObject <UnitState>(entity); if (unitState == null) { return; } if (this.mSelectedEntity.IsValid()) { if (this.mLastUnitState == unitState) { return; } if (this.mSettings.UnitHealthValueLabel == null || this.mSettings.UnitHealthBar == null || this.mSettings.UnitArmorValueLabel == null || this.mSettings.UnitFireRateLabel == null || this.mSettings.UnitDamageValueLabel == null || this.mSettings.SpeedValueLabel == null || this.mSettings.UnitShortDescriptionValueLabel == null) { Log.Warn(Log.Channel.UI, "Information Panel: An information label was not configured correctly. Check Unity Config. Skipping Info Panel Update", new object[0]); return; } string typeID = unitState.TypeID; bool flag = this.mLastUnitState == null || this.mLastUnitState.EntityID != this.mSelectedEntity; ExperienceViewAttributes entityTypeAttributes = ShipbreakersMain.GetEntityTypeAttributes <ExperienceViewAttributes>(typeID); if (entityTypeAttributes != null) { ExperienceState experienceState = ShipbreakersMain.CurrentSimFrame.FindObject <ExperienceState>(entity); if (experienceState != null && experienceState.Level > 0 && (flag || this.mLastExperienceState == null || this.mLastExperienceState.Level != experienceState.Level)) { if (!string.IsNullOrEmpty(experienceState.NameSuffix)) { RankViewAttributes rankViewAttributes = entityTypeAttributes.RankViews[experienceState.Level]; this.mTempLocalizationFormatObjects[0] = rankViewAttributes.ShortRankName; this.mTempLocalizationFormatObjects[1] = experienceState.NameSuffix; this.mSettings.UnitShortDescriptionValueLabel.text = this.mSettings.UnitLevelFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan); } this.mLastExperienceState = experienceState; } } if (flag || unitState.OwnerCommander != this.mLastUnitState.OwnerCommander) { Commander commanderFromID = this.mCommanderManager.GetCommanderFromID(unitState.OwnerCommander); CommanderDirectorAttributes commanderDirectorFromID = this.mCommanderManager.GetCommanderDirectorFromID(unitState.OwnerCommander); this.mTempLocalizationFormatObjects[0] = ((commanderFromID != null) ? SharedLocIDConstants.GetLocalizedCommanderName(commanderDirectorFromID.PlayerType, commanderFromID.Name, commanderDirectorFromID.AIDifficulty) : string.Empty); this.mTempLocalizationFormatObjects[1] = null; this.mSettings.PlayerNameLabel.text = this.mSettings.PlayerNameLocID.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan); } UnitAttributes typeAttributes = this.mSelectedEntity.GetTypeAttributes <UnitAttributes>(); if (typeAttributes == null) { Log.Warn(Log.Channel.UI, "Information Panel: Attribute data was missing for unit type {0}. Skipping info panel update", new object[] { this.mSelectedEntity.ToFriendlyString() }); return; } UnitAttributes entityTypeAttributes2 = ShipbreakersMain.GetEntityTypeAttributes <UnitAttributes>(typeID); if (entityTypeAttributes2 == null) { Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base UnitAttributes for entity type {0}", new object[] { typeID }); } if (flag || unitState.Hitpoints != this.mLastUnitState.Hitpoints) { this.mTempLocalizationFormatObjects[0] = unitState.Hitpoints; this.mTempLocalizationFormatObjects[1] = unitState.MaxHitpoints; this.mSettings.UnitHealthValueLabel.text = ((unitState.MaxHitpoints > 0) ? this.mSettings.UnitHealthFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan) : string.Empty); this.mSettings.UnitHealthBar.value = ((unitState.MaxHitpoints > 0) ? ((float)unitState.Hitpoints / (float)unitState.MaxHitpoints) : 0f); int buffComparison = 0; if (entityTypeAttributes2 != null) { buffComparison = unitState.MaxHitpoints.CompareTo(entityTypeAttributes2.MaxHealth); } this.mSettings.UnitHealthValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison); } this.mSelectedEntity.GetTypeAttributes <UnitMovementAttributes>(); int num = Fixed64.IntValue(unitState.MaxSpeed); if (flag || num != Fixed64.IntValue(this.mLastUnitState.MaxSpeed)) { this.mTempLocalizationFormatObjects[0] = num; this.mTempLocalizationFormatObjects[1] = null; this.mSettings.SpeedValueLabel.text = this.mSettings.UnitSpeedFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan); int buffComparison2 = 0; UnitMovementAttributes entityTypeAttributes3 = ShipbreakersMain.GetEntityTypeAttributes <UnitMovementAttributes>(typeID); UnitDynamicsAttributes unitDynamicsAttributes = (entityTypeAttributes3 != null) ? entityTypeAttributes3.Dynamics : null; if (unitDynamicsAttributes != null) { buffComparison2 = unitState.MaxSpeed.CompareTo(unitDynamicsAttributes.MaxSpeed); } else { Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base UnitDynamicsAttributes for entity type {0}", new object[] { typeID }); } this.mSettings.SpeedValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison2); } int buffComparison3 = 0; // MOD int baseDamagePerRound = 0; int damagePacketsPerShot = 1; // MOD if (!typeAttributes.WeaponLoadout.IsNullOrEmpty <WeaponBinding>()) { WeaponBinding weaponBinding = typeAttributes.WeaponLoadout[0]; if (weaponBinding != null) { // MOD damagePacketsPerShot = weaponBinding.Weapon.DamagePacketsPerShot; baseDamagePerRound = Fixed64.IntValue(weaponBinding.Weapon.BaseDamagePerRound); WeaponAttributes entityTypeAttributes4 = ShipbreakersMain.GetEntityTypeAttributes <WeaponAttributes>(typeID, weaponBinding.Weapon.Name); if (entityTypeAttributes4 != null) { buffComparison3 = baseDamagePerRound.CompareTo(Fixed64.IntValue(entityTypeAttributes4.BaseDamagePerRound)); } else { Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base WeaponAttributes with name {0} for entity type {1}", new object[] { weaponBinding.Weapon.Name, typeID }); } // MOD } else { Log.Error(Log.Channel.Data | Log.Channel.UI, "First WeaponBinding in WeaponLoadout for unit type {0} is null! Unable to determine damage to show on info panel", new object[] { typeID }); } } // MOD if (flag || this.mLastWeaponDamageValue != baseDamagePerRound || this.mLastWeaponPacketsValue != damagePacketsPerShot) { this.mSettings.UnitDamageValueLabel.text = damagePacketsPerShot != 1 ? string.Format("{0} | {1}", baseDamagePerRound, damagePacketsPerShot) : string.Format("{0}", baseDamagePerRound); this.mLastWeaponDamageValue = baseDamagePerRound; this.mLastWeaponPacketsValue = damagePacketsPerShot; this.mSettings.UnitDamageValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison3); } // MOD if (flag || this.mLastUnitArmourValue != typeAttributes.Armour) { this.mTempLocalizationFormatObjects[0] = typeAttributes.Armour; this.mTempLocalizationFormatObjects[1] = null; this.mSettings.UnitArmorValueLabel.text = this.mSettings.UnitArmorFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan); this.mLastUnitArmourValue = typeAttributes.Armour; int buffComparison4 = 0; if (entityTypeAttributes2 != null) { buffComparison4 = typeAttributes.Armour.CompareTo(entityTypeAttributes2.Armour); } this.mSettings.UnitArmorValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison4); } if (flag || this.mLastFireRateDisplay != typeAttributes.FireRateDisplay) { this.mTempLocalizationFormatObjects[0] = InformationPanelController.InformationPanelSettings.FireRateLocIDs[typeAttributes.FireRateDisplay]; this.mTempLocalizationFormatObjects[1] = null; this.mSettings.UnitFireRateLabel.text = this.mSettings.UnitFireRateFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan); this.mLastFireRateDisplay = typeAttributes.FireRateDisplay; int buffComparison5 = 0; if (entityTypeAttributes2 != null) { buffComparison5 = typeAttributes.FireRateDisplay.CompareTo(entityTypeAttributes2.FireRateDisplay); } this.mSettings.UnitFireRateLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison5); } this.mLastUnitState = unitState; } }
// Token: 0x0600197B RID: 6523 public HUDMapController(HUDMapControllerAsset settings, SimMapDependencies mapDependencies, UserCamera camera, ICommandScheduler simScheduler, bool showBoundariesGame, bool showBoundariesSensors) { this.mHUDEnabled = true; this.mFOWSimEnabled = true; this.mFOWRenderEnabled = true; this.mBoundsEnabled = true; this.mDefaultFOWVolumeBuffer = new CommandBuffer(); this.mFoWCubeMeshTransform = Matrix4x4.identity; this.mSimScheduler = simScheduler; this.mMainCamera = camera.ActiveCamera; this.mFogBuffers = new Dictionary <HUDMapController.RenderModeType, CommandBuffer>(2, HUDMapController.sRenderModeTypeComparer); this.mBoundsEnabledForLevelGame = showBoundariesGame; this.mBoundsEnabledForLevelSensors = showBoundariesSensors; this.mSettings = settings; if (this.mSettings != null) { if (mapDependencies != null) { Vector3 min = VectorHelper.SimVector2ToUnityVector3(mapDependencies.MinPathfindingBounds, -5000f); Vector3 max = VectorHelper.SimVector2ToUnityVector3(mapDependencies.MaxPathfindingBounds, 5000f); // MOD: fix sensors on non square maps float s = Math.Max(max.x - min.x, max.z - min.z); max.x = min.x + s; max.z = min.z + s; // MOD this.mMapBounds = default(Bounds); this.mMapBounds.SetMinMax(min, max); this.mFOWCamera = HUDMapController.InstantiateFOWCamera(settings.FOWCameraPrefab, this.mMapBounds, ShipbreakersMain.GetDynamicRoot(ShipbreakersMain.DynamicRootIndex.Misc)); if (this.mMainCamera != null && this.mFOWCamera != null) { if (this.mFOWCamera.targetTexture != null) { Log.Error(Log.Channel.Graphics, "RenderTexture asset incorrectly set as target for FoW camera, discarding!", new object[0]); this.mFOWCamera.targetTexture.Release(); } this.mFOWTexture = HUDMapController.CreateFOWRenderTexture(this.mMapBounds); this.mBlurMaterial = new Material(settings.FOWBlurShader); this.mFOWCamera.targetTexture = this.mFOWTexture; this.mFOWCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, HUDMapController.CreateFOWBlurCmdBuffer(this.mBlurMaterial, this.mFOWTexture)); this.mFOWMaterial = new Material(settings.FOWMaterial); this.mFOWMaterial.SetTexture("_MainTex", this.mFOWTexture); Vector3 size = Vector3.one * 5000f + this.mMapBounds.size; GameObject gameObject = HUDMapController.InstantiateFOWVolume(new Bounds(this.mMapBounds.center, size)); this.mFoWCubeMesh = gameObject.GetComponent <MeshFilter>().mesh; this.mFoWCubeMeshTransform = gameObject.transform.localToWorldMatrix; HUDMapController.RebuildFOWVolumeCmdBuffer(this.mDefaultFOWVolumeBuffer, this.mFoWCubeMesh, this.mFoWCubeMeshTransform, this.mFOWMaterial, "FOW Combine (Default)"); this.mFogBuffers.Add(HUDMapController.RenderModeType.Default, this.mDefaultFOWVolumeBuffer); UnityEngine.Object.Destroy(gameObject); this.CreateMapBoundsBuffers(settings); this.SetMode(HUDMapController.RenderModeType.Default); this.mAnimFade = new FloatAnimFadeInOut(null, 1f, 1f, 0f); this.mAnimFade.FadeOutCallback = new Action(this.OnAnimFadeOut); this.mAnimFade.Value = 1f; ShipbreakersMain.PresentationEventSystem.AddHandler <SensorsManagerEvent>(new BBI.Core.Events.EventHandler <SensorsManagerEvent>(this.OnSensorsManagerEvent)); ShipbreakersMain.PresentationEventSystem.AddHandler <HUDMapToggleEvent>(new BBI.Core.Events.EventHandler <HUDMapToggleEvent>(this.OnHUDMapToggleEvent)); ShipbreakersMain.PresentationEventSystem.AddHandler <HUDMapSettingsEvent>(new BBI.Core.Events.EventHandler <HUDMapSettingsEvent>(this.OnHUDMapSettingsEvent)); ShipbreakersMain.PresentationEventSystem.AddHandler <QualitySettingsChangedEvent>(new BBI.Core.Events.EventHandler <QualitySettingsChangedEvent>(this.OnQualitySettingsChanged)); ShipbreakersMain.PresentationEventSystem.AddHandler <TacticalOverlayToggleEvent>(new BBI.Core.Events.EventHandler <TacticalOverlayToggleEvent>(this.OnTacticalOverlayToggleEvent)); ShipbreakersMain.SimToPresentationEventSystem.AddHandler <MatchGameOverEvent>(new BBI.Core.Events.EventHandler <MatchGameOverEvent>(this.OnMatchGameOverEvent)); ShipbreakersMain.SimToPresentationEventSystem.AddHandler <ReplayCompleteEvent>(new BBI.Core.Events.EventHandler <ReplayCompleteEvent>(this.OnReplayCompleteEvent)); } else { Log.Error(Log.Channel.Graphics, "Cannot find child Camera for provided UserCamera", new object[] { camera }); } DecalSystem.sFOWCamera = this.mFOWCamera; return; } Log.Error(Log.Channel.Graphics, "[FogOfWar] - Cannot initialize Presentaiton side FoW for level! Make sure it contains a SetRenderSettings and has particle occlusion baked!", new object[0]); } }
// Token: 0x06000C54 RID: 3156 RVA: 0x00056D54 File Offset: 0x00054F54 private void PopulatePanelForUnit(Entity entity) { string typeName = entity.GetTypeName(); if (string.IsNullOrEmpty(typeName)) { return; } UnitHUDAttributes entityTypeAttributes = ShipbreakersMain.GetEntityTypeAttributes <UnitHUDAttributes>(typeName); if (entityTypeAttributes == null) { Log.Error(Log.Channel.UI, "Unable to get HUD attributes for entity {0}", new object[] { entity.ToFriendlyString() }); } this.mSettings.UnitNameLabel.text = this.mSettings.UnitNameLocID.TokenFormat(new object[] { (entityTypeAttributes == null) ? typeName : entityTypeAttributes.UnitLocalizedNameStringID }, this.mLocMan); if (this.mSettings.UnitIcon != null) { this.mSettings.UnitIcon.spriteName = ((entityTypeAttributes == null) ? string.Empty : entityTypeAttributes.IconSettings.UnitInfoPanelIconName); } else { Log.Warn(Log.Channel.UI, "Unit Icon is missing from the info panel.", new object[0]); } if (this.mSettings.UnitShortDescriptionValueLabel != null) { this.mLastExperienceState = null; this.mSettings.UnitShortDescriptionValueLabel.text = this.mSettings.UnitNameLocID.TokenFormat(new object[] { (entityTypeAttributes == null) ? string.Empty : entityTypeAttributes.UnitLocalizedShortDescriptionStringID }, this.mLocMan); } else { Log.Warn(Log.Channel.UI, "ShortDescription Value Label is missing from the info panel.", new object[0]); } if (this.mSettings.UnitHealthBar != null && this.mInteractionProvider != null && this.mInteractionProvider != null) { SimStateFrame currentSimFrame = ShipbreakersMain.CurrentSimFrame; UnitState unitState = currentSimFrame.FindObject <UnitState>(entity); CommanderRelationship relationship = this.mInteractionProvider.GetRelationship(unitState.OwnerCommander, this.mCommanderManager.LocalCommanderID); if (relationship != CommanderRelationship.Ally) { if (relationship != CommanderRelationship.Enemy) { this.mSettings.UnitHealthBar.foregroundWidget.color = this.mUnitInteractionAttributes.PlayerIconColours.SelectedColour; } else { this.mSettings.UnitHealthBar.foregroundWidget.color = this.mUnitInteractionAttributes.EnemyIconColours.SelectedColour; } } else { this.mSettings.UnitHealthBar.foregroundWidget.color = this.mUnitInteractionAttributes.AllyIconColours.SelectedColour; } } if (this.mSettings.UnitLongDescriptionValueLabel != null) { this.mSettings.UnitLongDescriptionValueLabel.text = this.mSettings.UnitNameLocID.TokenFormat(new object[] { (entityTypeAttributes == null) ? string.Empty : entityTypeAttributes.UnitLocalizedLongDescriptionStringID }, this.mLocMan); } else { Log.Warn(Log.Channel.UI, "LongDescription Value Label is missing from the info panel.", new object[0]); } this.mSelectedEntity = entity; this.UpdateDynamicDataForUnit(entity); }