Exemplo n.º 1
0
    private void RunViewModelAdd(ViewModel vm, IHeldItem item, bool doMeshes)
    {
        ModViewModelAddArgs modViewModelAddArg = new ModViewModelAddArgs(vm, item, doMeshes);

        for (int i = 0; i < 5; i++)
        {
            this._itemMods.BindAsLocal(i, ref modViewModelAddArg, this);
        }
    }
Exemplo n.º 2
0
 private void BindModAsLocal(ref ItemModPair pair, ref ModViewModelAddArgs a)
 {
     if (((int)pair.bindState) == 2)
     {
         this.UnBindModAsProxy(ref pair);
     }
     if ((((int)pair.bindState) == 1) || (((int)pair.bindState) == 3))
     {
         a.modRep = pair.representation;
         pair.dataBlock.BindAsLocal(ref a);
         pair.bindState = BindState.Local;
     }
 }
Exemplo n.º 3
0
    protected override bool InstallToViewModel(ref ModViewModelAddArgs a)
    {
        GameObject gameObject;

        if (this.isMesh && !a.isMesh)
        {
            return(base.InstallToViewModel(ref a));
        }
        if (!this.isMesh && a.isMesh)
        {
            return(base.InstallToViewModel(ref a));
        }
        if (a.vm == null)
        {
            Debug.Log("Viewmodel null for item attachment...");
        }
        if (this.attachObjectVM != null)
        {
            WeaponModRep weaponModRep = (WeaponModRep)a.modRep;
            if (!a.isMesh)
            {
                gameObject = this.GetSocketByName(a.vm, this.attachSocketName).InstantiateAsChild(this.attachObjectVM, true);
            }
            else
            {
                Socket socketByName = this.GetSocketByName(a.vm, this.attachSocketName);
                gameObject = UnityEngine.Object.Instantiate(this.attachObjectVM, socketByName.offset, Quaternion.Euler(socketByName.eulerRotate)) as GameObject;
                gameObject.transform.parent           = socketByName.parent;
                gameObject.transform.localPosition    = socketByName.offset;
                gameObject.transform.localEulerAngles = socketByName.eulerRotate;
            }
            gameObject.name = this.attachObjectVM.name;
            weaponModRep.SetAttached(gameObject, true);
            ViewModelAttachment component = gameObject.GetComponent <ViewModelAttachment>();
            if (component)
            {
                if (this.socketOverrideName != string.Empty && component is VMAttachmentSocketOverride)
                {
                    VMAttachmentSocketOverride vMAttachmentSocketOverride = (VMAttachmentSocketOverride)component;
                    this.SetSocketByname(a.vm, this.socketOverrideName, vMAttachmentSocketOverride.socketOverride);
                    if (this.modifyZoomOffset)
                    {
                        a.vm.punchScalar  = this.punchScalar;
                        a.vm.zoomOffset.z = this.zoomOffsetZ;
                    }
                }
                component.viewModel = a.vm;
            }
        }
        return(true);
    }
Exemplo n.º 4
0
        public void BindAsLocal(int slotNumber, ref ModViewModelAddArgs args, ItemRepresentation itemRep)
        {
            switch (slotNumber)
            {
            case 0:
            {
                itemRep.BindModAsLocal(ref this.a, ref args);
                break;
            }

            case 1:
            {
                itemRep.BindModAsLocal(ref this.b, ref args);
                break;
            }

            case 2:
            {
                itemRep.BindModAsLocal(ref this.c, ref args);
                break;
            }

            case 3:
            {
                itemRep.BindModAsLocal(ref this.d, ref args);
                break;
            }

            case 4:
            {
                itemRep.BindModAsLocal(ref this.e, ref args);
                break;
            }

            default:
            {
                throw new IndexOutOfRangeException();
            }
            }
        }
Exemplo n.º 5
0
 protected virtual bool InstallToViewModel(ref ModViewModelAddArgs a)
 {
     return(false);
 }
Exemplo n.º 6
0
 internal void BindAsLocal(ref ModViewModelAddArgs a)
 {
     this.InstallToViewModel(ref a);
 }