public void SetBody(BodyEnum bodyEnum) { if (body == null) { body = Instantiate(_entitiesPrefabs.GetPrefabFromEnum(bodyEnum), transform).GetComponent <PartComponent>(); body.SetPrimaryColor(primaryColor); //GOD FORGIVE KILLING SPREE body.SetAuthor(author); } else { ChangeBody(bodyEnum); } }
private void ChangeBody(BodyEnum newBody) { DetachPartsFromBody(topPart, bottomPart, frontPart, leftPart, rightPart); Destroy(body.gameObject); body = Instantiate(_entitiesPrefabs.GetPrefabFromEnum(newBody), transform).GetComponent <PartComponent>(); body.SetPrimaryColor(primaryColor); //GOD FORGIVE KILLING SPREE body.SetAuthor(author); AttachPartToBody(topPart, CommandArg.TOP); AttachPartToBody(frontPart, CommandArg.FRONT); AttachPartToBody(bottomPart, CommandArg.BOTTOM); AttachPartToBody(leftPart, CommandArg.LEFT); AttachPartToBody(rightPart, CommandArg.RIGHT); }
private void InstantiatePart(ref PartComponent partComponent, PartEnum partEnum, CommandArg arg) { if (partComponent != null) { Destroy(partComponent.gameObject); } if (partEnum != PartEnum.NONE) { partComponent = Instantiate(_entitiesPrefabs.GetPrefabFromEnum(partEnum), GetPartPosition(arg)) .GetComponent <PartComponent>(); partComponent.SetPrimaryColor(primaryColor); partComponent.SetSecondaryColor(secondaryColor); } }