Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/FluidWarpMod/FluidWarp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FluidWarpMod</RootNamespace>
<AssemblyName>FluidWarp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Source/FluidWarpMod/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public void LogFormat(LogType logType, UnityEngine.Object context, string format
}
}
#if DEBUG
static UnityEngine.Logger u_logger = new UnityEngine.Logger(new FileLogHandler("Mods" + Path.DirectorySeparatorChar + "_Logs" + Path.DirectorySeparatorChar + "FluidWarpMod.txt"));
static UnityEngine.Logger u_logger = new UnityEngine.Logger(new FileLogHandler("FluidWarpMod.txt"));
#endif

public static void Log(string message)
{
#if DEBUG
Expand Down
12 changes: 6 additions & 6 deletions Source/FluidWarpMod/WarpProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public override BuildingDef CreateBuildingDef()
string anim = "valveliquid_kanim";
int hitpoints = 30;
float construction_time = 5f;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER7;
string[] rAW_METALS = MATERIALS.REFINED_METALS;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER1;
string[] rAW_METALS = MATERIALS.ALL_METALS;
float melting_point = 1600f;
BuildLocationRule build_location_rule = BuildLocationRule.Anywhere;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER6;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER0;
BuildingDef buildingDef = BuildingTemplates.CreateBuildingDef(ID, width, height, anim, hitpoints, construction_time, tIER, rAW_METALS, melting_point, build_location_rule, BUILDINGS.DECOR.PENALTY.TIER5, tIER6, 0.2f);
buildingDef.InputConduitType = _conduitType;
buildingDef.OutputConduitType = ConduitType.None;
Expand Down Expand Up @@ -69,11 +69,11 @@ public override BuildingDef CreateBuildingDef()
string anim = "valvegas_kanim";
int hitpoints = 30;
float construction_time = 5f;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER7;
string[] rAW_METALS = MATERIALS.REFINED_METALS;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER1;
string[] rAW_METALS = MATERIALS.ALL_METALS;
float melting_point = 1600f;
BuildLocationRule build_location_rule = BuildLocationRule.Anywhere;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER6;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER0;
BuildingDef buildingDef = BuildingTemplates.CreateBuildingDef(ID, width, height, anim, hitpoints, construction_time, tIER, rAW_METALS, melting_point, build_location_rule, BUILDINGS.DECOR.PENALTY.TIER5, tIER6, 0.2f);
buildingDef.InputConduitType = _conduitType;
buildingDef.OutputConduitType = ConduitType.None;
Expand Down
12 changes: 6 additions & 6 deletions Source/FluidWarpMod/WarpRequestorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public override BuildingDef CreateBuildingDef()
string anim = "valveliquid_kanim";
int hitpoints = 30;
float construction_time = 5f;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER7;
string[] rAW_METALS = MATERIALS.REFINED_METALS;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER1;
string[] rAW_METALS = MATERIALS.ALL_METALS;
float melting_point = 1600f;
BuildLocationRule build_location_rule = BuildLocationRule.Anywhere;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER6;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER0;
BuildingDef buildingDef = BuildingTemplates.CreateBuildingDef(ID, width, height, anim, hitpoints, construction_time, tIER, rAW_METALS, melting_point, build_location_rule, BUILDINGS.DECOR.PENALTY.TIER5, tIER6, 0.2f);
buildingDef.InputConduitType = ConduitType.None;
buildingDef.OutputConduitType = _conduitType;
Expand Down Expand Up @@ -71,11 +71,11 @@ public override BuildingDef CreateBuildingDef()
string anim = "valvegas_kanim";
int hitpoints = 30;
float construction_time = 5f;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER7;
string[] rAW_METALS = MATERIALS.REFINED_METALS;
float[] tIER = BUILDINGS.CONSTRUCTION_MASS_KG.TIER1;
string[] rAW_METALS = MATERIALS.ALL_METALS;
float melting_point = 1600f;
BuildLocationRule build_location_rule = BuildLocationRule.Anywhere;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER6;
EffectorValues tIER6 = NOISE_POLLUTION.NOISY.TIER0;
BuildingDef buildingDef = BuildingTemplates.CreateBuildingDef(ID, width, height, anim, hitpoints, construction_time, tIER, rAW_METALS, melting_point, build_location_rule, BUILDINGS.DECOR.PENALTY.TIER5, tIER6, 0.2f);
buildingDef.InputConduitType = ConduitType.None;
buildingDef.OutputConduitType = _conduitType;
Expand Down
37 changes: 19 additions & 18 deletions Source/FluidWarpMod/WarpSpaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public ValveBaseExt(ValveBase vb)
public bool isValidRequestor()
{

Logger.Log(String.Format("WarpSpaceManager.RequestFluid2 Is valid requestor {0}", FlowManager.HasConduit(ValveBase.GetOutputCell())));
//Logger.Log(String.Format("WarpSpaceManager.RequestFluid2 Is valid requestor {0}", FlowManager.HasConduit(ValveBase.GetOutputCell())));
return ValveBase != null && FlowManager.HasConduit(ValveBase.GetOutputCell());
}

public bool isValidProvider()
{
Logger.Log(String.Format("WarpSpaceManager.RequestFluid2 Is valid provider {0}", FlowManager.HasConduit(ValveBase.GetInputCell())));
//Logger.Log(String.Format("WarpSpaceManager.RequestFluid2 Is valid provider {0}", FlowManager.HasConduit(ValveBase.GetInputCell())));
return ValveBase != null && FlowManager.HasConduit(ValveBase.GetInputCell());
}

Expand Down Expand Up @@ -65,23 +65,19 @@ public static void RegisterConduitUpdater()
{
if (!isUpdaterRegistered)
{
Logger.Log("WarpSpaceManager.RegisterConduitUpdater start");
Conduit.GetFlowManager(ConduitType.Gas).AddConduitUpdater(new Action<float>(WarpSpaceManager.GasConduitUpdate), ConduitFlowPriority.Default);
Conduit.GetFlowManager(ConduitType.Liquid).AddConduitUpdater(new Action<float>(WarpSpaceManager.LiquidConduitUpdate), ConduitFlowPriority.Default);
isUpdaterRegistered = true;
Logger.Log("WarpSpaceManager.RegisterConduitUpdater end");
}
}

public static void UnregisterConduitUpdate()
{
if (isUpdaterRegistered)
{
Logger.Log("WarpSpaceManager.UnregisterConduitUpdate start");
Conduit.GetFlowManager(ConduitType.Gas).RemoveConduitUpdater(new Action<float>(WarpSpaceManager.GasConduitUpdate));
Conduit.GetFlowManager(ConduitType.Liquid).RemoveConduitUpdater(new Action<float>(WarpSpaceManager.LiquidConduitUpdate));
isUpdaterRegistered = false;
Logger.Log("WarpSpaceManager.UnregisterConduitUpdate end");
}
}

Expand Down Expand Up @@ -144,21 +140,26 @@ private static void PushFluid(List<ValveBaseExt> requesters, List<ValveBaseExt>
{
if (!provider.isValidProvider())
continue;
Logger.LogFormat("-----WarpSpaceManager.RequestFluid start for channel: {0}", provider.Channel);
var flowManager = provider.FlowManager;
int fromCell = provider.ValveBase.GetInputCell();
ConduitFlow.Conduit providerConduit = flowManager.GetConduit(fromCell);
ConduitFlow.ConduitContents providerContents = providerConduit.GetContents(flowManager);
if (SimHashes.Vacuum.Equals(providerContents.element))
{
Logger.LogFormat("PushFluid: Vacuum found in Provider {0}, channel {1}", provider.ID, provider.Channel);
continue;
}

var matchedRequesters = requesters.Where(x => x.Channel == provider.Channel).ToList();
if (matchedRequesters.Count == 0)
{
Logger.LogFormat("PushFluid: No matched requestors for Provider {0}, channel {1}", provider.ID, provider.Channel);
continue;
}
var splitMass = providerContents.mass / matchedRequesters.Count();

Logger.Log(String.Format("WarpSpaceManager.RequestFluid splitMass: {0}", splitMass));
Logger.Log(String.Format("WarpSpaceManager.RequestFluid matchedRequesters: {0}", matchedRequesters.Count));
//Logger.Log(String.Format("WarpSpaceManager.RequestFluid splitMass: {0}", splitMass));
//Logger.Log(String.Format("WarpSpaceManager.RequestFluid matchedRequesters: {0}", matchedRequesters.Count));
foreach (var requester in matchedRequesters)
{
if (!requester.isValidRequestor())
Expand All @@ -169,39 +170,39 @@ private static void PushFluid(List<ValveBaseExt> requesters, List<ValveBaseExt>

if (requestorContents.mass < 1f && requestorContents.element != providerContents.element && requestorContents.element != SimHashes.Vacuum)
{
Logger.LogFormat("Removing contents is: {0} kg. of {1}", requestorContents.mass, requestorContents.element);
//Logger.LogFormat("Removing contents is: {0} kg. of {1}", requestorContents.mass, requestorContents.element);
flowManager.RemoveElement(requestorConduit, requestorContents.mass);
}

float addedMass = flowManager.AddElement(toCell, providerContents.element, splitMass, providerContents.temperature, providerContents.diseaseIdx, providerContents.diseaseCount);
Game.Instance.accumulators.Accumulate(provider.ValveBase.AccumulatorHandle, addedMass);
Logger.LogFormat($@"Requestor Info
requester mass: {requestorContents.mass} requester element: {requestorContents.element}
provider mass: {providerContents.mass} provider element: {providerContents.element}
provider split: {splitMass} added mass: {addedMass}
\r\n ");
// Logger.LogFormat($@"Requestor Info
//requester mass: {requestorContents.mass} requester element: {requestorContents.element}
//provider mass: {providerContents.mass} provider element: {providerContents.element}
//provider split: {splitMass} added mass: {addedMass}
//");
if (addedMass > 0f)
{
ConduitFlow.ConduitContents removed = flowManager.RemoveElement(providerConduit, addedMass);
Game.Instance.accumulators.Accumulate(requester.ValveBase.AccumulatorHandle, addedMass);
Logger.LogFormat("Moved {0} kg. from {1} to {2}. ", addedMass, fromCell, toCell);
// Logger.LogFormat("Moved {0} kg. from {1} to {2}. ", addedMass, fromCell, toCell);
}
else
{
Logger.Log(String.Format("WarpSpaceManager.RequestFluid No mass moved"));
}
}

Logger.LogFormat("-----WarpSpaceManager.RequestFluid end for channel: {0}", provider.Channel);
}

Logger.LogFormat("WarpSpaceManager.RequestFluid end");
}

private static void UpdateConduitsOfWarpGates(float dt, ConduitType warpGateType)
{
try
{
Logger.LogFormat("UpdateConduitsOfWarpGates: Liquid Providers: {0}, Gas Providers {1}", _liquidProviders.Count, _gasProviders.Count);
Logger.LogFormat("UpdateConduitsOfWarpGates: Liquid Requestors: {0}, Gas Requestors {1}", _liquidRequesters.Count, _gasRequesters.Count);
if (warpGateType == ConduitType.Liquid)
{
var requesters = _liquidRequesters.Values.Where(x => x.Channel != 10000).ToList();
Expand Down
21 changes: 0 additions & 21 deletions Source/ZeroPointModule/ZeroPointModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,7 @@ private static void Prefix()

ModUtil.AddBuildingToPlanScreen("Power", ZeroPointModuleConfig.ID);

/*
List<string> ls = new List<string>((string[])TUNING.BUILDINGS.PLANORDER[2].data);
ls.Add(ZeroPointModuleConfig.ID);
TUNING.BUILDINGS.PLANORDER[2].data = (string[])ls.ToArray();

TUNING.BUILDINGS.COMPONENT_DESCRIPTION_ORDER.Add(ZeroPointModuleConfig.ID);
*/
/*
List<string> category = (List<string>)TUNING.BUILDINGS.PLANORDER.First(po => ((HashedString) "Power").Equals(po.category)).data;
category.Add(ZeroPointModuleConfig.ID);
*/

}
/*
private static void Postfix()
{

Debug.Log(" === ZeroPointModuleMod_GeneratedBuildings_LoadGeneratedBuildings Postfix === ");
object obj = Activator.CreateInstance(typeof(ZeroPointModuleConfig));
BuildingConfigManager.Instance.RegisterBuilding(obj as IBuildingConfig);
}
*/
}

[HarmonyPatch(typeof(Db), "Initialize")]
Expand Down
3 changes: 2 additions & 1 deletion Source/ZeroPointModule/ZeroPointModule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ZeroPointModule</RootNamespace>
<AssemblyName>ZeroPointModule</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
19 changes: 3 additions & 16 deletions Source/ZeroPointModule/ZeroPointModuleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ class ZeroPointModuleConfig : BaseBatteryConfig
{
public const string ID = "ZeroPointModule";

private static readonly LogicPorts.Port[] OUTPUT_PORTS = LogicOperationalController.INPUT_PORTS_0_0;

public override BuildingDef CreateBuildingDef()
{
//string id = "ZeroPointModule";
int width = 2;
int height = 2;
int hitpoints = 60;
string anim = "smartbattery_kanim";
float construction_time = 120f;
float construction_time = 20f;
float[] tIER = TUNING.BUILDINGS.CONSTRUCTION_MASS_KG.TIER7;
string[] aLL_METALS = TUNING.MATERIALS.REFINED_METALS;
string[] aLL_METALS = TUNING.MATERIALS.ALL_METALS;
float melting_point = 800f;
float exhaust_temperature_active = 0f;
float self_heat_kilowatts_active = 100f;
float self_heat_kilowatts_active = 0f;

BuildingDef result = base.CreateBuildingDef(ID, width, height, hitpoints, anim, construction_time, tIER, aLL_METALS, melting_point, exhaust_temperature_active, self_heat_kilowatts_active, TUNING.BUILDINGS.DECOR.PENALTY.TIER5, TUNING.NOISE_POLLUTION.NOISY.TIER6);
//result.EnergyConsumptionWhenActive = 120f;
Expand All @@ -31,23 +29,12 @@ public override BuildingDef CreateBuildingDef()
return result;
}

public override void DoPostConfigurePreview(BuildingDef def, GameObject go)
{
GeneratedBuildings.RegisterLogicPorts(go, null, OUTPUT_PORTS);
}

public override void DoPostConfigureUnderConstruction(GameObject go)
{
GeneratedBuildings.RegisterLogicPorts(go, null, OUTPUT_PORTS);
}

public override void DoPostConfigureComplete(GameObject go)
{
Battery battery = go.AddOrGet<Battery>();
battery.capacity = 40000f;
battery.joulesLostPerSecond = battery.capacity * 0.05f / 600f;

GeneratedBuildings.RegisterLogicPorts(go, null, OUTPUT_PORTS);
base.DoPostConfigureComplete(go);
}
}
Expand Down