public void BuildTank(NodeAddedEvent e, HangarTankBaseSystem.HangarNode hangar, HangarTankBaseSystem.WeaponSkinItemPreviewLoadedNode weaponSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.WeaponItemPreviewNode weaponItem, HangarTankBaseSystem.HullSkinItemPreviewLoadedNode tankSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.TankItemPreviewNode tankItem, TankPaintItemPreviewLoadedNode tankPaint, WeaponPaintItemPreviewLoadedNode weaponPaint, HangarTankBaseSystem.HangarCameraNode hangarCamera, SingleNode <SupplyEffectSettingsComponent> settings)
        {
            Transform root = hangar.hangarTankPosition.transform;

            root.DestroyChildren();
            GameObject tankInstance = (GameObject)Object.Instantiate(tankSkin.resourceData.Data);

            tankInstance.transform.SetParent(root);
            tankInstance.transform.localPosition = Vector3.zero;
            tankInstance.transform.localRotation = Quaternion.identity;
            tankSkin.hangarItemPreview.Instance  = tankInstance;
            tankInstance.GetComponentInChildren <NitroEffectComponent>().InitEffect(settings.component);
            Transform  mountPoint     = tankInstance.GetComponent <MountPointComponent>().MountPoint;
            GameObject weaponInstance = (GameObject)Object.Instantiate(weaponSkin.resourceData.Data);

            weaponInstance.transform.SetParent(tankInstance.transform);
            weaponInstance.transform.localPosition = mountPoint.localPosition;
            weaponInstance.transform.localRotation = mountPoint.localRotation;
            weaponSkin.hangarItemPreview.Instance  = weaponInstance;
            GameObject tankPaintInstance = (GameObject)Object.Instantiate(tankPaint.resourceData.Data);

            tankPaintInstance.transform.SetParent(tankInstance.transform);
            tankPaintInstance.transform.localPosition = Vector3.zero;
            GameObject weaponPaintInstance = (GameObject)Object.Instantiate(weaponPaint.resourceData.Data);

            weaponPaintInstance.transform.SetParent(tankInstance.transform);
            weaponPaintInstance.transform.localPosition = Vector3.zero;
            PhysicsUtil.SetGameObjectLayer(root.gameObject, Layers.STATIC);
            this.ApplyPaint(tankInstance, weaponInstance, tankPaintInstance, weaponPaintInstance);
            weaponInstance.GetComponentInChildren <DoubleDamageEffectComponent>().InitEffect(settings.component);
            weaponInstance.GetComponentInChildren <DoubleDamageSoundEffectComponent>().RecalculatePlayingParameters();
            Renderer weaponRenderer = TankBuilderUtil.GetWeaponRenderer(weaponInstance);

            weaponRenderer.tag = "TankWeapon";
            Renderer hullRenderer = TankBuilderUtil.GetHullRenderer(tankInstance);

            hullRenderer.tag = "TankHull";
            weaponRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
            weaponRenderer.lightProbeUsage      = LightProbeUsage.Off;
            hullRenderer.reflectionProbeUsage   = ReflectionProbeUsage.Off;
            hullRenderer.lightProbeUsage        = LightProbeUsage.Off;
            BurningTargetBloom componentInChildren = hangarCamera.cameraRootTransform.Root.GetComponentInChildren <BurningTargetBloom>();

            componentInChildren.targets.Clear();
            componentInChildren.targets.Add(weaponRenderer);
            componentInChildren.targets.Add(hullRenderer);
            base.ScheduleEvent <HangarTankBuildedEvent>(hangar);
        }
        public void BuildVisualWeapon(NodeAddedEvent evt, WeaponGraphicsNode weaponGraphics)
        {
            Entity entity = weaponGraphics.Entity;
            BaseRendererComponent component = new BaseRendererComponent();
            Renderer weaponRenderer         = TankBuilderUtil.GetWeaponRenderer(weaponGraphics.weaponVisualRoot.gameObject);

            component.Renderer = weaponRenderer;
            component.Mesh     = (component.Renderer as SkinnedMeshRenderer).sharedMesh;
            entity.AddComponent <StartMaterialsComponent>();
            entity.AddComponent(component);
            WeaponBoundsComponent component3 = new WeaponBoundsComponent {
                WeaponBounds = weaponRenderer.bounds
            };

            entity.AddComponent(component3);
        }
 private void ApplyPaint(GameObject tankInstance, GameObject weaponInstance, GameObject tankPaintInstance, GameObject weaponPaintInstance)
 {
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(tankInstance), TankBuilderUtil.GetWeaponRenderer(weaponInstance), tankPaintInstance.GetComponent <ColoringComponent>(), weaponPaintInstance.GetComponent <ColoringComponent>());
 }
예제 #4
0
 private void SetColoring(ColoringComponent coloring)
 {
     this.coloring = coloring;
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetHullRenderer(this.hullInstance), coloring);
     TankMaterialsUtil.ApplyColoring(TankBuilderUtil.GetWeaponRenderer(this.weaponInstance), coloring);
 }