W.I.P. some more things done, for VS API change
This commit is contained in:
parent
30a477fd4d
commit
ee495f88ac
7 changed files with 52 additions and 98 deletions
|
|
@ -76,7 +76,6 @@
|
|||
<Compile Include="Helpers.cs" />
|
||||
<Compile Include="BlockBehaviors\BlockBehaviorVerticalOrientation.cs" />
|
||||
<Compile Include="BlockClasses\CollapsingBlock.cs" />
|
||||
<Compile Include="BlockEntityClasses\CollapsingBlockEntity.cs" />
|
||||
<Compile Include="BlockClasses\FalseWall.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -85,6 +84,8 @@
|
|||
<Folder Include="BlockEntityClasses\" />
|
||||
<Folder Include="BlockBehaviors\" />
|
||||
<Folder Include="assets\defensive\recipes\grid\" />
|
||||
<Folder Include="assets\defensive\textures\ceramic\" />
|
||||
<Folder Include="assets\defensive\shapes\block\ceramic\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="assets\defensive\blocktypes\iron\grille_horizontal.json">
|
||||
|
|
@ -181,6 +182,12 @@
|
|||
<None Include="assets\defensive\shapes\block\stone\false_wall_upper.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="assets\defensive\shapes\block\ceramic\Candle_wall-holder.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="assets\defensive\textures\ceramic\semi_t_cera.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Vintagestory.API;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Config;
|
||||
using Vintagestory.API.MathTools;
|
||||
|
|
@ -19,16 +20,21 @@ namespace FirstMachineAge
|
|||
|
||||
private ModSystemBlockReinforcement ReinforcementSystem;
|
||||
|
||||
private uint Howmuch
|
||||
public uint Howmuch
|
||||
{
|
||||
get
|
||||
{
|
||||
return properties[_howmuchKey].AsType<uint>(1u);
|
||||
}
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public override void Initialize(JsonObject properties)
|
||||
{
|
||||
base.Initialize(properties);
|
||||
|
||||
Howmuch = properties[_howmuchKey].AsType<uint>(1u);
|
||||
}
|
||||
|
||||
public BlockBehaviorFreeReinforcement(Block block) : base(block)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnLoaded(ICoreAPI api)
|
||||
|
|
@ -47,7 +53,7 @@ namespace FirstMachineAge
|
|||
{
|
||||
handling = EnumHandling.PassThrough;
|
||||
if (world.Api.Side.IsServer( )) {
|
||||
world.Api.Event.RegisterCallback((elapse) => { PostPlacementReinforce(elapse, blockSel.Position.Copy( ), byPlayer, this.Howmuch); }, 64);
|
||||
world.Api.Event.RegisterCallback((elapse) => { PostPlacementReinforce(elapse, blockSel.Position.Copy( ), byPlayer, this.Howmuch); }, 256);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,34 +10,11 @@ using Vintagestory.GameContent;
|
|||
|
||||
namespace FirstMachineAge
|
||||
{
|
||||
public class CollapsingBlock : Block, ITexPositionSource
|
||||
public class CollapsingBlock : Block
|
||||
{
|
||||
internal const string CamoKey = @"camo";
|
||||
internal const string WoodKey = @"wood";
|
||||
|
||||
#region ITexPositionSource
|
||||
internal string camoMaterial;
|
||||
public Size2i AtlasSize { get; private set; }
|
||||
private ITexPositionSource camoTextureSource;
|
||||
private ITexPositionSource woodTextureSource;
|
||||
private ITexPositionSource defaultTextureSource;
|
||||
|
||||
public TextureAtlasPosition this[string textureCode] {
|
||||
get
|
||||
{
|
||||
if (camoTextureSource == null ) camoTextureSource = ClientAPI.Tesselator.GetTexSource(this);//How to PRESET??
|
||||
if (woodTextureSource == null) woodTextureSource = ClientAPI.Tesselator.GetTexSource(this);
|
||||
if (defaultTextureSource == null) defaultTextureSource = ClientAPI.Tesselator.GetTexSource(this);
|
||||
|
||||
|
||||
|
||||
if (textureCode == CamoKey) return camoTextureSource[CamoKey];
|
||||
if (textureCode == WoodKey) return woodTextureSource[WoodKey];
|
||||
|
||||
return defaultTextureSource[textureCode];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
/*
|
||||
EntityPlayer : EntityHumanoid
|
||||
EntityHumanoid : EntityAgent
|
||||
|
|
@ -55,19 +32,7 @@ namespace FirstMachineAge
|
|||
get { return this.api as ICoreClientAPI; }
|
||||
}
|
||||
|
||||
internal CollapsingBlockEntity Entity(BlockPos here)
|
||||
{
|
||||
var collapseBlockEntity = api.World.BlockAccessor.GetBlockEntity(here) as CollapsingBlockEntity;
|
||||
|
||||
if (collapseBlockEntity == null) {
|
||||
#if DEBUG
|
||||
api.World.Logger.Warning($"CollapsingBlockEntity [{here}]: BlockEntity NULL! (regenerating)");
|
||||
#endif
|
||||
api.World.BlockAccessor.SpawnBlockEntity(AssortedModSystems.CollapsingBlockEntityNameKey, here);
|
||||
}
|
||||
|
||||
return collapseBlockEntity;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Fall apart if player tries to 'Hoe' 'Dig' or mess with block in any way, or even place things on top of it...
|
||||
|
|
@ -80,17 +45,15 @@ namespace FirstMachineAge
|
|||
|
||||
public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact)
|
||||
{
|
||||
//Start to shake...with particles , dust
|
||||
//Start to shake...with particles , dust, creaking sounds
|
||||
api.World.Logger.VerboseDebug($"OnEntityCollide ({entity.Code}) of [{entity.GetType( ).Name}] @ {pos} impact: {isImpact}");
|
||||
//Check 'Volumne' of Bounding box; large ones - cause collapse...
|
||||
|
||||
//Tick Callback; in 200ms...
|
||||
api.Event.RegisterCallback(CheckOwnVolume, pos ,200);
|
||||
}
|
||||
|
||||
public override string GetPlacedBlockName(IWorldAccessor world, BlockPos pos)
|
||||
{
|
||||
if (this.AltCover == @"soil") {
|
||||
return Lang.Get(GlobalConstants.DefaultDomain + ":block-soil-verylow-none");
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(this.Cover) && !String.IsNullOrEmpty(this.Material)) {
|
||||
return Lang.Get(GlobalConstants.DefaultDomain + $":block-{this.Cover}-{this.Material}" );
|
||||
|
|
@ -99,6 +62,13 @@ namespace FirstMachineAge
|
|||
return @"Error?";
|
||||
}
|
||||
|
||||
private void CheckOwnVolume(IWorldAccessor localAcc, BlockPos here, float delay)
|
||||
{
|
||||
//Check 'Volumne' of Bounding box; any 'large' entity still standing here is going to be surprised!
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private string Material
|
||||
{
|
||||
|
|
@ -125,16 +95,6 @@ namespace FirstMachineAge
|
|||
}
|
||||
}
|
||||
|
||||
private string AltCover {
|
||||
/*
|
||||
{ code: "cover", states: [ "sand","gravel" ] },
|
||||
{ code: "material", loadFromProperties: "block/rock", combine: "SelectiveMultiply", onVariant: "cover" },
|
||||
{ code: "alt_cover", states: [ "soil" ], combine: "Add" },
|
||||
*/
|
||||
get
|
||||
{
|
||||
return this.Variant[@"alt_cover"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ namespace FirstMachineAge
|
|||
get { return this.Block as BoltableDoor; }
|
||||
}
|
||||
|
||||
public override void FromTreeAtributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve)
|
||||
public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve)
|
||||
{
|
||||
base.FromTreeAtributes(tree, worldAccessForResolve);
|
||||
base.FromTreeAttributes(tree, worldAccessForResolve);
|
||||
this.Bolted = tree.GetBool(_boltedKey, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,29 +2,20 @@
|
|||
code: "false_floor",
|
||||
class: "CollapsingBlock",
|
||||
variantgroups: [
|
||||
{ code: "cover", states: [ "sand","gravel" ] },
|
||||
{ code: "material", combine: "SelectiveMultiply", onVariant: "cover", states: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] },
|
||||
{ code: "alt_cover", states: [ "soil" ], combine: "Add" },
|
||||
{ code: "cover", states: [ "cobblestone","stonebricks" ] },
|
||||
{ code: "material", loadFromProperties: "block/rock" },
|
||||
],
|
||||
creativeinventory: { "general": ["*"], "terrain": ["*"] },
|
||||
shape: { base: "block/wood/false_floor" },
|
||||
blockmaterialByType: {
|
||||
"*-soil": "Soil",
|
||||
"*-sand-*": "Sand",
|
||||
"*-gravel-*": "Gravel",
|
||||
},
|
||||
texturesByType: {
|
||||
"*-soil": {
|
||||
blockmaterial: "Stone",
|
||||
texturesByType: {
|
||||
"*-cobblestone-*": {
|
||||
"wood": { base: "game:block/plant/bamboo/stem-brown" },
|
||||
"camo": { base: "game:block/soil/fertverylow" }
|
||||
"camo": { base: "game:block/stone/cobblestone/{material}1" }
|
||||
},
|
||||
"*-sand-*": {
|
||||
"*-stonebricks-*": {
|
||||
"wood": { base: "game:block/plant/bamboo/stem-brown" },
|
||||
"camo": { base: "game:block/stone/sand/{material}" }
|
||||
},
|
||||
"*-gravel-*": {
|
||||
"wood": { base: "game:block/plant/bamboo/stem-brown" },
|
||||
"camo": { base: "game:block/stone/gravel/{material}" }
|
||||
"camo": { base: "game:block/stone/brick/{material}1" }
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
|
|
@ -38,13 +29,12 @@
|
|||
all: false , top: true
|
||||
},
|
||||
replaceable: 600,
|
||||
fertility: 1,
|
||||
resistance: 2.0,
|
||||
sounds: {
|
||||
place: "block/sand",
|
||||
break: "block/sand",
|
||||
hit: "block/sand",
|
||||
walk: "walk/sand"
|
||||
"walk": "walk/stone",
|
||||
byTool: {
|
||||
"Pickaxe": { hit: "block/rock-hit-pickaxe", break: "block/rock-break-pickaxe" }
|
||||
}
|
||||
},
|
||||
heldTpIdleAnimation: "holdbothhandslarge", heldTpUseAnimation: "twohandplaceblock",
|
||||
tpHandTransform: {
|
||||
|
|
|
|||
|
|
@ -2,31 +2,21 @@
|
|||
{
|
||||
ingredientPattern: "_S_ BBB",
|
||||
ingredients: {
|
||||
"S": { type: "block", code: "game:sand-*", quantity: 1, name: "sand", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] },
|
||||
"S": { type: "block", code: "game:cobblestoneslab-*", quantity: 1, name: "cobblestone", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] },
|
||||
"B": { type: "item", code: "game:bamboostakes" },
|
||||
},
|
||||
width: 3,
|
||||
height: 2,
|
||||
output: { type: "block", code: "false_floor-sand-{sand}", quantity: 1 }
|
||||
output: { type: "block", code: "false_floor-cobblestone-{cobblestone}", quantity: 1 }
|
||||
},
|
||||
{
|
||||
ingredientPattern: "_G_ BBB",
|
||||
ingredients: {
|
||||
"G": { type: "block", code: "game:gravel-*", quantity: 1, name: "gravel", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] },
|
||||
"G": { type: "block", code: "game:stonebrickslab-*", quantity: 1, name: "brick", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] },
|
||||
"B": { type: "item", code: "game:bamboostakes" },
|
||||
},
|
||||
width: 3,
|
||||
height: 2,
|
||||
output: { type: "block", code: "false_floor-gravel-{gravel}", quantity: 1 }
|
||||
output: { type: "block", code: "false_floor-brick-{brick}", quantity: 1 }
|
||||
},
|
||||
{
|
||||
ingredientPattern: "_D_ BBB",
|
||||
ingredients: {
|
||||
"D": { type: "block", code: "game:soil-low-*", quantity: 1 },
|
||||
"B": { type: "item", code: "game:bamboostakes" },
|
||||
},
|
||||
width: 3,
|
||||
height: 2,
|
||||
output: { type: "block", code: "false_floor-soil", quantity: 1 }
|
||||
}
|
||||
]
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
"description" : "Defensive structures and emplacements, ideal for castles...",
|
||||
"authors": ["Melchior"],
|
||||
"version": "0.1.3",
|
||||
"ModID":"defensive",
|
||||
"dependencies": {
|
||||
"game": "1.12.0",
|
||||
"survival": ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue