public virtual void applyStun(Stun newStun) { // only process the stun if this object type cares about it if (this.stuns != null) { // figure out what created this stun Explosion source = newStun.getCreator(); Stun previous = null; if (this.stuns.TryGetValue(source, out previous)) { // if we were already stunned by this source then replace the previous stun previous = newStun; } else { // if we were not already stunned by this source then add this stun this.stuns.Add(source, newStun); } } }