private bool IsPlacement(WorldFrustrum f, long x, long y, long z, ushort placementValue) { Segment segment = f.GetSegment(x, y, z); if (segment == null || !segment.mbInitialGenerationComplete || segment.mbDestroyed) { return(false); } return(segment.GetCube(x, y, z) == eCubeTypes.MachinePlacementBlock && segment.GetCubeData(x, y, z).mValue == placementValue); }
static void BuildPart(WorldFrustrum frustrum, Position block, Block.Material material, byte orientationFlags) { var segment = new FrustrumSegmentProvider(frustrum).GetSegment(block); if (segment == null) { Debug.Log("Attempt to build multiblock machine in non-ready segment. Always check filled boxes before build"); return; } frustrum.BuildOrientation(segment, block.X, block.Y, block.Z, material.Type, material.Value, orientationFlags); }
/// this method build multiblock machine in place of placements blocks. /// fustrum - get that form ModCheckForCompletedMachineParameters /// blocks - all the positions machine should occupy /// contolPosition - position of the control block. It is important for reusing code of existing machines /// method does not check if given positions are filled with placement blocks, but they should at least be /// loaded into world /// use this method as foundation for implementing Builder interface (if BoxBuilder doesn't suit your needs) public static void Build( WorldFrustrum frustrum, IEnumerable <Position> blocks, Materials materials, Position controlPosition, Orientation orientation) { // Player builds with placement blocks, filler and control appear instead of them. WorldScript.mLocalPlayer.mResearch.GiveResearch(materials.Control.Type, materials.Control.Value); WorldScript.mLocalPlayer.mResearch.GiveResearch(materials.Filler.Type, materials.Filler.Value); foreach (var block in blocks) { if (block == controlPosition) { continue; } BuildPart(frustrum, block, materials.Filler, orientation.Flags()); } BuildPart(frustrum, controlPosition, materials.Control, orientation.Flags()); AudioSpeechManager.PlayStructureCompleteDelayed = true; }