Skip to content

Commit

Permalink
Renamed Interaction methods to reduce confusion. (#680)
Browse files Browse the repository at this point in the history
- CreateInteractions renamed to GenerateInteractionsFromSource
- GenerateInteractions renamed to GenerateInteractionsFromTarget

Co-authored-by: CosmicCoincidence <[email protected]>
  • Loading branch information
Ryan089 and cosmiccoincidence authored Jun 2, 2021
1 parent 03631e8 commit 82db883
Show file tree
Hide file tree
Showing 40 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Assets/Content/Furniture/Generic/WaterCooler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WaterCooler : InteractionTargetBehaviour, IExaminable
// how many we have now
public int NumberOfCups;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Start()
//canisterUI.label.text = transform.name;
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
// TODO: Update the interaction names and remove the increase/decrease pressure
// Create a custom interaction for opening the menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void DisposeContents()
}
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> interactions = new List<IInteraction>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void Start()
light.enabled = false;
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[] {new SimpleInteraction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SubstanceDispenser : InteractionTargetBehaviour
/// How much should be dispensed
/// </summary>
public float Moles;
public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
var registry = FindObjectOfType<SubstanceRegistry>();
Substance substance = registry.FromId(Substance);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Content/Furniture/Machines/Vendors/Vendor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Start()
audioSource = GetComponent<AudioSource>();
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
var interaction = new SimpleInteraction
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Content/Furniture/NetworkedOpenable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class NetworkedOpenable : InteractionTargetNetworkBehaviour

[SerializeField] private Sprite OpenIcon;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
OpenInteraction openInteraction = new OpenInteraction();
openInteraction.icon = OpenIcon;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Content/Furniture/Openable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Openable : InteractionTargetBehaviour
// This defines the icon that will be shown in the interaction menu
[SerializeField] private Sprite openInteractionIcon;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
// Here we generate the interactions when we are not holding the item
OpenInteraction openInteraction = new OpenInteraction();
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Furniture/Storage/StorageContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class StorageContainer : NetworkedOpenable

[SerializeField] private Sprite viewContainerIcon;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
// The "open" state is changed via the object interaction
// so we don't need to worry about that here, unless we can store stuff without needing it to open

List<IInteraction> interactions = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> interactions = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
StoreInteraction storeInteraction = new StoreInteraction();
ViewContainerInteraction view = new ViewContainerInteraction {MaxDistance = MaxDistance, icon = viewContainerIcon};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ private void ConsumeUpdate()
RpcUpdateMesh();
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> interactions = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> interactions = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
interactions.Add(new IgniteInteraction() { extinguishIcon = extinguishIcon, igniteIcon = igniteIcon });
return interactions.ToArray();
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Consumables/Food/Consumable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ void RpcPlayEatingSound(float pitch, int audioClip)
}


public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = new List<IInteraction>();
list.Add(new ConsumeInteraction {icon = item.sprite, Verb = consumeVerb, LoadingBarPrefab = LoadingBarPrefab});

return list.ToArray();
}

public void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
interactions.Add(new InteractionEntry(targets[0], new ConsumeInteraction {icon = item.sprite, Verb = consumeVerb, LoadingBarPrefab = LoadingBarPrefab }));
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Cosmetic/Bikehorn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ private void RpcPlayHonk()
audioSource.PlayOneShot(honkSound);
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> list = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
list.Add(new HonkInteraction{ icon = useIcon });
return list.ToArray();
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Cosmetic/ServiceBell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ private void RpcPlayBell()
audioSource.PlayOneShot(bellSound);
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> interactions = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> interactions = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
interactions.Insert(0, new BellInteraction());
return interactions.ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ private void RpcSpray()
justSprayed = true;
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> list = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
list.Add(new SprayInteraction { icon = useIcon });
return list.ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Content/Items/Functional/Generic/Boombox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public bool GetState()
return radioOn;
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> interactions = new List<IInteraction>(2)
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Functional/Tools/Generic/Crowbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class Crowbar : Item

public Sprite constructIcon;

public override void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public override void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
base.CreateInteractions(targets, interactions);
base.GenerateInteractionsFromSource(targets, interactions);
var wallConstructionInteraction = new WallConstructionInteraction
{
WallToConstruct = WallToConstruct,
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Functional/Tools/Generic/Flashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class Flashlight : Item
public new Light light = null;
public Sprite turnOnIcon;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> list = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
list.Add(new FlashlightInteraction{ icon = turnOnIcon });
return list.ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void Toggle()
RpcTurnOn(!hotFlame.isEmitting);
}

