This repository has been archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from NotoriousPyro/1.0.3-pre
1.0.3 pre
- Loading branch information
Showing
23 changed files
with
444 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root=true | ||
|
||
[*.cs] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ Builds/ | |
*.suo | ||
*.user | ||
.vsconfig | ||
dist/ | ||
release/ | ||
|
||
# Windows rubbish | ||
Thumbs.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Mafi.Core.Economy; | ||
using Mafi.Core.Entities.Static; | ||
using Mafi.Core.Prototypes; | ||
using Mafi.Core.Factory.Sorters; | ||
|
||
|
||
namespace Mafi.Core.Mods; | ||
|
||
public class SorterProtoBuilder : IProtoBuilder | ||
{ | ||
public class State : LayoutEntityBuilderState<State> | ||
{ | ||
private readonly StaticEntityProto.ID m_id; | ||
|
||
public State(SorterProtoBuilder builder, StaticEntityProto.ID id, string name) | ||
: base(builder, id, name) | ||
{ | ||
m_id = id; | ||
} | ||
|
||
[MustUseReturnValue] | ||
public override State Description(string description, string explanation = "short description of a machine") | ||
{ | ||
return base.Description(description, explanation); | ||
} | ||
|
||
[MustUseReturnValue] | ||
public State SetElectricityConsumption(Electricity electricity) | ||
{ | ||
base.Electricity = electricity; | ||
return (State)this; | ||
} | ||
|
||
[MustUseReturnValue] | ||
public State SetDeconstructionParams(AssetValue productGiven, EntityCosts entityCosts) | ||
{ | ||
// Assert.That(productGiven.IsNotEmpty).IsTrue(); | ||
// Assert.That(durationPerProduct).IsPositive(); | ||
// m_durationPerProduct = durationPerProduct; | ||
// m_productsGiven = productGiven; | ||
return this; | ||
} | ||
|
||
public SorterProto BuildAndAdd() | ||
{ | ||
return AddToDb(new SorterProto(m_id, base.Strings, layout: base.LayoutOrThrow, productsFilter: base.ProductsFilterOrThrow, costs: base.Costs, base.Electricity, graphics: base.Graphics)); | ||
} | ||
} | ||
|
||
public ProtosDb ProtosDb => Registrator.PrototypesDb; | ||
|
||
public ProtoRegistrator Registrator | ||
{ | ||
get; | ||
} | ||
|
||
public SorterProtoBuilder(ProtoRegistrator registrator) | ||
: base() | ||
{ | ||
Registrator = registrator; | ||
} | ||
|
||
public State Start(string name, StaticEntityProto.ID labId) | ||
{ | ||
return new State(this, labId, name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Mafi.Core.Economy; | ||
using Mafi.Core.Entities.Static; | ||
using Mafi.Core.Prototypes; | ||
using Mafi.Core.Factory.Zippers; | ||
|
||
|
||
namespace Mafi.Core.Mods; | ||
|
||
public class ZipperProtoBuilder : IProtoBuilder | ||
{ | ||
public class State : LayoutEntityBuilderState<State> | ||
{ | ||
private readonly StaticEntityProto.ID m_id; | ||
|
||
public State(ZipperProtoBuilder builder, StaticEntityProto.ID id, string name) | ||
: base(builder, id, name) | ||
{ | ||
m_id = id; | ||
} | ||
|
||
[MustUseReturnValue] | ||
public override State Description(string description, string explanation = "short description of a machine") | ||
{ | ||
return base.Description(description, explanation); | ||
} | ||
|
||
[MustUseReturnValue] | ||
public State SetElectricityConsumption(Electricity electricity) | ||
{ | ||
base.Electricity = electricity; | ||
return (State)this; | ||
} | ||
|
||
[MustUseReturnValue] | ||
public State SetDeconstructionParams(AssetValue productGiven, EntityCosts entityCosts) | ||
{ | ||
// Assert.That(productGiven.IsNotEmpty).IsTrue(); | ||
// Assert.That(durationPerProduct).IsPositive(); | ||
// m_durationPerProduct = durationPerProduct; | ||
// m_productsGiven = productGiven; | ||
return this; | ||
} | ||
|
||
public ZipperProto BuildAndAdd() | ||
{ | ||
return AddToDb(new ZipperProto(m_id, base.Strings, layout: base.LayoutOrThrow, costs: base.Costs, base.Electricity, graphics: base.Graphics)); | ||
} | ||
} | ||
|
||
public ProtosDb ProtosDb => Registrator.PrototypesDb; | ||
|
||
public ProtoRegistrator Registrator | ||
{ | ||
get; | ||
} | ||
|
||
public ZipperProtoBuilder(ProtoRegistrator registrator) | ||
: base() | ||
{ | ||
Registrator = registrator; | ||
} | ||
|
||
public State Start(string name, StaticEntityProto.ID labId) | ||
{ | ||
return new State(this, labId, name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Mafi.Core.Mods; | ||
|
||
public static class ProtoRegistratorEx | ||
{ | ||
public static ZipperProtoBuilder ZipperProtoBuilder(this ProtoRegistrator registrator) => new ZipperProtoBuilder(registrator); | ||
public static SorterProtoBuilder SorterProtoBuilder(this ProtoRegistrator registrator) => new SorterProtoBuilder(registrator); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Mafi.Core.Ports.Io; | ||
using Mafi.Core.Factory.Zippers; | ||
using Mafi.Core.Factory.Sorters; | ||
using System; | ||
|
||
namespace Mafi.Core.Prototypes; | ||
|
||
public static class ProtosDbEx | ||
{ | ||
public static ZipperProto GetZipperProto(this ProtosDb protosDb, IoPortShapeProto.ID portShape) => | ||
protosDb.GetOrThrow<ZipperProto>(IdsCore.Transports.GetZipperIdFor(portShape)); | ||
public static SorterProto GetSorterProto(this ProtosDb protosDb, IoPortShapeProto.ID portShape) => | ||
protosDb.GetOrThrow<SorterProto>(IdsCore.Transports.GetSorterIdFor(portShape)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Mafi.Base; | ||
using Mafi.Core; | ||
using Mafi.Core.Mods; | ||
using Mafi.Core.Ports.Io; | ||
using Mafi.Core.Entities.Static.Layout; | ||
using Mafi.Core.Prototypes; | ||
using Mafi.Core.Factory.Zippers; | ||
using Mafi.Core.Factory.Machines; | ||
|
||
namespace UnpoweredBalancers.Machines; | ||
|
||
internal class UnpoweredBalancersData : IModData | ||
{ | ||
public void RegisterData(ProtoRegistrator registrator) | ||
{ | ||
ZipperProto flatZipperProto = registrator.PrototypesDb.GetZipperProto(Ids.IoPortShapes.FlatConveyor); | ||
ZipperProto moltenZipperProto = registrator.PrototypesDb.GetZipperProto(Ids.IoPortShapes.MoltenMetalChannel); | ||
ZipperProto uShapeZipperProto = registrator.PrototypesDb.GetZipperProto(Ids.IoPortShapes.LooseMaterialConveyor); | ||
ZipperProto pipeZipperProto = registrator.PrototypesDb.GetZipperProto(Ids.IoPortShapes.Pipe); | ||
|
||
register( | ||
registrator, | ||
Ids.IoPortShapes.FlatConveyor, | ||
UnpoweredBalancersIds.Machines.UnpoweredFlatBalancer, | ||
"Flat", | ||
Assets.Base.Zippers.BalancerFlat_prefab, | ||
flatZipperProto.Graphics.IconPath, | ||
Costs.Build.CP3(6) | ||
); | ||
register( | ||
registrator, | ||
Ids.IoPortShapes.MoltenMetalChannel, | ||
UnpoweredBalancersIds.Machines.UnpoweredMoltenBalancer, | ||
"Molten", | ||
Assets.Base.Zippers.BalancerMolten_prefab, | ||
moltenZipperProto.Graphics.IconPath, | ||
Costs.Build.CP3(9) | ||
); | ||
register( | ||
registrator, | ||
Ids.IoPortShapes.LooseMaterialConveyor, | ||
UnpoweredBalancersIds.Machines.UnpoweredUShapeBalancer, | ||
"U-shape", | ||
Assets.Base.Zippers.BalancerUShape_prefab, | ||
uShapeZipperProto.Graphics.IconPath, | ||
Costs.Build.CP3(9) | ||
); | ||
register( | ||
registrator, | ||
Ids.IoPortShapes.Pipe, | ||
UnpoweredBalancersIds.Machines.UnpoweredPipeBalancer, | ||
"Pipe", | ||
Assets.Base.Zippers.BalancerFluid_prefab, | ||
pipeZipperProto.Graphics.IconPath, | ||
Costs.Build.CP3(6) | ||
); | ||
} | ||
|
||
private void register( | ||
ProtoRegistrator registrator, | ||
IoPortShapeProto.ID portShape, | ||
MachineProto.ID id, | ||
string name, | ||
string prefab, | ||
string icon, | ||
EntityCostsTpl costs | ||
) => registrator.ZipperProtoBuilder() | ||
.Start($"Unpowered {name} balancer", id) | ||
.Description($"Allows distributing and prioritizing products using any of its two input and output ports.") | ||
.SetCost(costs) | ||
.SetElectricityConsumption(Mafi.Electricity.Zero) | ||
.SetLayout( | ||
new EntityLayoutParams(null, useNewLayoutSyntax: true, null, portsCanOnlyConnectToTransports: true), | ||
Ports.SetLayout(registrator.PrototypesDb.GetOrThrow<IoPortShapeProto>(portShape).LayoutChar, " D?+C?+ ", "E?+[1][1]+?B", "F?+[1][1]+?A", " G?+H?+ ") | ||
) | ||
.SetCategories(Ids.ToolbarCategories.Transports) | ||
.SetPrefabPath(prefab) | ||
.SetCustomIconPath(icon) | ||
.BuildAndAdd(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Mafi.Base; | ||
using Mafi.Core.Products; | ||
using Mafi.Core.Mods; | ||
using Mafi.Core.Ports.Io; | ||
using Mafi.Core.Entities.Static.Layout; | ||
using Mafi.Core.Prototypes; | ||
using Mafi.Core.Factory.Sorters; | ||
using Mafi.Core.Factory.Machines; | ||
|
||
namespace UnpoweredBalancers.Machines; | ||
|
||
internal class UnpoweredSortersData : IModData | ||
{ | ||
public void RegisterData(ProtoRegistrator registrator) | ||
{ | ||
SorterProto flatSorterProto = registrator.PrototypesDb.GetSorterProto(Ids.IoPortShapes.FlatConveyor); | ||
SorterProto uShapeSorterProto = registrator.PrototypesDb.GetSorterProto(Ids.IoPortShapes.LooseMaterialConveyor); | ||
|
||
register( | ||
registrator, | ||
Ids.IoPortShapes.FlatConveyor, | ||
UnpoweredBalancersIds.Machines.UnpoweredFlatSorter, | ||
CountableProductProto.ProductType, | ||
"Flat", | ||
Assets.Base.Zippers.SorterFlat_prefab, | ||
flatSorterProto.Graphics.IconPath, | ||
Costs.Build.CP3(6) | ||
); | ||
register( | ||
registrator, | ||
Ids.IoPortShapes.LooseMaterialConveyor, | ||
UnpoweredBalancersIds.Machines.UnpoweredUShapeSorter, | ||
LooseProductProto.ProductType, | ||
"U-shape", | ||
Assets.Base.Zippers.SorterUShape_prefab, | ||
uShapeSorterProto.Graphics.IconPath, | ||
Costs.Build.CP3(9) | ||
); | ||
} | ||
|
||
private void register( | ||
ProtoRegistrator registrator, | ||
IoPortShapeProto.ID portShape, | ||
MachineProto.ID id, | ||
ProductType productType, | ||
string name, | ||
string prefab, | ||
string icon, | ||
EntityCostsTpl costs | ||
) => registrator.SorterProtoBuilder() | ||
.Start($"Unpowered {name} sorter", id) | ||
.Description($"Allows sorting of products.") | ||
.SetCost(costs) | ||
.SetElectricityConsumption(Mafi.Electricity.Zero) | ||
.SetLayout( | ||
new EntityLayoutParams(null, useNewLayoutSyntax: true), | ||
Ports.SetLayout(registrator.PrototypesDb.GetOrThrow<IoPortShapeProto>(portShape).LayoutChar, "A?>[1][1]>?X", " [1][1] ", " v?S ") | ||
) | ||
.SetCategories(Ids.ToolbarCategories.Transports) | ||
.SetProductsFilter( | ||
(ProductProto x) => x.Type == productType | ||
) | ||
.SetPrefabPath(prefab) | ||
.SetCustomIconPath(icon) | ||
.BuildAndAdd(); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.