Skip to content

Commit

Permalink
解决制导发射器的遗留问题
Browse files Browse the repository at this point in the history
以及铜锤不能铺总线的问题
  • Loading branch information
XiaofengdiZhu committed Dec 24, 2023
1 parent 99c163c commit 30537c6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
7 changes: 6 additions & 1 deletion Gigavolt.Expand/Gigavolt.Expand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<Compile Include="JavascriptMicrocontroller\GVJavascriptMicrocontrollerData.cs"/>
<Compile Include="JavascriptMicrocontroller\SubsystemGVJavascriptMicrocontrollerBlockBehavior.cs"/>
<Compile Include="JavascriptMicrocontroller\JavascriptMicrocontrollerGVElectricElement.cs"/>
<Compile Include="WireThrough\EditGVCopperHammerDialog.cs" />
<Compile Include="WireThrough\EditGVCopperHammerDialog.cs"/>
<Compile Include="WireThrough\GVAStar.cs"/>
<Compile Include="WireThrough\GVEWireThroughBlock.cs"/>
<Compile Include="WireThrough\SubsystemGVCopperHammerBlockBehavior.cs"/>
Expand Down Expand Up @@ -431,5 +431,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Assets\Textures\GVGuidedDispenserBlock.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Engine;
using Engine.Graphics;

namespace Game {
public class GVGuidedDispenserBlock : CubeBlock, IGVElectricElementBlock {
Expand All @@ -8,26 +9,38 @@ public enum Mode { Dispense, Shoot }

public Texture2D texture;

public override void Initialize()
{
public override void Initialize() {
base.Initialize();
texture = ContentManager.Get<Texture2D>("Textures/GVGuidedDispenserBlock");
}

public override int GetFaceTextureSlot(int face, int value) {
int direction = GetDirection(Terrain.ExtractData(value));
return face == direction ? 1 : 0;
}

public override int GetFaceTextureSlot(int face, int value) => face == GetDirection(Terrain.ExtractData(value)) ? 1 : 0;

public override int GetTextureSlotCount(int value) => 2;

public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
{
generator.GenerateCubeVertices(this, value, x, y, z, Color.White, geometry.GetGeometry(texture).OpaqueSubsetsByFace);
public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
generator.GenerateCubeVertices(
this,
value,
x,
y,
z,
Color.White,
geometry.GetGeometry(texture).OpaqueSubsetsByFace
);
}
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
{
BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData, texture);

public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) {
BlocksManager.DrawCubeBlock(
primitivesRenderer,
value,
new Vector3(size),
ref matrix,
color,
color,
environmentData,
texture
);
}

public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult) {
Expand Down Expand Up @@ -87,4 +100,4 @@ public static Mode GetMode(int data) {

public int GetConnectionMask(int value) => int.MaxValue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) {
Point3 glowPoint = m_glowPoints[i];
int face1 = CellFace.Point3ToFace(i == 0 ? m_glowPoints[1] - glowPoint : glowPoint - m_glowPoints[i - 1], 6);
int face2 = CellFace.Point3ToFace(i == m_glowPoints.Length - 1 ? m_glowPoints[i - 1] - glowPoint : glowPoint - m_glowPoints[i + 1], 6);
SubsystemTerrain.ChangeCell(m_glowPoints[i].X, m_glowPoints[i].Y, m_glowPoints[i].Z, Terrain.MakeBlockValue(GVEWireThroughBlock.Index, 0, GVEWireThroughBlock.SetWireFacesBitmask(GVEWireThroughBlock.SetTexture(0, m_texture), (1 << face1) | (1 << face2))));
SubsystemTerrain.ChangeCell(m_glowPoints[i].X, m_glowPoints[i].Y, m_glowPoints[i].Z, Terrain.MakeBlockValue(GVEWireThroughBlock.Index, 0, GVEWireThroughBlock.SetWireFacesBitmask(GVEWireThroughBlock.SetTexture(GVEWireThroughBlock.SetIsWireHarness(0, m_isHarness), m_texture), (1 << face1) | (1 << face2))));
}
m_glowPoints = Array.Empty<Point3>();
}
Expand Down

0 comments on commit 30537c6

Please sign in to comment.