Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
- Updated PluginAPI to 13.1.1
  • Loading branch information
MrAfitol committed Sep 2, 2023
1 parent e123114 commit 253680b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
31 changes: 16 additions & 15 deletions SCP1162/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ namespace SCP1162
using CustomPlayerEffects;
using PluginAPI.Core.Items;
using InventorySystem.Items.Usables.Scp330;
using PluginAPI.Events;

public class EventHandlers
{
private Vector3 SCP1162Position;

[PluginEvent(ServerEventType.MapGenerated)]
public void OnGenerationMap()
[PluginEvent]
public void OnGenerationMap(MapGeneratedEvent ev)
{
var Room = LightZone.Rooms.FirstOrDefault(x => x.GameObject.name == "LCZ_173");
var scp1162 = new SimplifiedToy(PrimitiveType.Cylinder, new Vector3(17f, 13f, 3.59f), new Vector3(90f, 0f, 0f),
Expand All @@ -26,43 +27,43 @@ public void OnGenerationMap()
SCP1162Position = scp1162.transform.position;
}

[PluginEvent(ServerEventType.PlayerDropItem)]
public bool OnPlayerDroppedItem(Player player, ItemBase item) { return OnUseSCP1162(player, item, player.CurrentItem == item); }
[PluginEvent]
public bool OnPlayerDroppedItem(PlayerDropItemEvent ev) { return OnUseSCP1162(ev.Player, ev.Item, ev.Player.CurrentItem == ev.Item); }

private bool OnUseSCP1162(Player player, ItemBase item, bool isThrow)
{
if (!Round.IsRoundStarted) return true;
if (Vector3.Distance(SCP1162Position, player.Position) > Plugin.Instance.Config.SCP1162Distance) return true;
if (Vector3.Distance(SCP1162Position, player.Position) > Plugin.Config.SCP1162Distance) return true;
if (item is Scp330Bag) return true;

if (isThrow ? !Plugin.Instance.Config.IgnoreThrow && Plugin.Instance.Config.CuttingChance > 0 : Plugin.Instance.Config.CuttingChance > 0)
if (isThrow ? !Plugin.Config.IgnoreThrow && Plugin.Config.CuttingChance > 0 : Plugin.Config.CuttingChance > 0)
{

if (Plugin.Instance.Config.CuttingChance >= Random.Range(0, 101))
if (Plugin.Config.CuttingChance >= Random.Range(0, 101))
{
player.EffectsManager.EnableEffect<SeveredHands>(1000);
return true;
}
}

if (Plugin.Instance.Config.DeleteChance > 0)
if (Plugin.Config.DeleteChance > 0)
{
if (Plugin.Instance.Config.DeleteChance >= Random.Range(0, 101))
if (Plugin.Config.DeleteChance >= Random.Range(0, 101))
{
player.RemoveItem(new Item(item));
player.ReceiveHint(Plugin.Instance.Config.ItemDeleteMessage.Message
player.ReceiveHint(Plugin.Config.ItemDeleteMessage.Message
.Replace("{dropitem}", GetItemName(item.ItemTypeId))
.Replace("{dropstatus}", isThrow ? Plugin.Instance.Config.ItemDeleteMessage.ThrowText : Plugin.Instance.Config.ItemDeleteMessage.DropText), 2f);
.Replace("{dropstatus}", isThrow ? Plugin.Config.ItemDeleteMessage.ThrowText : Plugin.Config.ItemDeleteMessage.DropText), 2f);
return true;
}
}

var newItemType = Plugin.Instance.Config.DroppingItems.RandomItem();
var newItemType = Plugin.Config.DroppingItems.RandomItem();

player.ReceiveHint(Plugin.Instance.Config.ItemDropMessage.Message
player.ReceiveHint(Plugin.Config.ItemDropMessage.Message
.Replace("{dropitem}", GetItemName(item.ItemTypeId))
.Replace("{giveitem}", GetItemName(newItemType))
.Replace("{dropstatus}", isThrow ? Plugin.Instance.Config.ItemDropMessage.ThrowText : Plugin.Instance.Config.ItemDropMessage.DropText), 2f);
.Replace("{dropstatus}", isThrow ? Plugin.Config.ItemDropMessage.ThrowText : Plugin.Config.ItemDropMessage.DropText), 2f);
player.RemoveItem(new Item(item));
player.AddItem(newItemType);

Expand All @@ -71,7 +72,7 @@ private bool OnUseSCP1162(Player player, ItemBase item, bool isThrow)

public string GetItemName(ItemType itemType)
{
if (Plugin.Instance.Config.ItemsName.TryGetValue(itemType, out string itemName)) return itemName;
if (Plugin.Config.ItemsName.TryGetValue(itemType, out string itemName)) return itemName;
return itemType.ToString();
}
}
Expand Down
8 changes: 2 additions & 6 deletions SCP1162/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace SCP1162
{
using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
Expand All @@ -10,17 +9,14 @@ public class Plugin
public static Plugin Instance { get; private set; }

[PluginConfig("configs/scp_1162.yml")]
public Config Config;
public static Config Config;

[PluginPriority(LoadPriority.Highest)]
[PluginEntryPoint("SCP-1162", "1.0.9", "A plugin that adds SCP-1162.", "MrAfitol")]
[PluginEntryPoint("SCP-1162", "1.1.0", "A plugin that adds SCP-1162.", "MrAfitol")]
void LoadPlugin()
{
Instance = this;
EventManager.RegisterEvents<EventHandlers>(this);

var handler = PluginHandler.Get(this);
handler.SaveConfig(this, nameof(Config));
}
}
}
4 changes: 2 additions & 2 deletions SCP1162/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 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.9.0")]
[assembly: AssemblyFileVersion("1.0.9.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
16 changes: 8 additions & 8 deletions SCP1162/SCP1162.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,34 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>$(SL_REFERENCES)\Assembly-CSharp.dll</HintPath>
<HintPath>$(SL_Dependencies)\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SL_REFERENCES)\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>$(SL_Dependencies)\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SL_REFERENCES)\Mirror.dll</HintPath>
<HintPath>$(SL_Dependencies)\Mirror.dll</HintPath>
</Reference>
<Reference Include="PluginAPI, Version=12.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Northwood.PluginAPI.12.0.0\lib\net48\PluginAPI.dll</HintPath>
<Reference Include="PluginAPI, Version=13.1.1.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Northwood.PluginAPI.13.1.1\lib\net48\PluginAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SL_REFERENCES)\UnityEngine.dll</HintPath>
<HintPath>$(SL_Dependencies)\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SL_REFERENCES)\UnityEngine.CoreModule.dll</HintPath>
<HintPath>$(SL_Dependencies)\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SL_REFERENCES)\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>$(SL_Dependencies)\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion SCP1162/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Northwood.PluginAPI" version="12.0.0" targetFramework="net48" />
<package id="Northwood.PluginAPI" version="13.1.1" targetFramework="net48" />
<package id="YamlDotNet" version="11.0.1" targetFramework="net48" />
</packages>

0 comments on commit 253680b

Please sign in to comment.