Exemple #1
0
        /// <summary>
        /// Creates a new station object with its left-top corner at
        /// the specified location.
        /// </summary>
        /// <param name="_type">
        /// Type of the station to be built.
        /// </param>
        /// <param name="wloc"></param>
        public Station(StationContribution _type, WorldLocator wloc)
            : base(_type, wloc)
        {
            this.type  = _type;
            this._name = string.Format("ST{0,2:d}", iota++);
            if (wloc.world == WorldDefinition.World)
            {
                WorldDefinition.World.Stations.add(this);
                WorldDefinition.World.Clock.registerRepeated(new ClockHandler(clockHandlerHour), TimeLength.fromHours(1));
                WorldDefinition.World.Clock.registerRepeated(new ClockHandler(clockHandlerDay), TimeLength.fromHours(24));
            }
            Distance r = new Distance(REACH_RANGE, REACH_RANGE, REACH_RANGE);

            // advertise listeners in the neighborhood that a new station is available
            foreach (IEntity e in Cube.CreateInclusive(baseLocation - r, baseLocation + r).GetEntities())
            {
                IStationListener l = (IStationListener)e.QueryInterface(typeof(IStationListener));
                if (l != null)
                {
                    l.advertiseStation(this);
                }
            }
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="listener"></param>
 public void remove(IStationListener listener)
 {
     core.Remove(listener);
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="listener"></param>
 public void add(IStationListener listener)
 {
     core.Add(listener);
 }