public void Possess(IPossessable obj) { if (obj != null) { // unpossess the current object if (controlledObject != null) { controlledObject.UnPossess(); } // possess the new object controlledObject = obj; controlledObject.Possess(); } }
private void PossessPossessable(IPossessable newPossession) { switch (newPossession.GetPossessableType()) { case EPossessableType.PRIMARY: if (primaryPossession != null) { primaryPossession.UnPossess(); } newPossession.Possess(); primaryPossession = newPossession; primaryPossessionTransform = primaryPossession.GetGameObject().transform; break; case EPossessableType.SECONDARY: newPossession.Possess(); secondaryPossessions.Add(newPossession); break; default: break; } }