Skip to content

Commit

Permalink
feat: add Type mutator and accessor functions to skill.nut
Browse files Browse the repository at this point in the history
  • Loading branch information
Enduriel authored and LordMidas committed Mar 2, 2023
1 parent ac5cc6b commit dc93557
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions msu/hooks/skills/skill.nut
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@
o.m.IsApplyingPreview <- false;
o.PreviewField <- {};

o.isType = function( _t, _any = true, _only = false )
{
if (_any)
{
return _only ? this.m.Type - (this.m.Type & _t) == 0 : (this.m.Type & _t) != 0;
}
else
{
return _only ? (this.m.Type & _t) == this.m.Type : (this.m.Type & _t) == _t;
}
}

o.addType <- function ( _t )
{
this.m.Type = this.m.Type | _t;
}

o.setType <- function( _t )
{
this.m.Type = _t;
}

o.removeType <- function( _t )
{
if (this.isType(_t, false)) this.m.Type -= _t;
else throw ::MSU.Exception.KeyNotFound(_t);
}

o.scheduleChange <- function( _field, _change, _set = false )
{
this.m.ScheduledChanges.push({Field = _field, Change = _change, Set = _set});
Expand Down

0 comments on commit dc93557

Please sign in to comment.