Ejemplo n.º 1
0
        bool CreateServer(Map map, AreaTriggerTemplate areaTriggerTemplate, AreaTriggerSpawn position)
        {
            SetMap(map);
            Relocate(position.Location);
            if (!IsPositionValid())
            {
                Log.outError(LogFilter.AreaTrigger, $"AreaTriggerServer (id {areaTriggerTemplate.Id}) not created. Invalid coordinates (X: {GetPositionX()} Y: {GetPositionY()})");
                return(false);
            }

            _areaTriggerTemplate = areaTriggerTemplate;

            _Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), areaTriggerTemplate.Id.Id, GetMap().GenerateLowGuid(HighGuid.AreaTrigger)));

            SetEntry(areaTriggerTemplate.Id.Id);

            SetObjectScale(1.0f);

            if (position.PhaseUseFlags != 0 || position.PhaseId != 0 || position.PhaseGroup != 0)
            {
                PhasingHandler.InitDbPhaseShift(GetPhaseShift(), (PhaseUseFlagsValues)position.PhaseUseFlags, position.PhaseId, position.PhaseGroup);
            }

            UpdateShape();

            AI_Initialize();

            _ai.OnCreate();

            return(true);
        }
Ejemplo n.º 2
0
        public override bool LoadFromDB(ulong spawnId, Map map, bool addToMap, bool allowDuplicate)
        {
            AreaTriggerSpawn position = Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(spawnId);

            if (position == null)
            {
                return(false);
            }

            AreaTriggerTemplate areaTriggerTemplate = Global.AreaTriggerDataStorage.GetAreaTriggerTemplate(position.Id);

            if (areaTriggerTemplate == null)
            {
                return(false);
            }

            return(CreateServer(map, areaTriggerTemplate, position));
        }