public override void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public override void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
base.CreateInteractions(targets, interactions);
base.GenerateInteractionsFromSource(targets, interactions);
interactions.Insert(0, new InteractionEntry(targets[0], new WelderConstructionInteraction
{
TurfReinforceList = reinforceDict,
Expand All @@ -106,9 +106,9 @@ public override void CreateInteractions(IInteractionTarget[] targets, List<Inter
}));
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> list = base.GenerateInteractionsFromTarget(interactionEvent).ToList();

ToggleInteraction toggleInteraction = new ToggleInteraction
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/Content/Items/Functional/Tools/Generic/Wrench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class Wrench : Item

public Sprite constructIcon;

public override void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public override void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
base.CreateInteractions(targets, interactions);
base.GenerateInteractionsFromSource(targets, interactions);
interactions.Insert(0, new InteractionEntry(targets[0], new TableConstructionInteraction
{ TableToConstruct = TableToConstruct,
Delay = Delay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void Toggle()
RpcSetBlade(on);
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
List<IInteraction> list = base.GenerateInteractions(interactionEvent).ToList();
List<IInteraction> list = base.GenerateInteractionsFromTarget(interactionEvent).ToList();
list.Add(new ToggleInteraction
{
OnName = "Turn off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Start()
}


public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
var interaction = new SimpleInteraction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void Start()
lights = GetComponentsInChildren<Light>();
}

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
var interaction = new SimpleInteraction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void Start()
item = GetComponent<Item>();
}

public void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
interactions.Add(new InteractionEntry(targets.First(), new SimpleInteraction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SimpleCraftingTarget : InteractionTargetBehaviour
/// </summary>
public SimpleCraftingInteraction.CraftingResult[] ResultingObjects;

public override IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[] { new SimpleCraftingInteraction
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/FilterObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void Step()



public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/MixerObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void Step()
}
}

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/PumpObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void Initialize()
SetAtmosNeighbours();
}

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/ScrubberObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void SetAtmosNeighbours()
}
}

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/ValveObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Start()
SetValve(false);
}

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Atmospherics/Machinery/VentObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void SetAtmosNeighbours()
return;
}

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[]
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Interactions/IInteractionSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IInteractionSource
/// </summary>
/// <param name="targets">The interaction targets of this interaction</param>
/// <param name="interactions">The already present interactions</param>
void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions);
void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions);
/// <summary>
/// Checks if this source can interact with a certain target
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Interactions/IInteractionSourceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public interface IInteractionSourceExtension
/// </summary>
/// <param name="targets">The interaction targets of this interaction</param>
/// <param name="interactions">The already present interactions</param>
void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions);
void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions);
}
}
2 changes: 1 addition & 1 deletion Assets/Engine/Interactions/IInteractionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public interface IInteractionTarget
/// </summary>
/// <param name="interactionEvent">The interaction event</param>
/// <returns>All possible interactions</returns>
IInteraction[] GenerateInteractions(InteractionEvent interactionEvent);
IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent);
}
}
4 changes: 2 additions & 2 deletions Assets/Engine/Interactions/InteractionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ private List<InteractionEntry> GetInteractionsFromTargets(IInteractionSource sou
{
// Generate interactions on targets
List<InteractionEntry> interactions = targets.SelectMany(t =>
t.GenerateInteractions(new InteractionEvent(source, t, @event.Point))
t.GenerateInteractionsFromTarget(new InteractionEvent(source, t, @event.Point))
.Select(i => new InteractionEntry(t, i))
).ToList();

// Allow the source to add its own interactions
source.CreateInteractions(targets.ToArray(), interactions);
source.GenerateInteractionsFromSource(targets.ToArray(), interactions);

// Filter interactions to possible ones
return interactions.Where(i => i.Interaction.CanInteract(new InteractionEvent(source, i.Target, @event.Point))).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public virtual void Update()
}


public virtual void CreateInteractions(IInteractionTarget[] targets, List<InteractionEntry> interactions)
public virtual void GenerateInteractionsFromSource(IInteractionTarget[] targets, List<InteractionEntry> interactions)
{
foreach (var extension in GetComponents<IInteractionSourceExtension>())
{
extension.CreateInteractions(targets, interactions);
extension.GenerateInteractionsFromSource(targets, interactions);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Engine/Interactions/InteractionTargetBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace SS3D.Engine.Interactions
public abstract class InteractionTargetBehaviour : MonoBehaviour, IInteractionTarget, IGameObjectProvider
{
public GameObject GameObject => gameObject;
public abstract IInteraction[] GenerateInteractions(InteractionEvent interactionEvent);
public abstract IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent);
}
}
2 changes: 1 addition & 1 deletion Assets/Engine/Interactions/InteractionTargetGameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public InteractionTargetGameObject(GameObject gameObject)

public GameObject GameObject { get; }

public IInteraction[] GenerateInteractions(InteractionEvent interactionEvent)
public IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent)
{
return new IInteraction[0];
}
Expand Down
Loading

0 comments on commit 82db883

Please sign in to comment.