예제 #1
0
    protected override void Do()
    {
        m_Action = new VCEAction();

        VCComponentData data = VCComponentData.Create(VCEditor.SelectedPart);

        if (data != null)
        {
            data.m_ComponentId = VCEditor.SelectedPart.m_ID;
            data.m_Type        = VCEditor.SelectedPart.m_Type;
            data.m_Position    = m_PartInst.transform.localPosition;
            data.m_Rotation    = Vector3.zero;
            data.m_Scale       = Vector3.one;
            data.m_Visible     = true;
            data.m_CurrIso     = VCEditor.s_Scene.m_IsoData;
            data.Validate();

            VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                VCEditor.s_Mirror.MirrorComponent(data);

                for (int i = VCEditor.s_Mirror.OutputCnt - 1; i >= 0; --i)
                {
                    VCComponentData image = VCEditor.s_Mirror.ComponentOutput[i];
                    if (VCEditor.s_Scene.m_IsoData.IsComponentIn(image.m_Position))
                    {
                        List <VCComponentData> conflicts = VCEditor.s_Scene.m_IsoData.FindComponentsAtPos(image.m_Position, image.m_ComponentId);
                        foreach (VCComponentData conflict in conflicts)
                        {
                            if (conflict.m_Scale != image.m_Scale)
                            {
                                continue;
                            }
                            if (conflict.m_Visible != image.m_Visible)
                            {
                                continue;
                            }

                            if (image is IVCMultiphaseComponentData && conflict is IVCMultiphaseComponentData)
                            {
                                if ((image as IVCMultiphaseComponentData).Phase != (conflict as IVCMultiphaseComponentData).Phase)
                                {
                                    continue;
                                }
                            }

                            // Delete conflict
                            int index = VCEditor.s_Scene.m_IsoData.GetComponentIndex(conflict);
                            if (index < 0)
                            {
                                continue;
                            }
                            VCEDelComponent del = new VCEDelComponent(index, conflict);
                            del.Redo();
                            m_Action.Modifies.Add(del);
                        }
                        VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, image);
                        modify.Redo();
                        m_Action.Modifies.Add(modify);
                    }
                }
                m_Action.Register();
            }
            // No mirror
            else
            {
                VCFixedHandPartData fixdata = data as VCFixedHandPartData;
                if (fixdata != null)
                {
                    fixdata.m_LeftHand = data.m_Position.x < VCEditor.s_Scene.m_IsoData.m_HeadInfo.xSize * VCEditor.s_Scene.m_Setting.m_VoxelSize * 0.5f;
                }

                VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, data);
                m_Action.Modifies.Add(modify);
                m_Action.Do();
            }
        }
        else
        {
            Debug.LogWarning("Forget to add this part's implementation ?");
        }
    }
예제 #2
0
    protected override void Do()
    {
        if (VCEditor.SelectedDecalGUID == 0)
        {
            return;
        }
        if (VCEditor.SelectedDecalIndex < 0)
        {
            return;
        }
        if (VCEditor.SelectedDecal == null)
        {
            return;
        }
        m_Action = new VCEAction();

        VCDecalData dcldata = VCComponentData.CreateDecal() as VCDecalData;

        if (dcldata != null)
        {
            dcldata.m_ComponentId = VCDecalData.s_ComponentId;
            dcldata.m_Type        = EVCComponent.cpDecal;
            dcldata.m_Position    = m_DecalInst.transform.localPosition;
            dcldata.m_Rotation    = VCEMath.NormalizeEulerAngle(m_DecalInst.transform.localEulerAngles);
            dcldata.m_Scale       = Vector3.one;
            dcldata.m_Visible     = true;
            dcldata.m_CurrIso     = VCEditor.s_Scene.m_IsoData;
            dcldata.m_Guid        = VCEditor.SelectedDecalGUID;
            dcldata.m_AssetIndex  = VCEditor.SelectedDecalIndex;
            dcldata.m_Size        = m_DecalInst.m_Size;
            dcldata.m_Depth       = m_DecalInst.m_Depth;
            dcldata.m_Mirrored    = m_DecalInst.m_Mirrored;
            dcldata.m_ShaderIndex = m_DecalInst.m_ShaderIndex;
            dcldata.m_Color       = m_DecalInst.m_Color;
            dcldata.Validate();

            ulong olddcl_guid = VCEditor.s_Scene.m_IsoData.DecalGUID(VCEditor.SelectedDecalIndex);
            ulong newdcl_guid = VCEditor.SelectedDecalGUID;
            if (olddcl_guid != newdcl_guid)
            {
                VCEAlterDecalMap modify = new VCEAlterDecalMap(VCEditor.SelectedDecalIndex, olddcl_guid, newdcl_guid);
                modify.Redo();
                m_Action.Modifies.Add(modify);
            }

            VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize);
            // Mirror
            if (VCEditor.s_Mirror.Enabled_Masked)
            {
                VCEditor.s_Mirror.MirrorComponent(dcldata);

                for (int i = VCEditor.s_Mirror.OutputCnt - 1; i >= 0; --i)
                {
                    VCComponentData image = VCEditor.s_Mirror.ComponentOutput[i];
                    if (VCEditor.s_Scene.m_IsoData.IsComponentIn(image.m_Position))
                    {
                        VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, image);
                        modify.Redo();
                        m_Action.Modifies.Add(modify);
                    }
                }
            }
            // No mirror
            else
            {
                VCEAddComponent modify = new VCEAddComponent(VCEditor.s_Scene.m_IsoData.m_Components.Count, dcldata);
                modify.Redo();
                m_Action.Modifies.Add(modify);
            }
            m_Action.Register();
        }
        else
        {
            Debug.LogWarning("Decal data create failed");
        }
    }