mirror of
https://git.muiegratis.online/suikoakari/Campofinale
synced 2025-12-12 17:44:37 +01:00
working conveyors and implemented furnace build
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Campofinale.Game.Factory
|
|||||||
{
|
{
|
||||||
public class BlockCalculator
|
public class BlockCalculator
|
||||||
{
|
{
|
||||||
public static int CalculateTotalBlocks(List<Vector3f> points)
|
public static float CalculateTotalBlocks(List<Vector3f> points)
|
||||||
{
|
{
|
||||||
if (points == null || points.Count < 2)
|
if (points == null || points.Count < 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Campofinale.Resource;
|
using Campofinale.Resource;
|
||||||
using static Campofinale.Resource.ResourceManager;
|
using static Campofinale.Resource.ResourceManager;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Campofinale.Game.Factory.BuildingsBehaviour
|
namespace Campofinale.Game.Factory.BuildingsBehaviour
|
||||||
{
|
{
|
||||||
@@ -20,18 +21,30 @@ namespace Campofinale.Game.Factory.BuildingsBehaviour
|
|||||||
public int currentProgress = 0;
|
public int currentProgress = 0;
|
||||||
public override void Init(FactoryChapter chapter, FactoryNode node)
|
public override void Init(FactoryChapter chapter, FactoryNode node)
|
||||||
{
|
{
|
||||||
FComponentCache cache1 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheIn1).Init();
|
FComponentCache cache1 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheIn1).Init();
|
||||||
FComponentCache cache2 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheOut1).Init();
|
FComponentCache cache2 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheOut1).Init();
|
||||||
FComponentProducer producer = (FComponentProducer)new FComponentProducer(chapter.nextCompV()).Init();
|
FComponentProducer producer = (FComponentProducer)new FComponentProducer(chapter.nextCompV()).Init();
|
||||||
node.components.Add(producer);
|
node.components.Add(producer);
|
||||||
node.components.Add(new FComponentFormulaMan(chapter.nextCompV()).Init());
|
node.components.Add(new FComponentFormulaMan(chapter.nextCompV()).Init());
|
||||||
node.components.Add(cache1);
|
node.components.Add(cache1);
|
||||||
node.components.Add(cache2);
|
node.components.Add(cache2);
|
||||||
inputCacheId = cache1.compId;
|
inputCacheId = cache1.compId;
|
||||||
outputCacheId = cache2.compId;
|
outputCacheId = cache2.compId;
|
||||||
producerId = producer.compId;
|
producerId = producer.compId;
|
||||||
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 3,cache1).Init());
|
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 3, cache1).Init());
|
||||||
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 3, cache2).Init());
|
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 3, cache2).Init());
|
||||||
|
}
|
||||||
|
public string GetFormulaGroupId(string templateId)
|
||||||
|
{
|
||||||
|
FactoryMachineCraftTable table = factoryMachineCraftTable.Values.ToList().Find(r => r.machineId == templateId);
|
||||||
|
if (table != null)
|
||||||
|
{
|
||||||
|
return table.formulaGroupId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public override void Update(FactoryChapter chapter, FactoryNode node)
|
public override void Update(FactoryChapter chapter, FactoryNode node)
|
||||||
{
|
{
|
||||||
@@ -41,8 +54,12 @@ namespace Campofinale.Game.Factory.BuildingsBehaviour
|
|||||||
FComponentProducer producer = node.GetComponent<FComponentProducer>(producerId);
|
FComponentProducer producer = node.GetComponent<FComponentProducer>(producerId);
|
||||||
FComponentCache inCache = node.GetComponent<FComponentCache>(inputCacheId);
|
FComponentCache inCache = node.GetComponent<FComponentCache>(inputCacheId);
|
||||||
FComponentCache outCache = node.GetComponent<FComponentCache>(outputCacheId);
|
FComponentCache outCache = node.GetComponent<FComponentCache>(outputCacheId);
|
||||||
|
FComponentFormulaMan formulaManager = node.GetComponent<FComponentFormulaMan>();
|
||||||
|
|
||||||
|
if (formulaManager == null) return;
|
||||||
|
formulaManager.currentGroup = GetFormulaGroupId(node.templateId);
|
||||||
FactoryMachineCraftTable craftingRecipe = null;
|
FactoryMachineCraftTable craftingRecipe = null;
|
||||||
string recipe = ResourceManager.FindFactoryMachineCraftIdUsingCacheItems(inCache.items);
|
string recipe = ResourceManager.FindFactoryMachineCraftIdUsingCacheItems(inCache.items,formulaManager.currentGroup);
|
||||||
producer.formulaId = recipe;
|
producer.formulaId = recipe;
|
||||||
ResourceManager.factoryMachineCraftTable.TryGetValue(producer.formulaId, out craftingRecipe);
|
ResourceManager.factoryMachineCraftTable.TryGetValue(producer.formulaId, out craftingRecipe);
|
||||||
|
|
||||||
@@ -73,7 +90,6 @@ namespace Campofinale.Game.Factory.BuildingsBehaviour
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
producer.inBlock = false;
|
|
||||||
producer.inProduce = false;
|
producer.inProduce = false;
|
||||||
producer.progress = 0;
|
producer.progress = 0;
|
||||||
}
|
}
|
||||||
@@ -85,18 +101,7 @@ namespace Campofinale.Game.Factory.BuildingsBehaviour
|
|||||||
producer.progress = 0;
|
producer.progress = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* ScFactoryModifyChapterComponents update = new()
|
|
||||||
{
|
|
||||||
ChapterId = chapter.chapterId,
|
|
||||||
Tms = DateTime.UtcNow.ToUnixTimestampMilliseconds()/1000,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var comp in node.components)
|
|
||||||
{
|
|
||||||
update.Components.Add(comp.ToProto());
|
|
||||||
}
|
|
||||||
chapter.GetOwner().Send(ScMsgId.ScFactoryModifyChapterComponents, update);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
using Campofinale.Game.Factory.Components;
|
||||||
|
using Campofinale.Protocol;
|
||||||
|
using Campofinale.Resource;
|
||||||
|
using Campofinale.Resource.Table;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Campofinale.Resource;
|
||||||
|
using static Campofinale.Resource.ResourceManager;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace Campofinale.Game.Factory.BuildingsBehaviour
|
||||||
|
{
|
||||||
|
public class NodeBuilding_ProducerFurnace : NodeBuildingBehaviour
|
||||||
|
{
|
||||||
|
public uint inputCacheId = 0;
|
||||||
|
public uint outputCacheId = 0;
|
||||||
|
public uint inputCacheIdFluid = 0;
|
||||||
|
public uint outputCacheIdFluid = 0;
|
||||||
|
public uint producerId = 0;
|
||||||
|
public int currentProgress = 0;
|
||||||
|
public override void Init(FactoryChapter chapter, FactoryNode node)
|
||||||
|
{
|
||||||
|
FComponentCache cache1 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheIn1).Init();
|
||||||
|
FComponentCache cache2 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheOut1).Init();
|
||||||
|
FComponentCache cache3 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheFluidIn1).Init();
|
||||||
|
FComponentCache cache4 = (FComponentCache)new FComponentCache(chapter.nextCompV(), FCComponentPos.CacheFluidOut1).Init();
|
||||||
|
FComponentProducer producer = (FComponentProducer)new FComponentProducer(chapter.nextCompV()).Init();
|
||||||
|
node.components.Add(producer);
|
||||||
|
node.components.Add(new FComponentFormulaMan(chapter.nextCompV()).Init());
|
||||||
|
node.components.Add(cache1);
|
||||||
|
node.components.Add(cache2);
|
||||||
|
node.components.Add(cache3);
|
||||||
|
node.components.Add(cache4);
|
||||||
|
inputCacheId = cache1.compId;
|
||||||
|
outputCacheId = cache2.compId;
|
||||||
|
inputCacheIdFluid = cache3.compId;
|
||||||
|
outputCacheIdFluid = cache4.compId;
|
||||||
|
producerId = producer.compId;
|
||||||
|
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 4, cache1).Init());
|
||||||
|
node.components.Add(new FComponentPortManager(chapter.nextCompV(), 4, cache2).Init());
|
||||||
|
}
|
||||||
|
public string GetFormulaGroupId(string templateId)
|
||||||
|
{
|
||||||
|
FactoryMachineCraftTable table = factoryMachineCraftTable.Values.ToList().Find(r => r.machineId == templateId);
|
||||||
|
if (table != null)
|
||||||
|
{
|
||||||
|
return table.formulaGroupId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void Update(FactoryChapter chapter, FactoryNode node)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (node.powered)
|
||||||
|
{
|
||||||
|
FComponentProducer producer = node.GetComponent<FComponentProducer>(producerId);
|
||||||
|
FComponentCache inCache = node.GetComponent<FComponentCache>(inputCacheId);
|
||||||
|
FComponentCache outCache = node.GetComponent<FComponentCache>(outputCacheId);
|
||||||
|
FComponentFormulaMan formulaManager = node.GetComponent<FComponentFormulaMan>();
|
||||||
|
|
||||||
|
if (formulaManager == null) return;
|
||||||
|
formulaManager.currentGroup = GetFormulaGroupId(node.templateId);
|
||||||
|
FactoryMachineCraftTable craftingRecipe = null;
|
||||||
|
string recipe = ResourceManager.FindFactoryMachineCraftIdUsingCacheItems(inCache.items,formulaManager.currentGroup);
|
||||||
|
producer.formulaId = recipe;
|
||||||
|
ResourceManager.factoryMachineCraftTable.TryGetValue(producer.formulaId, out craftingRecipe);
|
||||||
|
|
||||||
|
if (craftingRecipe != null)
|
||||||
|
{
|
||||||
|
producer.inBlock = outCache.IsFull();
|
||||||
|
if (craftingRecipe.CacheHaveItems(inCache) && !outCache.IsFull())
|
||||||
|
{
|
||||||
|
producer.inProduce = true;
|
||||||
|
|
||||||
|
producer.lastFormulaId = recipe;
|
||||||
|
producer.progress += craftingRecipe.totalProgress/craftingRecipe.progressRound;
|
||||||
|
currentProgress++;
|
||||||
|
if (currentProgress >= craftingRecipe.progressRound)
|
||||||
|
{
|
||||||
|
currentProgress = 0;
|
||||||
|
List<ItemCount> toConsume = craftingRecipe.GetIngredients();
|
||||||
|
inCache.ConsumeItems(toConsume);
|
||||||
|
craftingRecipe.outcomes.ForEach(e =>
|
||||||
|
{
|
||||||
|
e.group.ForEach(i =>
|
||||||
|
{
|
||||||
|
outCache.AddItem(i.id, i.count);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
producer.inProduce = false;
|
||||||
|
producer.progress = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
producer.inBlock = false;
|
||||||
|
producer.inProduce = false;
|
||||||
|
producer.progress = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,14 +10,17 @@ namespace Campofinale.Game.Factory.Components
|
|||||||
public List<ItemCount> items = new();
|
public List<ItemCount> items = new();
|
||||||
public FComponentBoxConveyor(uint id) : base(id, FCComponentType.BoxConveyor,FCComponentPos.BoxConveyor)
|
public FComponentBoxConveyor(uint id) : base(id, FCComponentType.BoxConveyor,FCComponentPos.BoxConveyor)
|
||||||
{
|
{
|
||||||
|
lastPopTms=DateTime.UtcNow.ToUnixTimestampMilliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void SetComponentInfo(ScdFacCom proto)
|
public override void SetComponentInfo(ScdFacCom proto)
|
||||||
{
|
{
|
||||||
if (items == null)
|
if (items == null)
|
||||||
{
|
{
|
||||||
items = new List<ItemCount>();
|
items = new List<ItemCount>();
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.BoxConveyor = new()
|
proto.BoxConveyor = new()
|
||||||
{
|
{
|
||||||
LastPopTms = lastPopTms,
|
LastPopTms = lastPopTms,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Campofinale.Resource;
|
using Campofinale.Resource;
|
||||||
using static Campofinale.Game.Factory.FactoryNode;
|
|
||||||
|
|
||||||
namespace Campofinale.Game.Factory.Components
|
namespace Campofinale.Game.Factory.Components
|
||||||
{
|
{
|
||||||
@@ -7,28 +7,24 @@ namespace Campofinale.Game.Factory.Components
|
|||||||
{
|
{
|
||||||
public string currentGroup = "group_grinder_normal";
|
public string currentGroup = "group_grinder_normal";
|
||||||
public string currentMode = "normal";
|
public string currentMode = "normal";
|
||||||
|
public List<string> formulaIds = new();
|
||||||
public FComponentFormulaMan(uint id) : base(id, FCComponentType.FormulaMan)
|
public FComponentFormulaMan(uint id) : base(id, FCComponentType.FormulaMan)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public List<string> GetFormulaIds()
|
||||||
|
{
|
||||||
|
List<string> ids = ResourceManager.factoryMachineCraftTable.Where(i => i.Value.formulaGroupId == currentGroup).Select(i => i.Value.id).ToList();
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
public override void SetComponentInfo(ScdFacCom proto)
|
public override void SetComponentInfo(ScdFacCom proto)
|
||||||
{
|
{
|
||||||
|
formulaIds = GetFormulaIds();
|
||||||
proto.FormulaMan = new()
|
proto.FormulaMan = new()
|
||||||
{
|
{
|
||||||
CurrentGroup = currentGroup,
|
CurrentGroup = currentGroup,
|
||||||
CurrentMode = currentMode,
|
CurrentMode = currentMode,
|
||||||
FormulaIds = {
|
FormulaIds = {
|
||||||
"grinder_iron_powder_1",
|
formulaIds
|
||||||
"grinder_quartz_powder_1",
|
|
||||||
"grinder_originium_powder_1",
|
|
||||||
"grinder_carbon_powder_1",
|
|
||||||
"grinder_crystal_powder_1",
|
|
||||||
"grinder_plant_moss_powder_1_1",
|
|
||||||
"grinder_plant_moss_powder_2_1",
|
|
||||||
"grinder_plant_moss_powder_3_1",
|
|
||||||
"grinder_plant_bbflower_powder_1_1",
|
|
||||||
"grinder_plant_grass_powder_1_1",
|
|
||||||
"grinder_plant_grass_powder_2_1"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Campofinale.Game.Factory.BuildingsBehaviour;
|
|||||||
using static Campofinale.Resource.ResourceManager.FactoryBuildingTable;
|
using static Campofinale.Resource.ResourceManager.FactoryBuildingTable;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Campofinale.Game.Inventory;
|
||||||
|
|
||||||
namespace Campofinale.Game.Factory
|
namespace Campofinale.Game.Factory
|
||||||
{
|
{
|
||||||
@@ -55,14 +56,27 @@ namespace Campofinale.Game.Factory
|
|||||||
lastPowered = powered;
|
lastPowered = powered;
|
||||||
chapter.GetOwner().Send(new PacketScFactoryModifyChapterNodes(chapter.GetOwner(), chapter.chapterId, this));
|
chapter.GetOwner().Send(new PacketScFactoryModifyChapterNodes(chapter.GetOwner(), chapter.chapterId, this));
|
||||||
}
|
}
|
||||||
if (nodeBehaviour != null)
|
if (nodeBehaviour != null && !deactive)
|
||||||
{
|
{
|
||||||
nodeBehaviour.Update(chapter,this);
|
nodeBehaviour.Update(chapter,this);
|
||||||
}
|
}
|
||||||
foreach(var comp in components.FindAll(c=> c is FComponentPortManager))
|
foreach (var comp in components.FindAll(c => c is FComponentPortManager))
|
||||||
{
|
{
|
||||||
UpdatePortManager(chapter, (FComponentPortManager)comp);
|
var portmanager = (FComponentPortManager)comp;
|
||||||
|
if (portmanager.customPos != FCComponentPos.PortOutManager)
|
||||||
|
{
|
||||||
|
UpdatePortManager(chapter, portmanager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
foreach (var comp in components.FindAll(c => c is FComponentPortManager))
|
||||||
|
{
|
||||||
|
var portmanager = (FComponentPortManager)comp;
|
||||||
|
if (portmanager.customPos == FCComponentPos.PortOutManager)
|
||||||
|
{
|
||||||
|
UpdatePortManager(chapter, portmanager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void UpdatePortManager(FactoryChapter chapter,FComponentPortManager manager)
|
public void UpdatePortManager(FactoryChapter chapter,FComponentPortManager manager)
|
||||||
{
|
{
|
||||||
@@ -99,7 +113,7 @@ namespace Campofinale.Game.Factory
|
|||||||
FComponentBoxConveyor output = chapter.GetCompById<FComponentBoxConveyor>(port.touchComId);
|
FComponentBoxConveyor output = chapter.GetCompById<FComponentBoxConveyor>(port.touchComId);
|
||||||
FComponentCache outputCache = chapter.GetCompById<FComponentCache>(port.ownerComId);
|
FComponentCache outputCache = chapter.GetCompById<FComponentCache>(port.ownerComId);
|
||||||
FactoryNode conveyorNode = chapter.GetNodeByCompId(port.touchComId);
|
FactoryNode conveyorNode = chapter.GetNodeByCompId(port.touchComId);
|
||||||
if(outputCache!=null && output != null && conveyorNode != null)
|
if (outputCache != null && output != null && conveyorNode != null)
|
||||||
{
|
{
|
||||||
bool did = false;
|
bool did = false;
|
||||||
outputCache.items.ForEach(i =>
|
outputCache.items.ForEach(i =>
|
||||||
@@ -109,22 +123,20 @@ namespace Campofinale.Game.Factory
|
|||||||
ItemCount add = new ItemCount()
|
ItemCount add = new ItemCount()
|
||||||
{
|
{
|
||||||
id = i.id,
|
id = i.id,
|
||||||
count = 1,
|
count = 1
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (conveyorNode.AddConveyorItem(add))
|
||||||
if (conveyorNode.AddConveyorItem(i))
|
|
||||||
{
|
{
|
||||||
did = true;
|
did = true;
|
||||||
outputCache.ConsumeItems(new List<ItemCount>() { add });
|
outputCache.ConsumeItems(new List<ItemCount>() { add });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -137,7 +149,7 @@ namespace Campofinale.Game.Factory
|
|||||||
c.nodeType == FCNodeType.BoxConveyor &&
|
c.nodeType == FCNodeType.BoxConveyor &&
|
||||||
c.points.Any(p => p.x == back.x && p.y == back.y && p.z == back.z));
|
c.points.Any(p => p.x == back.x && p.y == back.y && p.z == back.z));
|
||||||
var compPort = manager.ports.Find(p => p.index == port.index);
|
var compPort = manager.ports.Find(p => p.index == port.index);
|
||||||
|
|
||||||
if (compPort != null)
|
if (compPort != null)
|
||||||
{
|
{
|
||||||
if (node != null)
|
if (node != null)
|
||||||
@@ -151,24 +163,65 @@ namespace Campofinale.Game.Factory
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Input items
|
||||||
|
foreach (var port in manager.ports)
|
||||||
|
{
|
||||||
|
FComponentBoxConveyor input = chapter.GetCompById<FComponentBoxConveyor>(port.touchComId);
|
||||||
|
FComponentCache inputCache = chapter.GetCompById<FComponentCache>(port.ownerComId);
|
||||||
|
FactoryNode conveyorNode = chapter.GetNodeByCompId(port.touchComId);
|
||||||
|
if (inputCache != null && input != null && conveyorNode != null)
|
||||||
|
{
|
||||||
|
bool did = false;
|
||||||
|
ItemCount toRemove = null;
|
||||||
|
foreach (var item in input.items)
|
||||||
|
{
|
||||||
|
if (!did && item.count > 0 && item.IsItemAtConveyorEnd(BlockCalculator.CalculateTotalBlocks(conveyorNode.points)))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!inputCache.IsFull())
|
||||||
|
{
|
||||||
|
did = true;
|
||||||
|
toRemove = item;
|
||||||
|
inputCache.AddItem(item.id, item.count);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(toRemove!=null)
|
||||||
|
input.items.Remove(toRemove);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AddConveyorItem(ItemCount i)
|
private bool AddConveyorItem(ItemCount i)
|
||||||
{
|
{
|
||||||
int length=BlockCalculator.CalculateTotalBlocks(points);
|
float length=BlockCalculator.CalculateTotalBlocks(points);
|
||||||
FComponentBoxConveyor conveyorComp = GetComponent<FComponentBoxConveyor>();
|
FComponentBoxConveyor conveyorComp = GetComponent<FComponentBoxConveyor>();
|
||||||
if (conveyorComp != null)
|
if (conveyorComp != null)
|
||||||
{
|
{
|
||||||
if(conveyorComp.items.Count < length)
|
if(conveyorComp.items.Count < (int)length)
|
||||||
{
|
{
|
||||||
conveyorComp.items.Add(i);
|
long timestamp = i.tms - conveyorComp.lastPopTms;
|
||||||
int size = BlockCalculator.CalculateTotalBlocks(points) - 1;
|
if(timestamp >= 2000)
|
||||||
conveyorComp.lastPopTms = i.tms;
|
{
|
||||||
return true;
|
conveyorComp.items.Add(i);
|
||||||
|
i.tms = DateTime.UtcNow.ToUnixTimestampMilliseconds();
|
||||||
|
conveyorComp.lastPopTms = i.tms;
|
||||||
|
Logger.Print("Spawning item in conveyor: " + conveyorComp.lastPopTms);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -413,7 +466,14 @@ namespace Campofinale.Game.Factory
|
|||||||
components.Add(new FComponentBattle(chapter.nextCompV()).Init());
|
components.Add(new FComponentBattle(chapter.nextCompV()).Init());
|
||||||
break;
|
break;
|
||||||
case FCNodeType.Producer:
|
case FCNodeType.Producer:
|
||||||
nodeBehaviour=new NodeBuilding_Producer();
|
if (templateId == "grinder_1")
|
||||||
|
{
|
||||||
|
nodeBehaviour = new NodeBuilding_Producer();
|
||||||
|
}else if (templateId == "furnance_1")
|
||||||
|
{
|
||||||
|
nodeBehaviour = new NodeBuilding_ProducerFurnace();
|
||||||
|
}
|
||||||
|
if(nodeBehaviour!=null)
|
||||||
nodeBehaviour.Init(chapter, this);
|
nodeBehaviour.Init(chapter, this);
|
||||||
break;
|
break;
|
||||||
case FCNodeType.BoxConveyor:
|
case FCNodeType.BoxConveyor:
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ namespace Campofinale.Packets.Cs
|
|||||||
IsFirstLogin = false,
|
IsFirstLogin = false,
|
||||||
IsReconnect=false,
|
IsReconnect=false,
|
||||||
LastRecvUpSeqid = packet.csHead.UpSeqid,
|
LastRecvUpSeqid = packet.csHead.UpSeqid,
|
||||||
|
ServerTimeZone=2,
|
||||||
|
ServerTime=DateTime.UtcNow.ToUnixTimestampMilliseconds(),
|
||||||
};
|
};
|
||||||
byte[] encKey = GenerateRandomBytes(32);
|
byte[] encKey = GenerateRandomBytes(32);
|
||||||
string serverPublicKeyPem = req.ClientPublicKey.ToStringUtf8();
|
string serverPublicKeyPem = req.ClientPublicKey.ToStringUtf8();
|
||||||
|
|||||||
@@ -341,12 +341,12 @@ namespace Campofinale.Resource
|
|||||||
return strIdNumTable.item_id.dic[item_id];
|
return strIdNumTable.item_id.dic[item_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FindFactoryMachineCraftIdUsingCacheItems(List<ItemCount> items)
|
public static string FindFactoryMachineCraftIdUsingCacheItems(List<ItemCount> items, string group)
|
||||||
{
|
{
|
||||||
// Estrae solo gli ID degli items in input e li ordina
|
// Estrae solo gli ID degli items in input e li ordina
|
||||||
var inputItemIds = items.Select(item => item.id).OrderBy(id => id).ToList();
|
var inputItemIds = items.Select(item => item.id).OrderBy(id => id).ToList();
|
||||||
|
|
||||||
foreach (var recipe in factoryMachineCraftTable.Values.ToList())
|
foreach (var recipe in factoryMachineCraftTable.Values.ToList().FindAll(r=>r.formulaGroupId==group))
|
||||||
{
|
{
|
||||||
// Raccoglie tutti gli ID degli ingredienti della ricetta
|
// Raccoglie tutti gli ID degli ingredienti della ricetta
|
||||||
var recipeItemIds = new List<string>();
|
var recipeItemIds = new List<string>();
|
||||||
@@ -386,8 +386,16 @@ namespace Campofinale.Resource
|
|||||||
{
|
{
|
||||||
Count = count,
|
Count = count,
|
||||||
Id = id,
|
Id = id,
|
||||||
|
Tms = tms
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public bool IsItemAtConveyorEnd(float conveyorSize)
|
||||||
|
{
|
||||||
|
long spawnTms = tms;
|
||||||
|
long endTms = spawnTms + (long)(2000 * conveyorSize);
|
||||||
|
long cur = DateTime.UtcNow.ToUnixTimestampMilliseconds();
|
||||||
|
return cur > endTms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class FactoryBuildingTable
|
public class FactoryBuildingTable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Campofinale.Resource.Table
|
|||||||
public int progressRound;
|
public int progressRound;
|
||||||
public long totalProgress;
|
public long totalProgress;
|
||||||
public int signal;
|
public int signal;
|
||||||
|
public string formulaGroupId;
|
||||||
public List<FactoryMachineCraftIngredient> ingredients = new();
|
public List<FactoryMachineCraftIngredient> ingredients = new();
|
||||||
public List<FactoryMachineCraftIngredient> outcomes = new();
|
public List<FactoryMachineCraftIngredient> outcomes = new();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user