/// <summary> /// Clears this holder, but does not stop it. /// </summary> public void clear() { lock (lockObject) { Projector p = null; Weapons w = null; foreach (Object o in projectors) { if ((p = o as Projector) != null) { p.requestingTerminate(); p.freeResources(); Interaction.removeFromObjectTable(p.id); } else if ((w = o as Weapons) != null) { Weapons.requestedClear = true; w.use(); Weapons.requestedClear = false; } } projectors.Clear(); modifiedProjectorList = true; } added = false; }
protected virtual void activate() { try { running = true; while (true) { modifiedProjectorList = false; startMarker = Environment.TickCount; count = 0; hault(); //will block here if asked to do so, //and then move on when released. lock (lockObject) { foreach (Object o in projectors) { Projector p = (Projector)o; if (!p.isTerminated) { p.move(); } else { p.freeResources(); remove(p); } if (modifiedProjectorList) //IE: if object requested another object to be added to this holder { break; } } //foreach } //lock long executionTime = Environment.TickCount - startMarker; if (executionTime < Common.intervalMS) { Thread.Sleep((int)(Common.intervalMS - executionTime)); } /* BUG FIX: * We need to have the added check below since * in an online game, holder[1] will have 0 projectors until a player connects to the FFA. * This would cause the holder to terminate, so when the player connected and * moved, the move would not register. * */ if (projectors.Count == 0 && (added || Interaction.isFFAFinished() || Options.abortGame || Options.serverEndedGame || Options.requestedShutdown)) { running = false; done = true; System.Diagnostics.Trace.WriteLine("Holder ended: " + (this is WeaponsHolder)); return; } } //while } catch (Exception e) { Common.handleError(e); } //catch }