Beispiel #1
0
		/// <summary>
		/// Initialize the GO
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="templ"></param>
		internal virtual void Init(GOEntry entry, GOTemplate templ)
		{
			EntityId = EntityId.GetGameObjectId((uint)Interlocked.Increment(ref _lastGOUID), entry.GOId);
			Type |= ObjectTypes.GameObject;
			//DynamicFlagsLow = GameObjectDynamicFlagsLow.Activated;
			m_entry = entry;
			m_template = templ;

			DisplayId = entry.DisplayId;
			EntryId = entry.Id;
			GOType = entry.Type;
			Flags = m_entry.Flags;
			m_faction = m_entry.Faction ?? Faction.NullFaction;
			ScaleX = m_entry.DefaultScale;

			if (templ != null)
			{
				Phase = templ.PhaseMask;
				State = templ.State;
				if (templ.Scale != 1)
				{
					ScaleX = templ.Scale;
				}
				Orientation = templ.Orientation;
				AnimationProgress = templ.AnimProgress;
				SetRotationFields(templ.Rotations);
			}

			m_entry.InitGO(this);
		}
Beispiel #2
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntry entry, GOTemplate templ)
		{
			var go = entry.GOCreator();
			var handlerCreator = entry.HandlerCreator;
			go.Init(entry, templ); 
			if (handlerCreator != null)
			{
				go.Handler = handlerCreator();
			}
			else
			{
				log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
				go.Delete();
				return null;
			}
			return go;
		}
Beispiel #3
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntryId id, GOTemplate templ)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry != null)
			{
				return Create(entry, templ);
			}
			return null;
		}
Beispiel #4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="map"></param>
		/// <param name="pos"></param>
		/// <param name="autoSpawn">Whether to always spawn this Template when the Region starts</param>
		public GOTemplate AddTemplate(MapId region, Vector3 pos, bool autoSpawn)
		{
			var go = new GOTemplate { MapId = region, Pos = pos, AutoSpawn = autoSpawn };
			Templates.Add(go);
			return go;
		}
Beispiel #5
0
		public void AddTemplate(GOTemplate template)
		{
			Templates.Add(template);
		}
Beispiel #6
0
        public void RegisterFlagstand(GOTemplate template)
        {
            template.Entry.Used += (go, chr) =>
            {
                if (go == FlagStand)
                {
                    if (Challenged)
                    {
                        InterruptCapture(chr);
                        return true;
                    }

                    BeginCapture(chr);
                    return true;
                }
                return false;
            };
        }