• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revisión66937a22478d726533179f3517396a0d9893098d (tree)
Tiempo2022-02-05 09:28:43
Autormelchior <melchior@user...>
Commitermelchior

Log Message

Mostly functional brazier

Should also decay (untested)

Cambiar Resumen

Diferencia incremental

--- a/Assorted/BlockClasses/RectangularBrazier.cs
+++ b/Assorted/BlockClasses/RectangularBrazier.cs
@@ -16,17 +16,24 @@ namespace FirstMachineAge
1616 {
1717 private const string stateKey = @"state";
1818 private const string fuledValue = @"fueled";
19+ private const string extinguishedValue = @"extinguished";
1920 private const string litValue = @"lit";
2021 private const float ignitionTime = 2f;
2122 private const int fuelReqt = 5;
2223 private const float fireDmg = 0.5f;
23- private WorldInteraction[ ] interactMustFuel, interactMustIgnight;
24+ private const int fuel_Temp = 999;
25+ private const int fuel_Duration = 30;
2426
27+ private WorldInteraction[ ] interactMustFuel, interactMustIgnight;
28+ private string flameoutPercentKey = @"flameoutPercent";
29+ private WeatherSystemBase weatherSys;
2530
2631 public override void OnLoaded(ICoreAPI api)
2732 {
2833 base.OnLoaded(api);
2934
35+ weatherSys = api.ModLoader.GetModSystem<WeatherSystemBase>( );
36+
3037 if (api.Side.IsClient( ))
3138 {
3239 var clientAPI = api as ICoreClientAPI;
@@ -35,7 +42,7 @@ namespace FirstMachineAge
3542 List<ItemStack> ignitionSources = new List<ItemStack>();
3643
3744 foreach (CollectibleObject obj in api.World.Collectibles) {
38- if (obj.CombustibleProps?.BurnTemperature >= 999 && obj.CombustibleProps?.BurnDuration >= 30)
45+ if (obj.CombustibleProps?.BurnTemperature >= fuel_Temp && obj.CombustibleProps?.BurnDuration >= fuel_Duration)
3946 {
4047 List<ItemStack> stacks = obj.GetHandBookStacks(clientAPI);
4148 if (stacks != null) solidFuels.AddRange(stacks);
@@ -81,6 +88,13 @@ namespace FirstMachineAge
8188 }
8289 }
8390
91+ public float FlameoutPercent {
92+ get
93+ {
94+ return this.Attributes[flameoutPercentKey].AsFloat(0.01f);
95+ }
96+ }
97+
8498 public override EnumIgniteState OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting)
8599 {
86100 if (Fueled)
@@ -113,7 +127,7 @@ namespace FirstMachineAge
113127 if ((!Fueled && !Lit)
114128 && hbItemStack != null
115129 && hbItemStack.Class == EnumItemClass.Item
116- && hbItemStack.Item?.CombustibleProps.BurnTemperature >= 999 && hbItemStack.Item?.CombustibleProps.BurnDuration >= 30)
130+ && hbItemStack.Item?.CombustibleProps.BurnTemperature >= fuel_Temp && hbItemStack.Item?.CombustibleProps.BurnDuration >= fuel_Duration)
117131 {
118132 if (byPlayer != null && byPlayer.WorldData.CurrentGameMode == EnumGameMode.Survival) {
119133 if (byPlayer.InventoryManager.ActiveHotbarSlot.StackSize >= fuelReqt) {
@@ -151,8 +165,8 @@ namespace FirstMachineAge
151165 {
152166 if (entity is EntityAgent && entity.Alive)
153167 {
154- entity.ReceiveDamage(new DamageSource( ) { Source = EnumDamageSource.Block, SourceBlock = this, Type = EnumDamageType.Fire, SourcePos = pos.ToVec3d( ) }, fireDmg);
155-
168+ entity.ReceiveDamage(new DamageSource( ) { Source = EnumDamageSource.Block, SourceBlock = this, Type = EnumDamageType.Fire, SourcePos = pos.ToVec3d( ), DamageTier = 5, KnockbackStrength = 0.25f }, fireDmg);
169+ if (Sounds?.Inside != null) world.PlaySoundAt(Sounds.Inside, entity.Pos.X, entity.Pos.Y, entity.Pos.Z);
156170 }
157171 }
158172 }
@@ -171,6 +185,38 @@ namespace FirstMachineAge
171185 return null;//Must be burning
172186 }
173187
188+
189+ public override bool ShouldReceiveServerGameTicks(IWorldAccessor world, BlockPos pos, Random offThreadRandom, out object extra)
190+ {
191+ extra = null;
192+
193+ if (Lit) {
194+ var rainLevel = world.BlockAccessor.GetRainMapHeightAt(pos);
195+ if (pos.Y >= rainLevel) { //Brr, its Wet out here!
196+ var rainPos = new BlockPos(pos.X, rainLevel, pos.Z);
197+ var precip = weatherSys.GetPrecipitation(pos.ToVec3d());
198+
199+ if (precip >= 0.4) { return true; }
200+ if (offThreadRandom.NextDouble( ) <= (FlameoutPercent * 10) ) { return true; }
201+ }
202+ else if (offThreadRandom.NextDouble( ) <= FlameoutPercent){ return true; }
203+ }
204+
205+ return false;
206+ }
207+
208+ public override void OnServerGameTick(IWorldAccessor world, BlockPos pos, object extra = null)
209+ {
210+ if (Lit) {
211+ #if DEBUG
212+ api.Logger.VerboseDebug("Got server-game tick for flameout! @ {0}", pos);
213+ #endif
214+
215+ Block extinctBlock = world.GetBlock(CodeWithVariant(stateKey, extinguishedValue));
216+ world.BlockAccessor.ExchangeBlock(extinctBlock.BlockId, pos);
217+ world.BlockAccessor.MarkBlockDirty(pos);
218+ }
219+ }
174220 }
175221 }
176222
--- a/Assorted/assets/defensive/blocktypes/metal/brazier.json
+++ b/Assorted/assets/defensive/blocktypes/metal/brazier.json
@@ -3,7 +3,7 @@
33 class: "RectangularBrazier",
44 maxstacksize: 1,
55 variantgroups: [
6- { code: "state", states: ["empty","fueled","lit","extinct"] }
6+ { code: "state", states: ["empty","fueled","lit","extinguished"] }
77 ],
88 behaviorsByType: {
99 "*-lit": [{ name: "HeatSource", properties: { heatStrength: 8 } }],
@@ -24,7 +24,7 @@
2424 base: "block/metal/brazier2", SelectiveElements:["Base/Leg*","Base/Grille1","Base/Embers"],
2525
2626 },
27- "*-extinct": {
27+ "*-extinguished": {
2828 base: "block/metal/brazier2", SelectiveElements:["Base/Leg*","Base/Grille1","Base/Ash/Lump*"],
2929
3030 },
@@ -36,12 +36,8 @@
3636 "coal": { base: "game:block/coal/charcoal"},
3737 "rusty-iron": { base: "game:block/currency/rusty-iron"},
3838 },
39- attributes: {
40- transientProps: {
41- convertFrom: "brazier-lit",
42- convertTo: "brazier-extinct",
43- inGameHours: "100",
44- }
39+ attributes: {
40+ flameoutPercent: 0.001,
4541 },
4642 creativeinventory: { "decorative": ["brazier-empty"] , "defensive": ["brazier-empty"] },
4743 blockmaterial: "Metal",
@@ -56,8 +52,8 @@
5652 particlePropertiesByType: {
5753 "*-lit": [
5854 {
59- hsvaColor: [{ avg: 50, var: 10 }, { avg: 255, var: 0 }, { avg: 200, var: 10 }, { avg: 250, var: 0 }],
60- posOffset: [{ avg: 0.55, var: 0.06 },{ avg: 0.65, var: -0.9 },{ avg: 0.0, var: -0.35 }],
55+ hsvaColor: [{ avg: 34, var: 10 }, { avg: 255, var: 0 }, { avg: 240, var: 10 }, { avg: 200, var: 50 }],
56+ posOffset: [{ avg: 0.1, var: 0.5 },{ avg: -0.2, var: 0.0 },{ avg: 0.1, var: 0.25 }],
6157 velocity: [{ avg: 0.1, var: 0.5 },{ avg: 0.1, var: -0.1 },{ avg: -0.2, var: -0.1 }],
6258 opacityEvolve: { transform: "linear", factor: -90 },
6359 gravityEffect: { avg: -0.02, var: 0.0 },
@@ -76,7 +72,8 @@
7672 "place": "game:block/anvil",
7773 "break": "game:block/anvil",
7874 "hit": "game:block/anvil",
79- ambientByType: { "*-lit": "game:effect/embers" }
75+ ambientByType: { "*-lit": "game:effect/embers" },
76+ insideByType: { "*-lit": "game:effect/extinguish1" },
8077 },
8178 drops: [
8279 { type: "block", code: "brazier-empty", quantity: { avg: 1 } }
--- a/Assorted/assets/defensive/lang/en.json
+++ b/Assorted/assets/defensive/lang/en.json
@@ -26,7 +26,7 @@
2626 "defensive:blockdesc-log_barricade-*":"A rough barrier fit for the Frontier.",
2727 "defensive:blockdesc-crusie_lamp-*":"Burn that midnight fuel faster.",
2828 "defensive:blockdesc-brazier-empty":"Needs fuel...",
29- "defensive:blockdesc-brazier-extinct":"Needs fuel again...",
29+ "defensive:blockdesc-brazier-extinguished":"Needs fuel again...",
3030 "defensive:blockdesc-brazier-lit":"What a lovely warm glow.",
3131
3232 "game:tabname-defensive":"Defensive Stuff",