예제 #1
0
        /// <summary>
        /// Creates a "placed" block.
        /// </summary>
        public static PlacedSingleBlock MakeSinglePlaced(Transform parent, SingleBlockInfo info, byte rotation, BlockPosition position)
        {
            GameObject        block     = InstantiatePrefab(parent, info, rotation, position);
            PlacedSingleBlock component = block.AddComponent <PlacedSingleBlock>();

            component.Initialize(info, position, rotation);
            return(component);
        }
예제 #2
0
        public static PlacedMultiBlockParent MakeMultiPlaced(Transform parent, MultiBlockInfo info, byte rotation, BlockPosition position,
                                                             out PlacedMultiBlockPart[] parts)
        {
            if (!info.GetRotatedPositions(position, rotation, out KeyValuePair <BlockPosition, BlockSides>[] partPositions))
            {
                parts = null;
                return(null);
            }

            GameObject             block     = InstantiatePrefab(parent, info, rotation, position);
            PlacedMultiBlockParent component = block.AddComponent <PlacedMultiBlockParent>();

            // ReSharper disable once CoVariantArrayConversion
            InitializeMulti(component, info, rotation, position, partPositions, count => new PlacedMultiBlockPart[count],
                            pair => new PlacedMultiBlockPart(pair.Value, pair.Key), out IMultiBlockPart[] tempParts);
            parts = (PlacedMultiBlockPart[])tempParts;
            return(component);
        }
예제 #3
0
 private static GameObject InstantiatePrefab(Transform parent, BlockInfo info, byte rotation, BlockPosition position)
 {
     return(Object.Instantiate(info.Prefab, position.ToVector(), Rotation.GetQuaternion(rotation), parent));
 }