Synapse914Processors

How to change the behavior of SCP-914

Synapse overrides the behavior of SCP-914: Every SynapseItem is assigned a ISynapse914Processor that is by default just a Wrapper around the default Processor, so that by default all items will be updated like they do in vanilla.

The 914Processor is responsible for upgrading the item and can be used like this to upgrade Items (SCP-914 also just calls this method now)

SynapseItem item;
item.UpgradeProcessor.CreateUpgradedItem(item, Scp914KnobSetting.Fine, Vector3.zero);

This method as you can see needs the item, the setting it is upgraded on and the position where the item should spawn when it is not inside a Player Inventory right now.

You can create an own 914 Processor by creating a new Type that inherits from ISynapse914Processor add the Attribute Automatic and Scp914Processor to it

using Neuron.Core.Meta;
using Scp914;
using Synapse3.SynapseModule.Item;
using Synapse3.SynapseModule.Map.Scp914;
using UnityEngine;

namespace DocsExample;

[Automatic]
[Scp914Processor(
    ReplaceHandlers = new uint[] { 35 } //35 is the Coin so this will only affect Coins
    )]
public class My914Processor : ISynapse914Processor
{
    public void CreateUpgradedItem(SynapseItem item, Scp914KnobSetting setting, Vector3 position = new Vector3())
    {
        
    }
}

Now let us add some upgrade logic to it but keep in mind that a SynapseItem can be in different states of existence

using Neuron.Core.Meta;
using Scp914;
using Synapse3.SynapseModule.Item;
using Synapse3.SynapseModule.Map.Scp914;
using UnityEngine;

namespace DocsExample;

[Automatic]
[Scp914Processor(
    ReplaceHandlers = new uint[] { 35 } //35 is the Coin so this will only affect Coins
    )]
public class My914Processor : ISynapse914Processor
{
    public void CreateUpgradedItem(SynapseItem item, Scp914KnobSetting setting, Vector3 position = new Vector3())
    {
        //Dependent on which setting is used get another Item that it should become
        //The logic for this can be of course more advanced with chances but we keep it simple here
        var type = setting switch
        {
            Scp914KnobSetting.Coarse => ItemType.KeycardJanitor,
            Scp914KnobSetting.Rough => ItemType.KeycardScientist,
            Scp914KnobSetting.OneToOne => ItemType.KeycardResearchCoordinator,
            Scp914KnobSetting.Fine => ItemType.KeycardNTFCommander,
            Scp914KnobSetting.VeryFine => ItemType.KeycardO5,
            _ => ItemType.None
        };

        var state = item.State;
        var owner = item.ItemOwner;
        
        //The Item is not automatically destroyed you have to do it yourself
        item.Destroy();
        
        if (type == ItemType.None) return;

        //Dependent on which state the Item was it will now be dropped or given in the inventory
        //You can of course also always drop it on the Map or always give it to a player
        switch (state)
        {
            case ItemState.Map:
                _ = new SynapseItem(type, position);
                break;
            
            case ItemState.Inventory:
                _ = new SynapseItem(type, owner);
                break;
        }
    }
}

Add a 914Processor manually

You can of course also add a 914Processor manually.

Synapse stores them all in a dictionary that decide which Item ID will become which Processor that you can easily change.

In this Example, your code would look like this if you don't use the Automatic and Scp914Processor Attribute

Synapse.Get<Scp914Service>().Synapse914Processors[35] = new My914Processor();

All Coins that will now be created after this code executed will now use your Processor instead of the default one

Last updated