Добавлен YellowStar,
опубликован
Алгоритмы, Наработки и Способности
Способ реализации:
cJass
Тип:
Наработка
Модуль небольшой, который вывел из модуля дока, за что credits ему.
Использует interface теперь, и теперь можно запускать хоть методы, хоть функции вне него, короче как вам удобнее.
Также добавил пример использования функции.
Какие приемущества перед другими модулями?
- Невесомый, и может использоваться абсолютно в любой структуре, даже не в спеллах
- Можно использовать в структуре которая может инициилизировать несколько спеллов (грубо говоря у вас одна структура на все тригерные магии)
vJass
function interface push takes integer this returns nothing defaults nothing
//! nocjass
module list
readonly static thistype array data
readonly static integer count = 0
boolean flush = false
push press
method add takes nothing returns nothing
set thistype.data[thistype.count] = this
set thistype.count = thistype.count + 1
endmethod
method remove takes integer i returns nothing
set thistype.count = thistype.count - 1
set thistype.data[i] = thistype.data[thistype.count]
endmethod
static method update takes nothing returns nothing
local integer i = 0
loop
exitwhen i==thistype.count
if thistype.data[i].flush then
call thistype.data[i].destroy()
call thistype.data[i].remove(i)
set i = i - 1
else
call thistype.data[i].press(thistype.data[i]).evaluate()
endif
set i = i + 1
endloop
endmethod
endmodule
//! endnocjass
cJass
function interface push takes integer this returns nothing defaults nothing
define <implement list>={
readonly static thistype data[]
readonly static integer count = 0
boolean flush = false
push press
nothing add(){thistype.data[thistype.count++] = this}
nothing remove(integer i){thistype.data[i] = thistype.data[--thistype.count]}
static nothing update(){
integer i = 0
whilenot(i == thistype.count){
if (thistype.data[i].flush){
thistype.data[i].destroy()
thistype.data[i].remove(i--)
} else {thistype.data[i].press(thistype.data[i]).evaluate()}i++}}
}
}
Ну и собственно пример.
struct spell
static timer tt=CreateTimer()
unit cast
unit targ
real time
implement list
endstruct
function onTimer takes spell this returns nothing
set this.time = this.time - 0.04
if this.time < 0.04 then
if GetWidgetLife(this.targ)>.405 or GetWidgetLife(this.cast)>.405 then
call SetUnitX(this.targ,GetUnitX(this.cast))
call SetUnitY(this.targ,GetUnitY(this.cast))
endif
call this.remove(this)
call this.destroy()
if spell.count == 0 then
call PauseTimer(spell.tt)
endif
endif
endfunction
function Cast takes nothing returns nothing
local spell this = spell.create
set this.cast = GetTriggerUnit()
set this.targ = GetSpellTargetUnit()
set this.time = GetUnitAbilityLevel(this.cast,GetSpellAbilityId())
set this.push = onTimer
call this.add()
if spell.count==0 then
call TimerStart(spell.tt,0.04,true,function this.update)
endif
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
а где же интерполяции, безье, акселерации, деселерации, рикошеты и прочее? Нихрена там не универсально =(
И да подразумевается использование 1 шаблона под 1 конкретную проблему, офк с поддержкой расширения. Бтв в шаблон можно передавать другой шаблон, с другими параметрами, и прочие эпики творить.
unit caster
unit target
method onSpellCastEffect takes nothing returns nothing
method onSpellCastEnd takes nothing returns nothing
method onSpellCastChannel takes nothing returns nothing
endinterface
но офк тебе дураку виднее
ахахахахаах, нет ну ахахахаха.
твой юзер дата - 20 таймеров пускать будет, итд, куча всякого ненужного дерьма. перебор массива в лупе, лучший способ, угадай почему, потому что больше 12 я не думаю что там будет запусков. И это оперативно быстрее в 12 раз, и не будет всяких неприятных очевидных багов с таймерами (запусти друг более менее нагруженные функции в 12 таймеров, или сейм функцию в 12 разных таймеров, и посмотри как это дерьмо обработается через дебаггер)
Т.е. 300 строк кода, существенно быстрее 60 вызовов функций, в которых хранится 5 инструкций. Причем сам вызов будет больше жрать процессорного времени, чем исполнение.
ScorpioT1000: