001/* 002 * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. 003 * Copyright (C) 2000-2010 The Gridarta Developers. 004 * 005 * This program is free software; you can redistribute it and/or modify 006 * it under the terms of the GNU General Public License as published by 007 * the Free Software Foundation; either version 2 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU General Public License for more details. 014 * 015 * You should have received a copy of the GNU General Public License along 016 * with this program; if not, write to the Free Software Foundation, Inc., 017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 018 */ 019 020package net.sf.gridarta.model.gameobject; 021 022import net.sf.gridarta.model.anim.AnimationObjects; 023import net.sf.gridarta.model.archetype.TestArchetype; 024import net.sf.gridarta.model.archetype.TestDefaultArchetype; 025import net.sf.gridarta.model.face.FaceObjectProviders; 026import net.sf.gridarta.model.maparchobject.TestMapArchObject; 027import org.jetbrains.annotations.NotNull; 028import org.jetbrains.annotations.Nullable; 029 030/** 031 * A {@link GameObjectFactory} for regression tests. 032 * @author Andreas Kirschbaum 033 */ 034public class TestGameObjectFactory extends AbstractGameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> { 035 036 /** 037 * The {@link FaceObjectProviders} to use. 038 */ 039 @NotNull 040 private final FaceObjectProviders faceObjectProviders; 041 042 /** 043 * The {@link AnimationObjects} for looking up animations. 044 */ 045 @NotNull 046 private final AnimationObjects animationObjects; 047 048 /** 049 * Creates a new instance. 050 * @param faceObjectProviders the face object providers to use 051 * @param animationObjects the animation objects for looking up animations 052 */ 053 public TestGameObjectFactory(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects) { 054 this.faceObjectProviders = faceObjectProviders; 055 this.animationObjects = animationObjects; 056 } 057 058 /** 059 * {@inheritDoc} 060 */ 061 @Override 062 @NotNull 063 public TestArchetype newArchetype(@NotNull final String archetypeName) { 064 return new TestDefaultArchetype(archetypeName, faceObjectProviders, animationObjects); 065 } 066 067 /** 068 * {@inheritDoc} 069 */ 070 @NotNull 071 @Override 072 public TestGameObject createGameObject(@NotNull final TestArchetype archetype) { 073 return createGameObjectPart(archetype, null); 074 } 075 076 /** 077 * {@inheritDoc} 078 */ 079 @NotNull 080 @Override 081 public TestGameObject createGameObjectPart(@NotNull final TestArchetype archetype, @Nullable final TestGameObject head) { 082 final TestGameObject gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects); 083 if (head != null) { 084 head.addTailPart(gameObject); 085 } 086 return gameObject; 087 } 088 089 /** 090 * {@inheritDoc} 091 */ 092 @NotNull 093 @Override 094 public TestGameObject cloneGameObject(@NotNull final TestGameObject gameObject) { 095 return gameObject.clone(); 096 } 097 098}