- Code: Select all
Unit = Class(moho.unit_methods)
moho.unit_methods is a c-class imported to LUA, the root file with all basics for the unitclass can be found in:
- Code: Select all
Supreme Commander\Gamedata\mohodata.SCD\lua\sim\Unit.lua
Now we create the StructureUnit. We are using the Unitclass as base.
That means everything included in the unitclass ist also part of the StructureUnit (if we not overwrite something)
- Code: Select all
StructureUnit = Class(Unit) {}
Finaly we creating the FactoryUnitclass.
- Code: Select all
FactoryUnit = Class(StructureUnit) {}
At this point the FactoryUnit has all function from the unitclass and all added functions from the StructureUnitclass.
If you now want to hook the FactoryUnit, first copy the original FactoryUnit:
- Code: Select all
local oldFactoryUnit = FactoryUnit
Now we are creating our own FactoryUnitclass:
- Code: Select all
FactoryUnit = Class(oldFactoryUnit)
We don't need to add the StructureUnitclass because (old)FactoryUnit is a child from StructureUnitclass that is also a child from unitclass.