/// <summary> /// 移出引擎 /// </summary> /// <param name="id">引擎ID</param> public static void Remove(EngineID id) { if (gEngineMap.ContainsKey(id)) { gEngineMap.Remove(id); } }
/// <summary> /// 将引擎添加到引擎容器 /// </summary> /// <param name="id">引擎ID</param> /// <param name="engine">消息引擎对象</param> public static void Add(EngineID id, MsgEngine engine) { if (gEngineMap.ContainsKey(id) == false) { gEngineMap.Add(id, engine); } }
public static void BuildTrain(TileIndex depot, StationID[] stations, Action <TileIndex, string> sign = null) { var list = new AIEngineList(AIVehicle.VT_RAIL); list.Valuate(AIEngine.GetMaxSpeed); EngineID passangerWagon = null; EngineID mailWagon = null; foreach (var(a, b) in list) { if (AIEngine.IsBuildable(a) && !AIEngine.IsWagon(a)) { //AILog.Info(a + ": " + AIEngine.GetName(a) + " | " + AIEngine.GetMaxSpeed(a) + " | " + AIEngine.GetReliability(a) + " | " + AIEngine.GetMaxTractiveEffort(a)); } else if (AIEngine.IsBuildable(a) && AIEngine.IsWagon(a)) { //AILog.Info(a + ": " + AIEngine.GetName(a) + " | " + AIEngine.GetCargoType(a)); if (AICargo.HasCargoClass(AIEngine.GetCargoType(a), AICargo.CC_PASSENGERS)) { passangerWagon = a; //AILog.Info("passanger"); } else if (AICargo.HasCargoClass(AIEngine.GetCargoType(a), AICargo.CC_MAIL)) { mailWagon = a; //AILog.Info("mail"); } } } var engineType = list.Begin(); //AILog.Info("Engine id: " + engineType); //AILog.Info("Building: " + AIEngine.GetName(engineType)); var train = AIVehicle.BuildVehicle(depot, engineType); var firstPassanger = AIVehicle.BuildVehicle(depot, passangerWagon); AIVehicle.BuildVehicle(depot, passangerWagon); AIVehicle.BuildVehicle(depot, passangerWagon); var firstMail = AIVehicle.BuildVehicle(depot, mailWagon); AIVehicle.MoveWagonChain(firstMail, 0, train, 0); AIVehicle.MoveWagonChain(firstPassanger, 0, train, 0); for (var i = 0; i < stations.Length; i++) { AIOrder.AppendOrder(train, AIStation.GetLocation(stations[i]), AIOrder.OF_NONE); } AIVehicle.StartStopVehicle(train); }
/// <summary> /// 删除消息映射项 /// </summary> /// <param name="msgID">消息ID</param> /// <param name="engineID">引擎ID</param> public static void Remove(int msgID, EngineID engineID) { lock (m_msgMap) { List <EngineID> elist; if (m_msgMap.TryGetValue(msgID, out elist)) { elist.Remove(engineID); if (elist.Count == 0) { m_msgMap.Remove(msgID); } } } }
/// <summary> /// 发送消息 /// </summary> /// <param name="msg">消息</param> /// <param name="engineID">引擎ID</param> public static void SendMsg(Msg msg, EngineID engineID = EngineID.Unknow) { // 默认向消息中心发送 if (engineID == EngineID.Unknow) { engineID = EngineID.MsgCenter; } MsgEngine engine = null; if (gEngineMap.TryGetValue(engineID, out engine)) { engine.PutMsg(msg); } }
/// <summary> /// 添加消息映射项 /// </summary> /// <param name="msgID">消息ID</param> /// <param name="engineID">引擎ID</param> public static void Add(int msgID, EngineID engineID) { lock (m_msgMap) { List <EngineID> elist; if (m_msgMap.TryGetValue(msgID, out elist)) { // 在引擎列表中传入查找比较委托 if (elist.Find(eid => eid == engineID) == 0) { elist.Add(engineID); } } else { elist = new List <EngineID>(); elist.Add(engineID); m_msgMap.Add(msgID, elist); } } }
/** * Get the EngineID the given EngineID is replaced with. * @param group_id The group to get the replacement from. * @param engine_id The engine that is being replaced. * @returns The EngineID that is replacing engine_id or an invalid EngineID * in case engine_id is not begin replaced. */ public static EngineID GetEngineReplacement(GroupID group_id, EngineID engine_id) { throw null; }
/** * Get the number of engines in a given group. * @param group_id The group to get the number of engines in. * @param engine_id The engine id to count. * @returns The number of engines with id engine_id in the group with id group_id. */ public static int GetNumEngines(GroupID group_id, EngineID engine_id) { throw null; }
/// <param name="engine">The engine that is available.</param> public AIEventEngineAvailable(EngineID engine) : base(AIEventType.ET_ENGINE_AVAILABLE) { throw null; }
/** * Get the capacity of an engine. In case it can transport multiple cargoes, it * returns the first/main. * @param engine_id The engine to get the capacity of. * @returns The capacity of the engine. */ public static int GetCapacity(EngineID engine_id) { throw null; }
/** * Get the cargo-type of an engine. In case it can transport multiple cargoes, it * returns the first/main. * @param engine_id The engine to get the cargo-type of. * @returns The cargo-type of the engine. */ public static CargoID GetCargoType(EngineID engine_id) { throw null; }
/** * Check if an engine is a wagon. * @param engine_id The engine to check. * @returns Whether or not the engine is a wagon. */ public static bool IsWagon(EngineID engine_id) { throw null; }
/** * Get the type of an engine. * @param engine_id The engine to get the type of. * @returns The type the engine has. */ public static VehicleType GetVehicleType(EngineID engine_id) { throw null; }
/** * Get the date this engine was designed. * @param engine_id The engine to get the design date of. * @returns The date this engine was designed. */ public static Date GetDesignDate(EngineID engine_id) { throw null; }
/** * Get the maximum tractive effort of an engine. * @param engine_id The engine to get the maximum tractive effort of. * @returns The maximum tractive effort of the engine in kN. */ public static int GetMaxTractiveEffort(EngineID engine_id) { throw null; }
/** * Get the maximum allowed distance between two orders for an engine. * The distance returned is a vehicle-type specific distance independent from other * map distances, you may use the result of this function to compare it * with the result of AIOrder.GetOrderDistance. * @param engine_id The engine to get the max distance for. * @returns The maximum distance between two orders for the engine * or 0 if the distance is unlimited. * @note The unit of the order distances is unspecified and should * not be compared with map distances * @see AIOrder.GetOrderDistance */ public static int GetMaximumOrderDistance(EngineID engine_id) { throw null; }
/** * Get the name of an engine. * @param engine_id The engine to get the name of. * @returns The name the engine has. */ public static string GetName(EngineID engine_id) { throw null; }
/** * Checks whether the given engine type is buildable for a company. * @param engine_id The engine to check. * @returns True if and only if the engine type is buildable. */ public static bool IsBuildable(EngineID engine_id) { throw null; }
/** * Check if the engine can pull a wagon with the given cargo. * @param engine_id The engine to check. * @param cargo_id The cargo to check. * @returns True if the engine can pull wagons carrying this cargo. * @note This function is not exhaustive; a true here does not mean * that the vehicle can pull the wagons, a false does mean it can't. */ public static bool CanPullCargo(EngineID engine_id, CargoID cargo_id) { throw null; }
/** * Check if a train vehicle can run on a RailType. * @param engine_id The engine to check. * @param track_rail_type The type you want to check. * @returns Whether an engine of type 'engine_id' can run on 'track_rail_type'. * @note Even if a train can run on a RailType that doesn't mean that it'll be * able to power the train. Use HasPowerOnRail for that. */ public static bool CanRunOnRail(EngineID engine_id, RailType track_rail_type) { throw null; }
/** * Get the reliability of an engine. The value is between 0 and 100, where * 100 means 100% reliability (never breaks down) and 0 means 0% * reliability (you most likely don't want to buy it). * @param engine_id The engine to get the reliability of. * @returns The reliability the engine has. */ public static int GetReliability(EngineID engine_id) { throw null; }
/** * Check if a train engine has power on a RailType. * @param engine_id The engine to check. * @param track_rail_type Another RailType. * @returns Whether an engine of type 'engine_id' has power on 'track_rail_type'. */ public static bool HasPowerOnRail(EngineID engine_id, RailType track_rail_type) { throw null; }
/// <param name="engine">The engine offered to test.</param> public AIEventEnginePreview(EngineID engine) : base(AIEventType.ET_ENGINE_PREVIEW) { throw null; }
/** * Get the RoadType of the engine. * @param engine_id The engine to get the RoadType of. * @returns The RoadType the engine has. */ public static RoadType GetRoadType(EngineID engine_id) { throw null; }
/// <summary> /// 向引擎管理对象添加引擎对象 /// </summary> public void Register(EngineID id) { ID = id; EngineManager.Add(ID, this); }
/** * Get the RailType of the engine. * @param engine_id The engine to get the RailType of. * @returns The RailType the engine has. */ public static RailType GetRailType(EngineID engine_id) { throw null; }
/** * Start replacing all vehicles with a specified engine with another engine. * @param group_id The group to replace vehicles from. Use ALL_GROUP to replace * vehicles from all groups that haven't set autoreplace protection. * @param engine_id_old The engine id to start replacing. * @param engine_id_new The engine id to replace with. * @returns True if and if the replacing was successfully started. * @note To stop autoreplacing engine_id_old, call StopAutoReplace(group_id, engine_id_old). */ public static bool SetAutoReplace(GroupID group_id, EngineID engine_id_old, EngineID engine_id_new) { throw null; }
/** * Check if the engine is articulated. * @param engine_id The engine to check. * @returns True if the engine is articulated. */ public static bool IsArticulated(EngineID engine_id) { throw null; }
/** * Stop replacing a certain engine in the specified group. * @param group_id The group to stop replacing the engine in. * @param engine_id The engine id to stop replacing with another engine. * @returns True if and if the replacing was successfully stopped. */ public static bool StopAutoReplace(GroupID group_id, EngineID engine_id) { throw null; }
/** * Get the PlaneType of the engine. * @param engine_id The engine to get the PlaneType of. * @returns The PlaneType the engine has. */ public static PlaneType GetPlaneType(EngineID engine_id) { throw null; }