-
Notifications
You must be signed in to change notification settings - Fork 12
Interface
Interface/contract for a type that is considered a GameObject source.Such as Components/IComponents, which are attached to GameObjects, so therefore are a source of a GameObject.
Base contract for any interface contract that should be considered a Component
flowchart LR
IGameObjectSource --- IComponent --> IGameObjectSource
IComponent --- IGameObjectSource
linkStyle 0,2 stroke:none
A special interface that allows you to deploy OnloadComponents
method, when this button load component in header script in Inspector will work, you can perform setups like Auto Binding Component here so that when clicking on this button everything will everything will Setup automatically avoids the error due to pulling
For components that do not deploy ILoadComponent, when clicking the button it does not perform anything, just announced that this component does not deploy ILoadComponent
Provide an Accept
method with a visitor parameter
public abstract class Entity : MonoBehaviour, IVisitable
{
public void Accept(IVisitor visitor) => visitor.Visit(this);
}
Provide an Visit
method with a visitable parameter
public class Item : MonoBehaviour, IVisitor
{
public void Visit<T>(T visitable) where T : Component, IVisitable
{
if (visitable is Entity entity)
{
// todo take item
}
}
private void OnTriggerEnter(Collider other)
{
other.TryGetComponent<IVisitable>(out var visitable);
visitable?.Accept(this);
}
}
Represents a mechanism for triggering an event.
public sealed class FakeEvent : IEventTrigger
{
public bool HasBeenTriggered { get; private set; }
public void Trigger() => HasBeenTriggered = true;
}