package Icon import Setup import Menu import IconType import HashMap import TypeCasting constant real animationSpeedHover = 5 constant real animationSpeedHit = 8 constant int dummyIcon = 'Icon' public class Icon extends Widget destructable array[12] structs boolean array[12] isDisabled iconType typ vec2 realPos int scale construct(string name, element pos, int scale) super(pos, element(scale, scale)) realPos = pos.toVec() + menuStart realPos += vec2((scale - 1) * tileSize * 0.5, (scale - 1) * tileSize * 0.5) typ = getIconType(name) this.scale = scale override function hideDirect(player p) destructable d = structs[p.getId()] if d != null RemoveDestructable(d) structs[p.getId()] = null override function showDirect(player p) destructable d = structs[p.getId()] if d == null int id = dummyIcon if GetLocalPlayer() == p if isDisabled[p.getId()] id = typ.diableId print("is Disabled") else id = typ.normalId structs[p.getId()] = CreateDestructable(id, realPos.x, realPos.y, 0, scale * 1., 1) override function disable(player p) if not isDisabled[p.getId()] isDisabled[p.getId()] = true destructable d = structs[p.getId()] if d != null RemoveDestructable(d) int id = dummyIcon if(GetLocalPlayer() == p) id = typ.diableId structs[p.getId()] = CreateDestructable(id, realPos.x, realPos.y, 0, scale * 1., 1) override function enable(player p) if isDisabled[p.getId()] isDisabled[p.getId()] = false destructable d = structs[p.getId()] if d != null RemoveDestructable(d) int id = dummyIcon if(GetLocalPlayer() == p) id = typ.normalId structs[p.getId()] = CreateDestructable(id, realPos.x, realPos.y, 0, scale * 1., 1) override function clickAnimation(player p) if GetLocalPlayer() == p destructable d = structs[p.getId()] SetDestructableAnimationSpeed(d, animationSpeedHit) SetDestructableAnimation(d, "morph alternate") QueueDestructableAnimation(d, "morph") override function trackAnimation(player p) if GetLocalPlayer() == p destructable d = structs[p.getId()] SetDestructableAnimationSpeed(d, animationSpeedHover) SetDestructableAnimation(d, "morph") override function untrackAnimation(player p) if GetLocalPlayer() == p destructable d = structs[p.getId()] SetDestructableAnimationSpeed(d, animationSpeedHover) SetDestructableAnimation(d, "morph alternate") ondestroy for int i = 0 to 11 if structs[i] != null RemoveDestructable(structs[i]) endpackage