'From Squeak3.7gamma of ''17 July 2004'' [latest update: #5976] on 17 July 2004 at 11:09:12 am'! "Change Set: UsableSiblingInstanceFix-nk Date: 11 October 2003 Author: Ned Konz Morph>>usableSiblingInstance was always adding the created sibling to the World, even though many of its callers would turn around and immediately add the result to other morphs or delete them from the World. This change set makes #usableSiblingInstance not add the newly created Morph to the World. This makes several uses of #usableSiblingInstance more bug-free and efficient. "! !Morph methodsFor: 'copying' stamp: 'nk 10/11/2003 16:59'! usableSiblingInstance "Return another similar morph whose Player is of the same class as mine. Do not open it in the world." | aName usedNames newPlayer newMorph topRenderer | (topRenderer := self topRendererOrSelf) == self ifFalse: [^topRenderer usableSiblingInstance]. self assuredPlayer assureUniClass. newMorph := self veryDeepCopySibling. newPlayer := newMorph player. newPlayer resetCostumeList. (aName := self knownName) isNil ifTrue: [self player notNil ifTrue: [aName := newMorph innocuousName]]. "Force a difference here" aName notNil ifTrue: [usedNames := (self world ifNil: [OrderedCollection new] ifNotNil: [self world allKnownNames]) copyWith: aName. newMorph setNameTo: (Utilities keyLike: aName satisfying: [:f | (usedNames includes: f) not])]. newMorph privateOwner: nil. newPlayer assureEventHandlerRepresentsStatus. self presenter flushPlayerListCache. ^newMorph! ! !Player methodsFor: 'copying' stamp: 'nk 9/25/2003 11:43'! getNewClone "Answer a new player of the same class as the receiver, with a costume much like mine" | clone | clone _ costume usableSiblingInstance. clone openInWorld. ^ clone player ! ! !Player methodsFor: 'scripts-vector' stamp: 'nk 9/25/2003 11:46'! * aNumber "Treating Players like vectors, return a new Player that is myself scaled by the number" | new | new _ costume usableSiblingInstance player. new setX: self getX * aNumber asPoint x. new setY: self getY * aNumber asPoint y. ^ new ! ! !Player methodsFor: 'scripts-vector' stamp: 'nk 9/25/2003 11:46'! + aPlayer "Treating Players like vectors, add aPlayer to me and return a new Player" | new | new _ costume usableSiblingInstance player. new setX: self getX + aPlayer asPoint x. new setY: self getY + aPlayer asPoint y. ^ new! ! !Player methodsFor: 'scripts-vector' stamp: 'nk 9/25/2003 11:46'! - aPlayer "Treating Players like vectors, subtract aPlayer from me and return a new Player" | new | new _ costume usableSiblingInstance player. new setX: self getX - aPlayer asPoint x. new setY: self getY - aPlayer asPoint y. ^ new! ! !Player methodsFor: 'scripts-vector' stamp: 'nk 9/25/2003 11:45'! / aNumber "Treating Players like vectors, return a new Player that is myself divided by the number" | new | new _ costume usableSiblingInstance player. new setX: self getX / aNumber asPoint x. new setY: self getY / aNumber asPoint y. ^ new ! !