Skip to content
This repository has been archived by the owner on Nov 25, 2018. It is now read-only.

Commit

Permalink
A16 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
notfood committed Dec 13, 2016
1 parent e019d3e commit 4b12cc6
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 60 deletions.
4 changes: 2 additions & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>Infused (local)</name>
<name>Infused</name>
<author>Latta &amp; NotFood</author>
<url>https://ludeon.com/forums/index.php?topic=21884.0</url>
<targetVersion>0.15.0</targetVersion>
<targetVersion>0.16.0</targetVersion>
<description>Equipment enchantment

Requires Community Core Library.
Expand Down
4 changes: 2 additions & 2 deletions Defs/InfusionDefs/Prefixes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@
</value>
</li>
<li>
<key>BaseHealingQuality</key>
<key>HealingQuality</key>
<value>
<multiplier>1.03</multiplier>
</value>
Expand Down Expand Up @@ -733,7 +733,7 @@
</value>
</li>
<li>
<key>BaseHealingQuality</key>
<key>HealingQuality</key>
<value>
<multiplier>1.07</multiplier>
</value>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RimWorld-Infused

[![Version](https://img.shields.io/badge/Rimworld-A15-green.svg)]
[![Version](https://img.shields.io/badge/Rimworld-A16-green.svg)]
(http://rimworldgame.com/)
[![License](https://img.shields.io/badge/license-Custom-blue.svg)]
(https://ludeon.com/forums/index.php?topic=11171.msg111243#msg111243)
Expand Down
44 changes: 41 additions & 3 deletions Source/Comp/CompInfusion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Text;

using UnityEngine;
using RimWorld;
using Verse;
using Verse.Sound;
Expand All @@ -18,6 +19,9 @@ public class CompInfusion : ThingComp
private string prefixDefName, suffixDefName;
private Def prefix, suffix;

private string infusedLabel;
private Color infusedLabelColor;

public InfusionSet Infusions {
get { return new InfusionSet (prefix, suffix); }
}
Expand All @@ -26,6 +30,14 @@ public bool Infused {
get { return prefix != null || suffix != null; }
}

public string InfusedLabel {
get { return infusedLabel; }
}

public Color InfusedLabelColor {
get { return infusedLabelColor; }
}

public void InitializeInfusionPrefix(InfusionTier tier)
{
InitializeInfusion (InfusionType.Prefix, tier, out prefix);
Expand Down Expand Up @@ -70,7 +82,7 @@ private void throwMote()
Messages.Message( ResourceBank.StringInfusionMessage.Translate( msg ), MessageSound.Silent );
InfusionSound.PlayOneShotOnCamera();

MoteMaker.ThrowText( parent.Position.ToVector3Shifted(), ResourceBank.StringInfused,
MoteMaker.ThrowText( parent.Position.ToVector3Shifted(), this.parent.Map, ResourceBank.StringInfused,
GenInfusionColor.Legendary );

isNew = false;
Expand All @@ -81,6 +93,32 @@ public override void PostSpawnSetup()
base.PostSpawnSetup();

if (Infused) {
//When there is only suffix
if (suffix != null)
{
infusedLabelColor = suffix.tier.InfusionColor();
}
//When there is only prefix
else if (prefix != null)
{
infusedLabelColor = prefix.tier.InfusionColor();
}
//When there are both prefix and suffix
else
{
infusedLabelColor = MathUtility.Max(prefix.tier, suffix.tier).InfusionColor();
}

infusedLabel = "";
if (prefix != null)
{
infusedLabel += prefix.labelShort;
if (suffix != null)
infusedLabel += " ";
}
if (suffix != null)
infusedLabel += suffix.labelShort;

InfusionLabelManager.Register (this);

// We only throw notifications for newly spawned items.
Expand Down Expand Up @@ -116,9 +154,9 @@ public override void PostExposeData()
#endif
}

public override void PostDeSpawn()
public override void PostDeSpawn (Map map)
{
base.PostDeSpawn();
base.PostDeSpawn (map);

if ( Infused )
{
Expand Down
8 changes: 4 additions & 4 deletions Source/Infused.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\Steam\steamapps\common\RimWorld\RimWorldLinux_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\RimWorldLinux_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\Steam\steamapps\common\RimWorld\RimWorldLinux_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>..\..\..\RimWorldLinux_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
37 changes: 3 additions & 34 deletions Source/MapComponent/MapComponent_InfusionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Infused
{
public class MapComponent_InfusionManager : MapComponent
{
public MapComponent_InfusionManager ()
public MapComponent_InfusionManager (Map map) : base(map)
{
// Clear old labels
InfusionLabelManager.ReInit();
Expand All @@ -32,42 +32,11 @@ private static void Draw()
foreach (var current in InfusionLabelManager.Drawee)
{
// skip fogged
if (Find.FogGrid.IsFogged (current.parent.Position)) {
if (Find.VisibleMap.fogGrid.IsFogged (current.parent.Position)) {
continue;
}

var inf = current.Infusions;
var prefix = inf.prefix;
var suffix = inf.suffix;

Color color;
//When there is only suffix
if (suffix != null)
{
color = suffix.tier.InfusionColor();
}
//When there is only prefix
else if (prefix != null)
{
color = prefix.tier.InfusionColor();
}
//When there are both prefix and suffix
else
{
color = MathUtility.Max(prefix.tier, suffix.tier).InfusionColor();
}
var result = new StringBuilder();
if (prefix != null)
{
result.Append(prefix.labelShort);
if (suffix != null)
result.Append(" ");
}
if (suffix != null)
result.Append(suffix.labelShort);

GenWorldUI.DrawThingLabel(
GenWorldUI.LabelDrawPosFor(current.parent, -0.66f), result.ToString(), color);
GenMapUI.DrawThingLabel( GenMapUI.LabelDrawPosFor(current.parent, -0.66f), current.InfusedLabel, current.InfusedLabelColor );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/ModInitializers/MapComponentInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class MapComponentInjector : MonoBehaviour

public void FixedUpdate()
{
if (Current.ProgramState != ProgramState.MapPlaying)
if (Current.ProgramState != ProgramState.Playing)
{
return;
}

if (Find.Map.components.FindAll(c => c.GetType() == infusionManager).Count == 0)
if (Find.VisibleMap.components.FindAll(c => c.GetType() == infusionManager).Count == 0)
{
Find.Map.components.Add((MapComponent) Activator.CreateInstance (infusionManager));
Find.VisibleMap.components.Add((MapComponent) Activator.CreateInstance (infusionManager, Find.VisibleMap));

Log.Message("Infused :: Added an infusion manager to the map.");
}
Expand Down
20 changes: 9 additions & 11 deletions Source/ModInitializers/ModInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Infused
{
[StaticConstructorOnStartup]
public class ModInjector
{
public static bool hasRun;
Expand All @@ -20,20 +19,21 @@ public static void Inject()
return;
}

hasRun = true;

MethodInfo Rimworld_CompQuality_SetQuality = typeof(CompQuality).GetMethod ("SetQuality", BindingFlags.Instance | BindingFlags.Public);
MethodInfo Infused_CompQuality_SetQuality = typeof(ModDetour).GetMethod ("_SetQuality", BindingFlags.Static | BindingFlags.NonPublic);
if (!Detours.TryDetourFromTo (Rimworld_CompQuality_SetQuality, Infused_CompQuality_SetQuality)) {
Log.Error ("Infused :: Failed to Detour");

hasRun = true;

return;
}

// until CCL for A15 appears...
GameObject initializer = new GameObject("InfusionMapComponentInjector");
initializer.AddComponent<MapComponentInjector>();
UnityEngine.Object.DontDestroyOnLoad(initializer);
LongEventHandler.ExecuteWhenFinished (delegate {
GameObject initializer = new GameObject("InfusionMapComponentInjector");
UnityEngine.Object.DontDestroyOnLoad(initializer);
initializer.AddComponent<MapComponentInjector>();
});

var defs = (
from def in DefDatabase< ThingDef >.AllDefs
Expand All @@ -43,7 +43,7 @@ select def
);

var tabType = typeof(ITab_Infusion);
var tab = ITabManager.GetSharedInstance ( tabType );
var tab = InspectTabManager.GetSharedInstance ( tabType );
var compProperties = new CompProperties { compClass = typeof (CompInfusion) };

foreach(var def in defs) {
Expand All @@ -55,7 +55,7 @@ select def
if ( def.inspectorTabs == null || def.inspectorTabs.Count == 0 )
{
def.inspectorTabs = new List< Type >();
def.inspectorTabsResolved = new List< ITab >();
def.inspectorTabsResolved = new List< InspectTabBase >();
}

def.inspectorTabs.Add (tabType);
Expand All @@ -64,8 +64,6 @@ select def
#if DEBUG
Log.Message ("Infused :: Injected");
#endif

hasRun = true;
}

}
Expand Down

0 comments on commit 4b12cc6

Please sign in to comment.