Esempio n. 1
0
        protected void OutputForMovement(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            UnitMovementAttributes movement = entityTypeAttributes.Get <UnitMovementAttributes>();

            if (movement == null)
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");

                OutputForMovementAttributes(movement, true);
            }
        }
Esempio n. 2
0
 public UnitMovementAttributesWrapper(UnitMovementAttributes other)
 {
     DriveType = other.DriveType;
     Dynamics  = other.Dynamics;
     RandomDynamicsVariance = other.RandomDynamicsVariance;
     Maneuvers       = other.Maneuvers;
     Hover           = other.Hover;
     Combat          = other.Combat;
     Avoidance       = other.Avoidance;
     ReversePolarity = other.ReversePolarity;
 }
Esempio n. 3
0
        protected void OutputForGeneral(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");
                Print($"contact: {unitAttributes.ContactRadius}");
                Print($"xp: {unitAttributes.ExperienceValue}");
                Print($"priorityAsTarget: {unitAttributes.PriorityAsTarget}");

                // Movement Attributes
                UnitMovementAttributes movement = entityTypeAttributes.Get <UnitMovementAttributes>();
                if (movement != null)
                {
                    OutputForMovementAttributes(movement);
                }

                // Harvester Attributes
                HarvesterAttributes harvester = entityTypeAttributes.Get <HarvesterAttributes>();
                if (harvester != null)
                {
                    OutputForHarvesterAttributes(harvester);
                }

                // Weapons
                if (unitAttributes.WeaponLoadout.Length > 0 && (unitSetting.weapons == null || unitSetting.weapons.Length > 0))
                {
                    OutputForWeapons(entityTypeCollection, entityTypeAttributes, unitSetting.weapons);
                }
            }
        }
Esempio n. 4
0
        protected void OutputForMovementAttributes(UnitMovementAttributes movement, bool advanced = false)
        {
            using (BeginScope("movement"))
            {
                Print($"driveType: {movement.DriveType}");
                using (BeginScope("dynamics"))
                {
                    Print($"permanentlyImmobile: {movement.Dynamics.PermanentlyImmobile}");
                    Print($"minCruiseSpeed: {movement.Dynamics.MinCruiseSpeed}");
                    Print($"maxEaseIntoTurnTime: {movement.Dynamics.MaxEaseIntoTurnTime}");
                    Print($"maxSpeedTurnRadius: {movement.Dynamics.MaxSpeedTurnRadius}");
                    Print($"brakingTime: {movement.Dynamics.BrakingTime}");
                    Print($"accelerationTime: {movement.Dynamics.AccelerationTime}");
                    Print($"reverseFactor: {movement.Dynamics.ReverseFactor}");
                    Print($"maxSpeed: {movement.Dynamics.MaxSpeed}");
                    Print($"width: {movement.Dynamics.Width}");
                    Print($"length: {movement.Dynamics.Length}");
                    if (advanced)
                    {
                        Print($"driveType: {movement.Dynamics.DriveType}");
                        Print($"deathDriftTime: {movement.Dynamics.DeathDriftTime}");
                        Print($"maxDriftRecoverTime: {movement.Dynamics.MaxDriftRecoverTime}");
                        Print($"minDriftSlipSpeed: {movement.Dynamics.MinDriftSlipSpeed}");
                        Print($"fishTailControlRecover: {movement.Dynamics.FishTailControlRecover}");
                        Print($"fishTailingTimeIntervals: {movement.Dynamics.FishTailingTimeIntervals}");
                        Print($"driftOvershootFactor: {movement.Dynamics.DriftOvershootFactor}");
                        Print($"reverseDriftMultiplier: {movement.Dynamics.ReverseDriftMultiplier}");
                        Print($"driftType: {movement.Dynamics.DriftType}");
                    }

                    using (BeginScope("hover"))
                    {
                        Print($"turnAcceleration: {movement.Hover.TurnAcceleration}");
                        if (advanced)
                        {
                            Print($"turnMaxLookAheadTime: {movement.Hover.TurnMaxLookAheadTime}");
                            Print($"noTurnDistance: {movement.Hover.NoTurnDistance}");
                            Print($"faceTargetOnlyInCombat: {movement.Hover.FaceTargetOnlyInCombat}");
                            Print($"turnHeuristic: {movement.Hover.TurnHeuristic}");
                        }
                    }

                    using (BeginScope("combat"))
                    {
                        Print($"minDesiredCombatRange: {movement.Combat.MinDesiredCombatRange}");
                        Print($"maxDesiredCombatRange: {movement.Combat.MaxDesiredCombatRange}");
                        if (advanced)
                        {
                            Print($"passiveCombatApproachMode: {movement.Combat.PassiveCombatApproachMode}");
                            Print($"activeCombatApproachMode: {movement.Combat.ActiveCombatApproachMode}");
                            Print($"hoverStrafeCycleDuration: {movement.Combat.HoverStrafeCycleDuration}");
                            Print($"hoverStrafeLateralDisplacement: {movement.Combat.HoverStrafeLateralDisplacement}");
                            Print($"advanceThroughSmokeScreen: {movement.Combat.AdvanceThroughSmokeScreen}");
                        }
                    }

                    using (BeginScope("avoidance"))
                    {
                        Print($"avoidsCarriers: {movement.Avoidance.AvoidsCarriers}");
                        Print($"avoidsWrecks: {movement.Avoidance.AvoidsWrecks}");
                        Print($"avoidanceDistance: {movement.Avoidance.AvoidanceDistance}");
                    }

                    if (advanced)
                    {
                        using (BeginScope("reversePolarity"))
                        {
                            Print($"enabled: {movement.ReversePolarity.Enabled}");
                            Print($"relativeWeight: {movement.ReversePolarity.RelativeWeight}");
                            Print($"pushRadiusMultiplier: {movement.ReversePolarity.PushRadiusMultiplier}");
                            Print($"squishinessFactor: {movement.ReversePolarity.SquishinessFactor}");
                        }
                    }
                }
            }
        }
        // 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;
            }
        }