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.var.crossfire.model.gameobject; 021 022import net.sf.gridarta.model.anim.AnimationObjects; 023import net.sf.gridarta.model.anim.DefaultAnimationObjects; 024import net.sf.gridarta.model.face.DefaultFaceObjects; 025import net.sf.gridarta.model.face.FaceObjectProviders; 026import net.sf.gridarta.model.face.FaceObjects; 027import net.sf.gridarta.utils.ResourceIcons; 028import net.sf.gridarta.var.crossfire.model.archetype.Archetype; 029import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetype; 030import org.jetbrains.annotations.NotNull; 031 032/** 033 * Creates {@link GameObject GameObjects}. 034 * @author Andreas Kirschbaum 035 */ 036public class GameObjectCreator { 037 038 /** 039 * The {@link Archetype} for created game objects. 040 */ 041 @NotNull 042 private final Archetype archetype; 043 044 /** 045 * The {@link FaceObjectProviders} for created game objects. 046 */ 047 @NotNull 048 private final FaceObjectProviders faceObjectProviders; 049 050 /** 051 * The {@link AnimationObjects} for created game objects. 052 */ 053 @NotNull 054 private final AnimationObjects animationObjects; 055 056 /** 057 * Creates a new instance. 058 */ 059 public GameObjectCreator() { 060 final FaceObjects faceObjects = new DefaultFaceObjects(false); 061 final ResourceIcons resourceIcons = new ResourceIcons(); 062 faceObjectProviders = new FaceObjectProviders(1, faceObjects, resourceIcons); 063 animationObjects = new DefaultAnimationObjects(); 064 archetype = new DefaultArchetype("arch", faceObjectProviders, animationObjects); 065 } 066 067 /** 068 * Creates a new {@link GameObject}. 069 * @param elevation the game object's elevation 070 * @return the new game object 071 */ 072 @NotNull 073 public GameObject newGameObject(final int elevation) { 074 final GameObject gameObject = new GameObject(archetype, faceObjectProviders, animationObjects); 075 if (elevation != 0) { 076 gameObject.setAttributeInt(GameObject.ELEVATION, elevation); 077 } 078 return gameObject; 079 } 080 081}