Skip to content

Commit

Permalink
alpha .01
Browse files Browse the repository at this point in the history
  • Loading branch information
tgruetzm committed Aug 15, 2014
1 parent 0221771 commit 85047b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
21 changes: 13 additions & 8 deletions Snacks/Snacks/SnackController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void Awake()
dayStartTime = Planetarium.GetUniversalTime();
System.Random r = new System.Random();
snackTime = r.NextDouble() * secondsInDay + dayStartTime;

Debug.Log("Snacks Awake:" + dayStartTime);
}

Expand All @@ -43,7 +44,7 @@ private void OnCrewBoardVessel(GameEvents.FromToAction<Part, Part> data)
double got = GetSnackResource(data.from, 1.0);
Debug.Log("EVA Got:" + got);
List<PartResource> resources = new List<PartResource>();
data.to.GetConnectedResources(snacksResource.id, resources);
data.to.GetConnectedResources(snacksResource.id,ResourceFlowMode.ALL_VESSEL, resources);
resources.First().amount += got;
}

Expand All @@ -59,7 +60,7 @@ private void OnCrewOnEva(GameEvents.FromToAction<Part, Part> data)
data.to.Resources.Add(node);
}
List<PartResource> resources = new List<PartResource>();
data.to.GetConnectedResources(snacksResource.id, resources);
data.to.GetConnectedResources(snacksResource.id,ResourceFlowMode.ALL_VESSEL, resources);
resources.First().amount = got;
resources.First().maxAmount = 1;

Expand Down Expand Up @@ -112,8 +113,8 @@ private bool GetRandomChance(int prob)
private double GetSnackResource(Part p, double demand)
{
List<PartResource> resources = new List<PartResource>();
p.GetConnectedResources(snacksResource.id, resources);

p.GetConnectedResources(snacksResource.id, ResourceFlowMode.ALL_VESSEL, resources);
double supplied = 0;
foreach (PartResource res in resources)
{
Expand Down Expand Up @@ -209,17 +210,21 @@ void EatSnacks()
{
if (!pv.vesselRef.loaded)
{
snacksMissed += RemoveSnacks(pv);
// Debug.Log("Ate snacks for: " + pv.vesselName);
double snacks = RemoveSnacks(pv);
snacksMissed += snacks;
if (snacks > 0)
Debug.Log("No snacks for: " + pv.vesselName);
}
}
}
foreach (Vessel v in FlightGlobals.Vessels)
{
if(v.GetCrewCount()> 0)
{
snacksMissed += RemoveSnacks(v);
//Debug.Log("Ate snacks for: " + v.vesselName);
double snacks = RemoveSnacks(v);
snacksMissed += snacks;
if(snacks > 0)
Debug.Log("No snacks for: " + v.vesselName);
}

}
Expand Down
7 changes: 4 additions & 3 deletions Snacks/Snacks/Snacks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\KSP\KSP_dev\KSP_win\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\KSP\KSP_dev\KSP_win\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
Expand Down

0 comments on commit 85047b0

Please sign in to comment.