1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 06:05:23 +00:00
OpenDiablo2/d2common/d2fileformats/d2dt1/subtile.go
gravestench 6f8b43f8d6
Various lint error fixes and suppressions (#846)
* suppressing the magic number lint errors in mapgen, it will get a heavy refactor soon, hopefully...

* adding string token constants for SkillClass

* adding panic on error to left/right skill select render

* fixed cuddle lint error

* fixed unnecessary conversion, unused func param lint errors in dcc_animation.go

* adding comment for skill class tokens

* fixed typo in comment

* removed unused parameter in dcc/dc6 animations

* supress warning about Object.setMode always being passed direction value of 0

* fixed all invalid golint directives

* fixed a couple gocritic lint errors
2020-10-26 02:04:50 -07:00

80 lines
1.6 KiB
Go

package d2dt1
// SubTileFlags represent the sub-tile flags for a DT1
type SubTileFlags struct {
BlockWalk bool
BlockLOS bool
BlockJump bool
BlockPlayerWalk bool
Unknown1 bool
BlockLight bool
Unknown2 bool
Unknown3 bool
}
// Combine combines a second set of flags into the current one
func (s *SubTileFlags) Combine(f SubTileFlags) {
s.BlockWalk = s.BlockWalk || f.BlockWalk
s.BlockLOS = s.BlockLOS || f.BlockLOS
s.BlockJump = s.BlockJump || f.BlockJump
s.BlockPlayerWalk = s.BlockPlayerWalk || f.BlockPlayerWalk
s.Unknown1 = s.Unknown1 || f.Unknown1
s.BlockLight = s.BlockLight || f.BlockLight
s.Unknown2 = s.Unknown2 || f.Unknown2
s.Unknown3 = s.Unknown3 || f.Unknown3
}
// DebugString returns the debug string
func (s *SubTileFlags) DebugString() string {
result := ""
if s.BlockWalk {
result += "BlockWalk "
}
if s.BlockLOS {
result += "BlockLOS "
}
if s.BlockJump {
result += "BlockJump "
}
if s.BlockPlayerWalk {
result += "BlockPlayerWalk "
}
if s.Unknown1 {
result += "Unknown1 "
}
if s.BlockLight {
result += "BlockLight "
}
if s.Unknown2 {
result += "Unknown2 "
}
if s.Unknown3 {
result += "Unknown3 "
}
return result
}
// NewSubTileFlags returns a list of new subtile flags
//nolint:gomnd // binary flags
func NewSubTileFlags(data byte) SubTileFlags {
return SubTileFlags{
BlockWalk: data&1 == 1,
BlockLOS: data&2 == 2,
BlockJump: data&4 == 4,
BlockPlayerWalk: data&8 == 8,
Unknown1: data&16 == 16,
BlockLight: data&32 == 32,
Unknown2: data&64 == 64,
Unknown3: data&128 == 128,
}
}