Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entity + dummy Unit in between ExFac and ExFacUnit #6093

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lua/defaultcomponents.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Buff = import("/lua/sim/buff.lua")
local Entity = import("/lua/sim/Entity.lua").Entity

---@class ShieldEffectsComponent : Unit
---@field Trash TrashBag
Expand Down Expand Up @@ -867,8 +868,21 @@ ExternalFactoryComponent = ClassSimple {
-- create the factory somewhere completely unrelated
local px, py, pz = self:GetPositionXYZ(self.FactoryAttachBone)

-- the anchor entity prevents the "deploy" command from detaching
-- the external factory from the base unit
local anchorEntity = Entity({Owner = self})
self.Trash:Add(anchorEntity)
anchorEntity:AttachTo(self, self.FactoryAttachBone)

-- the anchor unit has the "CARRIER" category, which prevents the
-- external factory from being highlighted or selected with the cursor, but
-- doesn't prevent selecting it with the exFac button
local anchorUnit = CreateUnitHPR('ZXA0003', self.Army, px, py, pz, 0, 0, 0)
self.Trash:Add(anchorUnit)
anchorUnit:AttachTo(anchorEntity, -1)

self.ExternalFactory = CreateUnitHPR(blueprintIdExternalFactory, self.Army, px, py, pz, 0, 0, 0) --[[@as ExternalFactoryUnit]]
self.ExternalFactory:AttachTo(self, self.FactoryAttachBone)
self.ExternalFactory:AttachTo(anchorUnit, -1)
self.ExternalFactory:SetCreator(self)
self:SetCreator(self.ExternalFactory)
self.ExternalFactory:SetParent(self)
Expand Down
41 changes: 41 additions & 0 deletions units/ZXA0003/ZXA0003_script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--******************************************************************************************************
--** Copyright (c) 2022 clyf
--**
--** Permission is hereby granted, free of charge, to any person obtaining a copy
--** of this software and associated documentation files (the "Software"), to deal
--** in the Software without restriction, including without limitation the rights
--** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--** copies of the Software, and to permit persons to whom the Software is
--** furnished to do so, subject to the following conditions:
--**
--** The above copyright notice and this permission notice shall be included in all
--** copies or substantial portions of the Software.
--**
--** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
--** SOFTWARE.
--******************************************************************************************************

local DummyUnit = import('/lua/sim/unit.lua').DummyUnit

---@class ZXA0003 : DummyUnit
ZXA0003 = ClassUnit(DummyUnit) {

OnCreate = function (self)
self:HideBone(0, true)
-- do not allow the unit to be killed or to take damage
self.CanTakeDamage = false

-- do not allow the unit to be reclaimed or targeted by weapons
self:SetReclaimable(false)
self:SetDoNotTarget(true)
end,

DetachFrom = function(self)
end,
}
TypeClass = ZXA0003
62 changes: 62 additions & 0 deletions units/ZXA0003/ZXA0003_unit.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
UnitBlueprint{
Categories = {
"DUMMYUNIT",
"INSIGNIFICANTUNIT",
"INVULNERABLE",
"UNSELECTABLE",
"UNSPAWNABLE",
"UNTARGETABLE",
"CARRIER",
},
Defense = {
Health = 30,
MaxHealth = 30,
},
Display = {
Mesh = {
IconFadeInZoom = 2000,
LODs = {
{
ShaderName = 'Unit',
MeshName = '/Units/UEA0001/UEA0001_lod0.scm',
AlbedoName = '/Units/UEA0001/UEA0001_Albedo.dds',
NormalsName = '/Units/UEA0001/UEA0001_normalsTS.dds',
SpecularName = '/Units/UEA0001/UEA0001_SpecTeam.dds',
},
},
},
UniformScale = 0.12,
},
Economy = {
BuildCostEnergy = 0,
BuildCostMass = 0,
BuildRate = 0.0001,
BuildTime = 0,
MaxBuildDistance = 100,
},
Footprint = {
MaxSlope = 0.25,
SizeX = 1,
SizeZ = 1,
},
General = {
CapCost = 0,
SelectionPriority = 3,
},
Intel = { VisionRadius = 0 },
Physics = {
BankingSlope = 0.5,
BuildOnLayerCaps = {
LAYER_Air = true,
LAYER_Land = false,
LAYER_Orbit = false,
LAYER_Seabed = false,
LAYER_Sub = false,
LAYER_Water = false,
},
MotionType = "RULEUMT_None",
},
SizeX = 0.01,
SizeY = 0.01,
SizeZ = 0.01,
}