001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.entity.living.ai; 019 020import net.tridentsdk.entity.LivingEntity; 021 022/** 023 * Interface for creating AI and pathfinding algorithms 024 * 025 * <p>Each time an entity attempts to think, it will call 026 * {@link net.tridentsdk.entity.living.ai.AiModule#think(net.tridentsdk.entity.LivingEntity)} and give the 027 * ai a chance to decide behavior.</p> 028 * 029 * <p>The module may also provide a path and return a number other than 0 to indicate how many ticks the 030 * AI can rest and the path will be followed by the entity. By not setting a path and returning a value other 031 * than 0, the entity can effectively be made to "sleep," where it will not move at all.</p> 032 * 033 * @author The TridentSDK Team 034 * @since 0.3-alpha-DP 035 */ 036public interface AiModule { 037 /** 038 * Called each time an entity is given a chance to think 039 * 040 * @param entity the handle that allows this handler to interact with the entity 041 * @return an integer representing the number of ticks that this entity may not have to think for 042 * i.e. if a path was submitted, this entity may not have to think for a few ticks 043 */ 044 int think(LivingEntity entity); 045}