/* * Author: Needles * https://steamcommunity.com/profiles/76561198026257137/ */ printl("*** ATTACHMENT"); ::Attachment <- {}; ::Attachment.SCOPE_KEY <- UniqueString(); ::Attachment.Attachment <- class { self = null; pointMap = null; constructor(_self) { self = _self; pointMap = {}; } function AddPoint(name, origin, angles) { pointMap[name] <- { origin = origin, angles = angles, } } function RemovePoint(name) { if (!(name in pointMap)) return; delete pointMap[name]; } function GetPoint(name) { if (!(name in pointMap)) return {origin = Vector(0.0, 0.0, 0.0), angles = QAngle(0.0, 0.0, 0.0)}; return pointMap[name]; } } function Attachment::Validate(entity) { if (entity == null || entity.IsValid() == false || entity.ValidateScriptScope() == false) return null; if (::Attachment.SCOPE_KEY in entity.GetScriptScope()) return entity.GetScriptScope()[::Attachment.SCOPE_KEY]; local attachment = ::Attachment.Attachment(entity); entity.GetScriptScope()[::Attachment.SCOPE_KEY] <- attachment; return attachment; }