コード例 #1
0
 private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args)
 {
     if (!component.IsFolded)
     {
         args.Cancel();
     }
 }
コード例 #2
0
    /// <summary>
    /// Set the folded state of the given <see cref="FoldableComponent"/>
    /// </summary>
    /// <param name="component"></param>
    /// <param name="folded">If true, the component will become folded, else unfolded</param>
    public virtual void SetFolded(FoldableComponent component, bool folded)
    {
        component.IsFolded = folded;
        Dirty(component);

        if (TryComp(component.Owner, out AppearanceComponent? appearance))
        {
            appearance.SetData(FoldKey, folded);
        }
    }
コード例 #3
0
    private void OnHandleState(EntityUid uid, FoldableComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not FoldableComponentState state)
        {
            return;
        }

        if (state.IsFolded != component.IsFolded)
        {
            SetFolded(component, state.IsFolded);
        }
    }
コード例 #4
0
 private void OnFoldableInit(EntityUid uid, FoldableComponent component, ComponentInit args)
 {
     SetFolded(component, component.IsFolded);
 }
コード例 #5
0
 private void OnGetState(EntityUid uid, FoldableComponent component, ref ComponentGetState args)
 {
     args.State = new FoldableComponentState(component.IsFolded);
 }