Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehni authored Aug 18, 2017
1 parent 20364f3 commit 8868593
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 0 deletions.
8 changes: 8 additions & 0 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>Food Alert</name>
<author>Mehni</author>
<targetVersion>0.17.0</targetVersion>
<url>https://github.com/Mehni/FoodAlert/releases/latest</url>
<description>v0.17.0.1 Initial release.\n\n Shows a persistent alert with the amount of food you currently have in storage, and an estimate of how long stocks will last.</description>
</ModMetaData>
Binary file added About/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assemblies/FoodAlert.dll
Binary file not shown.
22 changes: 22 additions & 0 deletions FoodAlert/FoodAlert.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodAlert", "FoodAlert\FoodAlert.csproj", "{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
63 changes: 63 additions & 0 deletions FoodAlert/FoodAlert/FoodAlert.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3F0E51D5-7F89-48FF-80E7-26F0D33C3B64}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FoodAlert</RootNamespace>
<AssemblyName>FoodAlert</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</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.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="SomeFoodAlert.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
36 changes: 36 additions & 0 deletions FoodAlert/FoodAlert/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FoodAlert")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FoodAlert")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3f0e51d5-7f89-48ff-80e7-26f0d33c3b64")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
62 changes: 62 additions & 0 deletions FoodAlert/FoodAlert/SomeFoodAlert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Linq;
using System.Collections.Generic;
using RimWorld;
using Verse;
using UnityEngine;

namespace FoodAlert
{
public class Alert_SomeFood : Alert
{
private const float NutritionThresholdPerColonist = 4f;

public Alert_SomeFood()
{
this.defaultLabel = "SomeFood".Translate();
this.defaultPriority = AlertPriority.Medium;
}

public override string GetExplanation()
{
Map map = this.MapWithSomeFood();
if (map == null)
{
return string.Empty;
}
float totalHumanEdibleNutrition = map.resourceCounter.TotalHumanEdibleNutrition;
int num = map.mapPawns.FreeColonistsSpawnedCount + (from pr in map.mapPawns.PrisonersOfColony
where pr.guest.GetsFood
select pr).Count<Pawn>();
int num2 = Mathf.FloorToInt(totalHumanEdibleNutrition / (float)num);
return string.Format("SomeFoodDesc".Translate(), totalHumanEdibleNutrition.ToString("F0"), num.ToStringCached(), num2.ToStringCached());
}

public override AlertReport GetReport()
{
if (Find.TickManager.TicksGame < 150000)
{
return false;
}
return this.MapWithSomeFood() != null;
}

private Map MapWithSomeFood()
{
List<Map> maps = Find.Maps;
for (int i = 0; i < maps.Count; i++)
{
Map map = maps[i];
if (map.IsPlayerHome)
{
int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;
if (map.resourceCounter.TotalHumanEdibleNutrition > 4f * (float)freeColonistsSpawnedCount)
{
return map;
}
}
}
return null;
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C:\Users\Maniak\Documents\RimWorld Mods\Assemblies\FoodAlert.dll
C:\Users\Maniak\Documents\RimWorld Mods\FoodAlert\FoodAlert\FoodAlert\obj\Debug\FoodAlert.csprojResolveAssemblyReference.cache
C:\Users\Maniak\Documents\RimWorld Mods\FoodAlert\FoodAlert\FoodAlert\obj\Debug\FoodAlert.dll
Binary file not shown.
Binary file added FoodAlert/FoodAlert/obj/Debug/FoodAlert.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions Languages/English/Keyed/SomeFood.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>

<SomeFood>Food reserves</SomeFood>
<SomeFoodDesc>Food is not of an immediate concern.\n\n Full bars worth of food in storage: {0}\n Colonists and prisoners getting food: {1}\n Days worth of food in storage: {2}\n\nThat is a decent amount of food.</SomeFoodDesc>

</LanguageData>

0 comments on commit 8868593

Please sign in to comment.