Skip to content

Commit

Permalink
Replacing self:GetBlueprint()
Browse files Browse the repository at this point in the history
`self:GetBlueprint()` > `self.Blueprint`
  • Loading branch information
MrRowey committed Dec 18, 2024
1 parent 508885d commit f21b665
Show file tree
Hide file tree
Showing 47 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion effects/Entities/SCUDeath01/SCUDeath01_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SCUDeath01 = Class(NullShell) {
---@param self SCUDeath01
OnCreate = function(self)
NullShell.OnCreate(self)
local myBlueprint = self:GetBlueprint()
local myBlueprint = self.Blueprint

-- Play the "NukeExplosion" sound
if myBlueprint.Audio.NukeExplosion then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ UEFNukeEffect01 = Class(NullShell) {

---@param self UEFNukeEffect01
EffectThread = function(self)
local scale = self:GetBlueprint().Display.UniformScale
local scale = self.Blueprint.Display.UniformScale
local scaleChange = 0.30 * scale

self:SetScaleVelocity(scaleChange,scaleChange,scaleChange)
Expand Down
12 changes: 6 additions & 6 deletions lua/RemoteViewing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function RemoteViewing(SuperClass)
end,

OnStopBeingBuilt = function(self,builder,layer)
self.Sync.Abilities = self:GetBlueprint().Abilities
self.Sync.Abilities = self.Blueprint.Abilities
self:SetMaintenanceConsumptionInactive()
SuperClass.OnStopBeingBuilt(self,builder,layer)
end,
Expand All @@ -35,19 +35,19 @@ function RemoteViewing(SuperClass)
end,

DisableRemoteViewingButtons = function(self)
self.Sync.Abilities = self:GetBlueprint().Abilities
self.Sync.Abilities = self.Blueprint.Abilities
self.Sync.Abilities.TargetLocation.Active = false
self:RemoveToggleCap('RULEUTC_IntelToggle')
end,

EnableRemoteViewingButtons = function(self)
self.Sync.Abilities = self:GetBlueprint().Abilities
self.Sync.Abilities = self.Blueprint.Abilities
self.Sync.Abilities.TargetLocation.Active = true
self:AddToggleCap('RULEUTC_IntelToggle')
end,

TargetLocationThread = function(self)
local Cost = CreateEconomyEvent(self, self:GetBlueprint().Economy.InitialRemoteViewingEnergyDrain * (self.EnergyMaintAdjMod or 1), 0, 1, self.SetWorkProgress)
local Cost = CreateEconomyEvent(self, self.Blueprint.Economy.InitialRemoteViewingEnergyDrain * (self.EnergyMaintAdjMod or 1), 0, 1, self.SetWorkProgress)
WaitFor(Cost)
self:SetWorkProgress(0.0)
RemoveEconomyEvent(self, Cost)
Expand All @@ -74,7 +74,7 @@ function RemoteViewing(SuperClass)
end

if self.RemoteViewingData.VisibleLocation and self.RemoteViewingData.DisableCounter == 0 and self.RemoteViewingData.IntelButton then
local bp = self:GetBlueprint()
local bp = self.Blueprint
self:SetMaintenanceConsumptionActive()
-- Create new visible area
if not self.RemoteViewingData.Satellite then
Expand Down Expand Up @@ -156,7 +156,7 @@ function RemoteViewing(SuperClass)
end,

EnableResourceMonitor = function(self)
local recharge = self:GetBlueprint().Intel.ReactivateTime or 10
local recharge = self.Blueprint.Intel.ReactivateTime or 10
WaitSeconds(recharge)
self.RemoteViewingData.DisableCounter = self.RemoteViewingData.DisableCounter - 1
self:CreateVisibleEntity()
Expand Down
2 changes: 1 addition & 1 deletion lua/ScenarioFramework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function OverrideKilled(self, instigator, type, overkillRatio)
end
self.Dead = true

local bp = self:GetBlueprint()
local bp = self.Blueprint
if self.Layer == 'Water' and bp.Physics.MotionType == 'RULEUMT_Hover' then
self:PlayUnitSound('HoverKilledOnWater')
end
Expand Down
2 changes: 1 addition & 1 deletion lua/SimCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ local function SetWorldCameraToUnitIconAngle(location, zoom)
end

local function ShowRaisedPlatforms(self)
local plats = self:GetBlueprint().Physics.RaisedPlatforms
local plats = self.Blueprint.Physics.RaisedPlatforms
if not plats then return end
local pos = self:GetPosition()
local entities = {}
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/Prop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Prop = Class(moho.prop_methods) {
-- caching
self.Trash = TrashBag()
self.EntityId = self:GetEntityId()
self.Blueprint = self:GetBlueprint()
self.Blueprint = self.Blueprint
self.CachePosition = self:GetPosition()

-- set reclaim values
Expand Down
4 changes: 2 additions & 2 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni

---@param self Unit
OnCreate = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint

-- cache often accessed values into inner table
self.Blueprint = bp
Expand Down Expand Up @@ -5461,7 +5461,7 @@ DummyUnit = ClassDummyUnit(moho.unit_methods, DebugUnitComponent) {
self.Layer = UnitGetCurrentLayer(self)

-- cache often accessed values into inner table
self.Blueprint = self:GetBlueprint()
self.Blueprint = self.Blueprint
end,

--- Typically called by functions
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/projectiles/components/SemiBallisticComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ SemiBallisticComponent = ClassSimple {
---@return number
AverageVerticalVelocityThroughTurn = function(self, targetAngle, currentAngle)
local averageVerticalVelocity = 1/(targetAngle-currentAngle) * (MathCos(currentAngle) - MathCos(targetAngle))
averageVerticalVelocity = averageVerticalVelocity * self:GetBlueprint().Physics.MaxSpeed
averageVerticalVelocity = averageVerticalVelocity * self.Blueprint.Physics.MaxSpeed
return averageVerticalVelocity
end,

Expand Down
2 changes: 1 addition & 1 deletion lua/sim/units/SlowAmphibiousLandUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SlowAmphibiousLandUnit = ClassUnit(AmphibiousLandUnit) {

-- the layer change is called before `OnCreate` is when a unit is created, hence the field `self.Blueprint` may not exist

local mult = (self.Blueprint or self:GetBlueprint()).Physics.WaterSpeedMultiplier
local mult = (self.Blueprint or self.Blueprint).Physics.WaterSpeedMultiplier
if new == 'Seabed' then
self:SetSpeedMult(mult)
else
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/units/SlowHoverLandUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SlowHoverLandUnit = ClassUnit(HoverLandUnit) {
-- The mult is applied twice thanks to an engine bug, so careful when adjusting it
-- Newspeed = oldspeed * mult * mult

local mult = (self.Blueprint or self:GetBlueprint()).Physics.WaterSpeedMultiplier
local mult = (self.Blueprint or self.Blueprint).Physics.WaterSpeedMultiplier
if new == 'Water' then
self:SetSpeedMult(mult)
else
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/units/components/TransportUnitComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BaseTransport = ClassSimple {
-- We need to determine how to handle the cargo
-- Units in internal storage are just killed/destroyed, and relevant numbers tallied up
-- Units in external storage have anims, effects, etc. and OnImpact is called for them
if damageType == "TransportDamage" or self:GetBlueprint().Transport.StorageSlots ~= 0 then
if damageType == "TransportDamage" or self.Blueprint.Transport.StorageSlots ~= 0 then
cargoDamageType = "TransportDamage" -- This damage type makes sure we skip death effects for internal cargo
cacheCargo = false
else
Expand Down
4 changes: 2 additions & 2 deletions lua/sim/units/cybran/CConstructionEggUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CConstructionEggUnit = ClassUnit(CStructureUnit) {
-- prevent the unit from being reclaimed
self:SetReclaimable(false)

local bp = self:GetBlueprint()
local bp = self.Blueprint
local buildUnit = bp.Economy.BuildUnit
local pos = self:GetPosition()
local aiBrain = self:GetAIBrain()
Expand All @@ -51,7 +51,7 @@ CConstructionEggUnit = ClassUnit(CStructureUnit) {
self:ForkThread(function()
self.OpenAnimManip = CreateAnimator(self)
self.Trash:Add(self.OpenAnimManip)
self.OpenAnimManip:PlayAnim(self:GetBlueprint().Display.AnimationOpen, false):SetRate(0.1)
self.OpenAnimManip:PlayAnim(self.Blueprint.Display.AnimationOpen, false):SetRate(0.1)
self:PlaySound(bp.Audio['EggOpen'])

WaitFor(self.OpenAnimManip)
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/units/cybran/CConstructionTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CConstructionTemplate = ClassSimple {
---@param self CConstructionTemplate
OnCreate = function(self)
-- cache the total amount of drones
self.BuildBotTotal = self:GetBlueprint().BuildBotTotal or
self.BuildBotTotal = self.Blueprint.BuildBotTotal or
math.min(math.ceil((10 + self:GetBuildRate()) / 15), 10)
end,

Expand Down
2 changes: 1 addition & 1 deletion lua/sim/units/seraphim/SAirFactoryUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SAirFactoryUnit = ClassUnit(AirFactoryUnit) {
self:SetBlockCommandQueue(true)
if unitBeingBuilt and not unitBeingBuilt.Dead and EntityCategoryContains(categories.AIR, unitBeingBuilt) then
unitBeingBuilt:DetachFrom(true)
local bp = self:GetBlueprint()
local bp = self.Blueprint
self:DetachAll(bp.Display.BuildAttachBone or 0)
end

Expand Down
6 changes: 3 additions & 3 deletions lua/sim/units/seraphim/SEnergyBallUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ SEnergyBallUnit = ClassUnit(SHoverLandUnit) {

KillingState = State {
LifeThread = function(self)
WaitSeconds(self:GetBlueprint().Lifetime)
WaitSeconds(self.Blueprint.Lifetime)
ChangeState(self, self.DeathState)
end,

Main = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint
local aiBrain = self:GetAIBrain()

-- Queue up random moves
Expand Down Expand Up @@ -92,7 +92,7 @@ SEnergyBallUnit = ClassUnit(SHoverLandUnit) {
end,

ComputeWaitTime = function(self)
local timeLeft = self:GetBlueprint().Lifetime - self.timeAlive
local timeLeft = self.Blueprint.Lifetime - self.timeAlive

local maxWait = 75
if timeLeft < 7.5 and timeLeft > 2.5 then
Expand Down
4 changes: 2 additions & 2 deletions lua/sim/units/uef/TMobileFactoryUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ TMobileFactoryUnit = ClassUnit(AmphibiousLandUnit) {
---@param builder Unit
---@param layer Layer
StartBeingBuiltEffects = function(self, builder, layer)
self:SetMesh(self:GetBlueprint().Display.BuildMeshBlueprint, true)
if self:GetBlueprint().General.UpgradesFrom ~= builder.UnitId then
self:SetMesh(self.Blueprint.Display.BuildMeshBlueprint, true)
if self.Blueprint.General.UpgradesFrom ~= builder.UnitId then
self:HideBone(0, true)
self.OnBeingBuiltEffectsBag:Add(self:ForkThread(CreateBuildCubeThread, builder, self.OnBeingBuiltEffectsBag))
end
Expand Down
14 changes: 7 additions & 7 deletions lua/sim/units/uef/TPodTowerUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
---@param order string
OnStartBuild = function(self, unitBeingBuilt, order)
TStructureUnit.OnStartBuild(self, unitBeingBuilt, order)
local unitid = self:GetBlueprint().General.UpgradesTo
local unitid = self.Blueprint.General.UpgradesTo
if unitBeingBuilt.UnitId == unitid and order == 'Upgrade' then
self.NowUpgrading = true
ChangeState(self, self.UpgradingState)
Expand All @@ -116,7 +116,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
---@param self TPodTowerUnit
---@param podData any
SetPodConsumptionRebuildRate = function(self, podData)
local bp = self:GetBlueprint()
local bp = self.Blueprint
-- Get build rate of tower
local buildRate = bp.Economy.BuildRate

Expand Down Expand Up @@ -160,7 +160,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
PodAttached = PodAttached + 1
end
if PodAttached == PodPresent and self.OpeningAnimationStarted then
local bp = self:GetBlueprint()
local bp = self.Blueprint
if not self.OpenAnim then return end
self.OpenAnim:SetRate(1.5)
self.OpeningAnimationStarted = false
Expand All @@ -177,7 +177,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
self:RequestRefreshUI()
if not self.OpeningAnimationStarted then
self.OpeningAnimationStarted = true
local bp = self:GetBlueprint()
local bp = self.Blueprint
if not self.OpenAnim then
self.OpenAnim = CreateAnimator(self)
self.Trash:Add(self.OpenAnim)
Expand All @@ -198,7 +198,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
-- This pod may have to be passed to another unit after it upgrades. We cannot let the trash clean it up
-- when this unit is destroyed at the tail end of the upgrade. Make sure the unit dies properly elsewhere.
self.TowerCaptured = nil
local bp = self:GetBlueprint()
local bp = self.Blueprint
for _, v in bp.Economy.EngineeringPods do
if v.CreateWithUnit and not self.PodData[v.PodName].Active then
if not self.PodData then
Expand Down Expand Up @@ -230,7 +230,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
self:SetPodConsumptionRebuildRate(self.PodData[self.Rebuilding])
ChangeState(self, self.RebuildingPodState)
end
local bp = self:GetBlueprint()
local bp = self.Blueprint
while true and not self.Rebuilding do
for _, v in bp.Economy.EngineeringPods do
-- Check if all the pods are active
Expand Down Expand Up @@ -325,7 +325,7 @@ TPodTowerUnit = ClassUnit(TStructureUnit) {
self:InitializeTower()
end

local bp = self:GetBlueprint().Display
local bp = self.Blueprint.Display
self:DestroyTarmac()
self:PlayUnitSound('UpgradeStart')
self:DisableDefaultToggleCaps()
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Weapon = ClassWeapon(WeaponMethods, DebugWeaponComponent) {
---@param self Weapon
OnCreate = function(self)
-- Store blueprint for improved access pattern, see benchmark on blueprints
local bp = self:GetBlueprint()
local bp = self.Blueprint
self.Blueprint = bp

-- Legacy information stored for backwards compatibility
Expand Down
2 changes: 1 addition & 1 deletion lua/sim/weapons/aeon/AQuantumBeamGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AQuantumBeamGenerator = ClassWeapon(DefaultBeamWeapon) {

---@param self AQuantumBeamGenerator
PlayFxWeaponUnpackSequence = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint
for _, v in self.FxUpackingChargeEffects do
for i, j in bp.RackBones[self.CurrentRackSalvoNumber].MuzzleBones do
CreateAttachedEmitter(self.unit, j, self.unit.Army, v):ScaleEmitter(self.FxUpackingChargeEffectScale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local VisionMarker = import("/lua/sim/vizmarker.lua").VisionMarkerOpti

AIFGuidedMissile02 = ClassProjectile(AGuidedMissileProjectile) {
OnImpact = function(self, TargetType, TargetEntity)
local bp = self:GetBlueprint().Audio
local bp = self.Blueprint.Audio
local snd = bp['Impact' .. TargetType]
if snd then
self:PlaySound(snd)
Expand Down
2 changes: 1 addition & 1 deletion projectiles/X1Mercy_proj/X1Mercy_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ X1Mercy = Class(AMiasmaProjectile) {

--WARN(tostring(TargetType) .. " - " .. tostring(TargetEntity))
--Sounds for all other impacts, ie: Impact<TargetTypeName>
local bp = self:GetBlueprint().Audio
local bp = self.Blueprint.Audio
local snd = bp['Impact'.. TargetType]
if snd then
self:PlaySound(snd)
Expand Down
2 changes: 1 addition & 1 deletion units/UAS0302/UAS0302_Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ UAS0302 = ClassUnit(ASeaUnit) {
OnCreate = function(self)
ASeaUnit.OnCreate(self)
for i = 1, 3 do
self.Trash:Add(CreateAnimator(self):PlayAnim(self:GetBlueprint().Weapon[i].AnimationOpen))
self.Trash:Add(CreateAnimator(self):PlayAnim(self.Blueprint.Weapon[i].AnimationOpen))
end
end,
}
Expand Down
2 changes: 1 addition & 1 deletion units/UAS0401/UAS0401_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ UAS0401 = ClassUnit(ASeaUnit, ExternalFactoryComponent) {

OnKilled = function(self, instigator, type, overkillRatio)
ExternalFactoryComponent.OnKilled(self, instigator, type, overkillRatio)
local watchBone = self:GetBlueprint().WatchBone or 0
local watchBone = self.Blueprint.WatchBone or 0

self:ForkThread(function()
local pos = self:GetPosition()
Expand Down
4 changes: 2 additions & 2 deletions units/UEA0104/UEA0104_Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ UEA0104 = ClassUnit(AirTransport) {
self.LandingAnimManip = CreateAnimator(self)
self.LandingAnimManip:SetPrecedence(0)
self.Trash:Add(self.LandingAnimManip)
self.LandingAnimManip:PlayAnim(self:GetBlueprint().Display.AnimationLand):SetRate(1)
self.LandingAnimManip:PlayAnim(self.Blueprint.Display.AnimationLand):SetRate(1)
self:ForkThread(self.ExpandThread)
end,

Expand Down Expand Up @@ -110,7 +110,7 @@ UEA0104 = ClassUnit(AirTransport) {
end,

GetUnitSizes = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint
if self:GetFractionComplete() < 1.0 then
return bp.SizeX, bp.SizeY, bp.SizeZ * 0.5
else
Expand Down
4 changes: 2 additions & 2 deletions units/UEA0107/UEA0107_Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ UEA0107 = ClassUnit(AirTransport) {
self.LandingAnimManip = CreateAnimator(self)
self.LandingAnimManip:SetPrecedence(0)
self.Trash:Add(self.LandingAnimManip)
self.LandingAnimManip:PlayAnim(self:GetBlueprint().Display.AnimationLand):SetRate(1)
self.LandingAnimManip:PlayAnim(self.Blueprint.Display.AnimationLand):SetRate(1)
self:ForkThread(self.ExpandThread)
end,

Expand Down Expand Up @@ -99,7 +99,7 @@ UEA0107 = ClassUnit(AirTransport) {
end,

GetUnitSizes = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint
if self:GetFractionComplete() < 1.0 then
return bp.SizeX, bp.SizeY, bp.SizeZ * 0.5
else
Expand Down
2 changes: 1 addition & 1 deletion units/UEB0203/UEB0203_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local TSeaFactoryUnit = import("/lua/terranunits.lua").TSeaFactoryUnit
UEB0203 = ClassUnit(TSeaFactoryUnit) {
OnCreate = function(self)
TSeaFactoryUnit.OnCreate(self)
self.BuildPointSlider = CreateSlider(self, self:GetBlueprint().Display.BuildAttachBone or 0, -5, 0, 0, -1)
self.BuildPointSlider = CreateSlider(self, self.Blueprint.Display.BuildAttachBone or 0, -5, 0, 0, -1)
self.Trash:Add(self.BuildPointSlider)
end,

Expand Down
2 changes: 1 addition & 1 deletion units/UEB0303/UEB0303_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local TSeaFactoryUnit = import("/lua/terranunits.lua").TSeaFactoryUnit
UEB0303 = ClassUnit(TSeaFactoryUnit) {
OnCreate = function(self)
TSeaFactoryUnit.OnCreate(self)
self.BuildPointSlider = CreateSlider(self, self:GetBlueprint().Display.BuildAttachBone or 0, -15, 0, 0, -1)
self.BuildPointSlider = CreateSlider(self, self.Blueprint.Display.BuildAttachBone or 0, -15, 0, 0, -1)
self.Trash:Add(self.BuildPointSlider)
end,

Expand Down
2 changes: 1 addition & 1 deletion units/UEB1101/UEB1101_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ UEB1101 = ClassUnit(TEnergyCreationUnit) {

OpeningState = State {
Main = function(self)
local bp = self:GetBlueprint()
local bp = self.Blueprint
if bp.Audio.Activate then
self:PlaySound(bp.Audio.Activate)
end
Expand Down
Loading

0 comments on commit f21b665

Please sign in to comment.