public void Initialize(EquipmentContainer container) { currentContainer = container; currentContainer.OccupySpace(spaceOccupier); SetCommonPlacingMethods(container); if (Utility.OverlapsOtherEquipment(spaceOccupier, transform.position, transform.rotation, container)) { boundingBoxRenderer.SetWrongMaterial(); } else { boundingBoxRenderer.SetRightMaterial(); } }
//returns true if moved successfully public bool Move(Vector3 position, EquipmentContainer container) { if (isPlaced) { return(false); } Vector3 newPosition = position + new Vector3(0, spaceOccupier.Volume.y * 0.5f, 0); newPosition = Utility.KeepPositionInsideContainer(spaceOccupier, newPosition, container); if (Utility.OverlapsOtherEquipment(spaceOccupier, newPosition, transform.rotation, container)) { return(false); } if (container.Capacity.y < spaceOccupier.Volume.y) { return(false); } if (container != currentContainer) { if (!CanBePlacedInContainer(container)) { return(false); } SetCommonPlacingMethods(container); currentContainer.UnoccupySpace(spaceOccupier); currentContainer = container; currentContainer.OccupySpace(spaceOccupier); transform.rotation = container.transform.rotation; } boundingBoxRenderer.SetRightMaterial(); transform.position = newPosition; return(true); }