First Machine Age's Mods (Combined repo.)
Revisão | a69ce26f3336ca6fed393b32653bdfd7112542c3 (tree) |
---|---|
Hora | 2021-02-27 10:24:50 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. working collapse
@@ -1,6 +1,6 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | - | |
3 | +using System.Threading; | |
4 | 4 | using Vintagestory.API.Common; |
5 | 5 | using Vintagestory.API.Common.Entities; |
6 | 6 | using Vintagestory.API.Config; |
@@ -12,7 +12,7 @@ namespace FirstMachineAge | ||
12 | 12 | { |
13 | 13 | public class CollapsingBlock : Block |
14 | 14 | { |
15 | - private readonly Cuboidf[ ] collapseZones = { new Cuboidf(0.1f, 0.1f, 0.0f, 0.95f, 0.95f, 0.25f) }; | |
15 | + private readonly Cuboidf[ ] collapseZones = { new Cuboidf(0.06f, 0.1f, 0.1f, 0.937f, 0.25f, 1.0f) }; | |
16 | 16 | |
17 | 17 | |
18 | 18 | private void MabeyCollapse(IWorldAccessor localAcc, BlockPos here, float delay) |
@@ -24,10 +24,9 @@ namespace FirstMachineAge | ||
24 | 24 | //hitboxSize: { x: 0.6, y: 1.85 } > Seraph |
25 | 25 | //hitboxSize: { x: 0.85, y: 0.5 }> Pup |
26 | 26 | //hitboxSize: { x: 0.4, y: 0.3 } > lil'Bunny |
27 | - | |
27 | + | |
28 | 28 | bool enough = false; |
29 | - var victems = localAcc.GetIntersectingEntities(here.UpCopy( ), collapseZones);//TOP 'Surface' - excluding edges | |
30 | - //var victems = localAcc.GetEntitiesInsideCuboid(here.AddCopy(-1,-1,-1),here.AddCopy(1,1,1));//TOP 'Surface' - excluding edges | |
29 | + var victems = localAcc.GetIntersectingEntities(here.UpCopy( ), collapseZones, (e) => { return true;});//TOP 'Surface' - excluding edges | |
31 | 30 | |
32 | 31 | foreach (var entity in victems) |
33 | 32 | { |
@@ -43,7 +42,9 @@ namespace FirstMachineAge | ||
43 | 42 | } |
44 | 43 | |
45 | 44 | if (enough) { |
46 | - localAcc.BlockAccessor.BreakBlock(here, null, 0); | |
45 | + localAcc.BlockAccessor.BreakBlock(here.Copy(), null); | |
46 | + //TODO: Sound & Dust | |
47 | + | |
47 | 48 | } |
48 | 49 | |
49 | 50 | } |
@@ -79,16 +80,7 @@ namespace FirstMachineAge | ||
79 | 80 | |
80 | 81 | #region Overrides |
81 | 82 | |
82 | - //TODO: Fall apart if player tries to 'Hoe' 'Dig' or mess with block in any way, or even place things on top of it... | |
83 | - public override void OnEntityInside(IWorldAccessor world, Entity entity, BlockPos pos) | |
84 | - { | |
85 | - if (api.Side.IsClient()) return; | |
86 | 83 | |
87 | - //Get Ready to CRUMBLE! | |
88 | - #if DEBUG | |
89 | - ServerAPI.Logger.VerboseDebug($"OnEntityInside ({entity.Code}) of [{entity.GetType( ).Name}] @ {pos}"); | |
90 | - #endif | |
91 | - } | |
92 | 84 | |
93 | 85 | public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact) |
94 | 86 | { |
@@ -99,7 +91,7 @@ namespace FirstMachineAge | ||
99 | 91 | #endif |
100 | 92 | |
101 | 93 | //Tick Callback; in 200ms... |
102 | - ServerAPI.World.RegisterCallbackUnique(MabeyCollapse, pos ,100); | |
94 | + ServerAPI.World.RegisterCallbackUnique(MabeyCollapse, pos.Copy() ,50); | |
103 | 95 | } |
104 | 96 | |
105 | 97 | public override string GetPlacedBlockName(IWorldAccessor world, BlockPos pos) |
@@ -123,6 +115,46 @@ namespace FirstMachineAge | ||
123 | 115 | base.OnNeighbourBlockChange(world, pos, neibpos); |
124 | 116 | } |
125 | 117 | |
118 | + public override bool CanCreatureSpawnOn(IBlockAccessor blockAccessor, BlockPos pos, EntityProperties type, BaseSpawnConditions sc) | |
119 | + { | |
120 | + return false; | |
121 | + } | |
122 | + | |
123 | + public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1) | |
124 | + { | |
125 | + if (api.Side.IsClient( )) { | |
126 | + //Dust | |
127 | + /* | |
128 | + byPlayer.Entity.World.SpawnParticles(new SimpleParticleProperties( ) { | |
129 | + MinQuantity = 0, | |
130 | + AddQuantity = 10, | |
131 | + Color = ColorUtil.ToRgba(128, 128, 128, 64), | |
132 | + MinPos = new Vec3d(posx + faceVec.X * 0.01f, posy + faceVec.Y * 0.01f, posz + faceVec.Z * 0.01f), | |
133 | + AddPos = new Vec3d(0, 0, 0), | |
134 | + MinVelocity = new Vec3f( | |
135 | + 4 * faceVec.X, | |
136 | + 4 * faceVec.Y, | |
137 | + 4 * faceVec.Z | |
138 | + ), | |
139 | + AddVelocity = new Vec3f( | |
140 | + 8 * (( float )rnd.NextDouble( ) - 0.5f), | |
141 | + 8 * (( float )rnd.NextDouble( ) - 0.5f), | |
142 | + 8 * (( float )rnd.NextDouble( ) - 0.5f) | |
143 | + ), | |
144 | + LifeLength = 0.025f, | |
145 | + GravityEffect = 0f, | |
146 | + MinSize = 0.03f, | |
147 | + MaxSize = 0.4f, | |
148 | + ParticleModel = EnumParticleModel.Quad, | |
149 | + VertexFlags = 200, | |
150 | + SizeEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, -0.15f) | |
151 | + }, byPlayer); | |
152 | + */ | |
153 | + } | |
154 | + | |
155 | + base.OnBlockBroken(world, pos, byPlayer, dropQuantityMultiplier); | |
156 | + } | |
157 | + | |
126 | 158 | #endregion |
127 | 159 | |
128 | 160 |
@@ -32,7 +32,8 @@ | ||
32 | 32 | replaceable: 600, |
33 | 33 | resistance: 0.4, |
34 | 34 | sounds: { |
35 | - "walk": "game:walk/stone", | |
35 | + "walk": "game:walk/wood", | |
36 | + "break":"game:effect/rockslide", | |
36 | 37 | byTool: { |
37 | 38 | "Pickaxe": { hit: "game:block/rock-hit-pickaxe", break: "game:block/rock-break-pickaxe" } |
38 | 39 | } |
@@ -42,5 +43,10 @@ | ||
42 | 43 | translation: { x: -1.2, y: -1.1, z: -0.8 }, |
43 | 44 | rotation: { x: -2, y: 25, z: -78 }, |
44 | 45 | scale: 0.37 |
46 | + }, | |
47 | + dropsByType: { | |
48 | + "*": [{ type: "item", code: "game:bamboostakes", quantity: { avg: 0.7, var: 1 } } ], | |
49 | + "*-cobblestone-*": [{ type: "item", code: "game:stone-{material}" , quantity: { avg: 0.5 } } ], | |
50 | + "*-stonebricks-*": [{ type: "item", code: "game:stonebrick-{material}" , quantity: { avg: 0.5 } }] | |
45 | 51 | } |
46 | 52 | } |
@@ -100,14 +100,14 @@ | ||
100 | 100 | { |
101 | 101 | "name": "Psudeo_Layer", |
102 | 102 | "from": [ 0.0, 4.0, -7.0 ], |
103 | - "to": [ 16.0, 5.0, 9.0 ], | |
103 | + "to": [ 16.0, 5.0, 9.0 ], | |
104 | 104 | "rotationOrigin": [ 0.0, 4.0, 8.0 ], |
105 | 105 | "faces": { |
106 | 106 | "north": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, |
107 | 107 | "east": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, |
108 | 108 | "south": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, |
109 | 109 | "west": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, |
110 | - "up": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, | |
110 | + "up": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 16.0 ], "rotation": 90 }, | |
111 | 111 | "down": { "texture": "#camo", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } |
112 | 112 | } |
113 | 113 | } |