Ejemplo n.º 1
0
        public static ConvertedItem SetupGameObject(this Flipper flipper, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <FlipperAuthoring>().SetItem(flipper);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            FlipperColliderAuthoring colliderAuthoring = null;

            switch (flipper.SubComponent)
            {
            case ItemSubComponent.None:
                colliderAuthoring = obj.AddComponent <FlipperColliderAuthoring>();

                // if invisible in main component, we skip creation entirely, because we think users won't dynamically toggle visibility.
                if (flipper.Data.IsVisible)
                {
                    meshAuthoring.Add(ConvertedItem.CreateChild <FlipperBaseMeshAuthoring>(obj, FlipperMeshGenerator.Base));
                    meshAuthoring.Add(ConvertedItem.CreateChild <FlipperRubberMeshAuthoring>(obj, FlipperMeshGenerator.Rubber));
                }
                break;

            case ItemSubComponent.Collider: {
                Logger.Warn("Cannot parent a flipper collider to a different object than a flipper!");
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Cannot parent a flipper mesh to a different object than a flipper!");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 2
0
        public void OnBulbEnabled(bool bulbEnabledBefore, bool bulbEnabledAfter)
        {
            if (bulbEnabledBefore == bulbEnabledAfter)
            {
                return;
            }

            if (bulbEnabledAfter)
            {
                ConvertedItem.CreateChild <LightBulbMeshAuthoring>(gameObject, LightMeshGenerator.Bulb);
                ConvertedItem.CreateChild <LightSocketMeshAuthoring>(gameObject, LightMeshGenerator.Socket);
            }
            else
            {
                var bulbMeshAuthoring = GetComponentInChildren <LightBulbMeshAuthoring>();
                if (bulbMeshAuthoring != null)
                {
                    DestroyImmediate(bulbMeshAuthoring.gameObject);
                }
                var socketMeshAuthoring = GetComponentInChildren <LightSocketMeshAuthoring>();
                if (socketMeshAuthoring != null)
                {
                    DestroyImmediate(socketMeshAuthoring.gameObject);
                }
            }
        }
        public static ConvertedItem SetupGameObject(this Surface surface, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <SurfaceAuthoring>().SetItem(surface);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            SurfaceColliderAuthoring colliderAuthoring = null;

            switch (surface.SubComponent)
            {
            case ItemSubComponent.None:
                colliderAuthoring = obj.AddColliderComponent(surface);
                meshAuthoring.Add(ConvertedItem.CreateChild <SurfaceSideMeshAuthoring>(obj, SurfaceMeshGenerator.Side));
                meshAuthoring.Add(ConvertedItem.CreateChild <SurfaceTopMeshAuthoring>(obj, SurfaceMeshGenerator.Top));
                break;

            case ItemSubComponent.Collider: {
                colliderAuthoring = obj.AddColliderComponent(surface);
                break;
            }

            case ItemSubComponent.Mesh: {
                meshAuthoring.Add(ConvertedItem.CreateChild <SurfaceSideMeshAuthoring>(obj, SurfaceMeshGenerator.Side));
                meshAuthoring.Add(ConvertedItem.CreateChild <SurfaceTopMeshAuthoring>(obj, SurfaceMeshGenerator.Top));
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 4
0
        public void UpdateMeshComponents(int rampTypeBefore, int rampTypeAfter)
        {
            var rampFlatBefore = rampTypeBefore == RampType.RampTypeFlat;
            var rampFlatAfter  = rampTypeAfter == RampType.RampTypeFlat;

            if (rampFlatBefore == rampFlatAfter)
            {
                return;
            }

            if (rampFlatAfter)
            {
                var flatRampAuthoring = GetComponentInChildren <RampWireMeshAuthoring>();
                if (flatRampAuthoring != null)
                {
                    DestroyImmediate(flatRampAuthoring.gameObject);
                }
                ConvertedItem.CreateChild <RampFloorMeshAuthoring>(gameObject, RampMeshGenerator.Floor);
                ConvertedItem.CreateChild <RampWallMeshAuthoring>(gameObject, RampMeshGenerator.Wall);
            }
            else
            {
                var flatFloorAuthoring = GetComponentInChildren <RampFloorMeshAuthoring>();
                if (flatFloorAuthoring != null)
                {
                    DestroyImmediate(flatFloorAuthoring.gameObject);
                }
                var flatWallAuthoring = GetComponentInChildren <RampWallMeshAuthoring>();
                if (flatWallAuthoring != null)
                {
                    DestroyImmediate(flatWallAuthoring.gameObject);
                }
                ConvertedItem.CreateChild <RampWireMeshAuthoring>(gameObject, RampMeshGenerator.Wires);
            }
        }
Ejemplo n.º 5
0
        public static ConvertedItem SetupGameObject(this Spinner spinner, GameObject obj)
        {
            var meshAuthoring = new List <IItemMeshAuthoring>();
            var mainAuthoring = obj.AddComponent <SpinnerAuthoring>().SetItem(spinner);
            SpinnerColliderAuthoring colliderAuthoring = null;

            switch (spinner.SubComponent)
            {
            case ItemSubComponent.None:
                colliderAuthoring = obj.AddComponent <SpinnerColliderAuthoring>();
                meshAuthoring.Add(ConvertedItem.CreateChild <SpinnerBracketMeshAuthoring>(obj, SpinnerMeshGenerator.Bracket));

                var wireMeshAuth = ConvertedItem.CreateChild <SpinnerPlateMeshAuthoring>(obj, SpinnerMeshGenerator.Plate);
                wireMeshAuth.gameObject.AddComponent <SpinnerPlateAnimationAuthoring>();
                meshAuthoring.Add(wireMeshAuth);
                break;

            case ItemSubComponent.Collider: {
                Logger.Warn("Cannot parent a spinner collider to a different object than a spinner!");
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Cannot parent a spinner mesh to a different object than a spinner!");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 6
0
        public bool IsValidChild(ConvertedItem parent)
        {
            if (MeshAuthoring.Any())
            {
                return(MeshAuthoring.First().ValidParents.Contains(parent.MainAuthoring.GetType()));
            }

            if (ColliderAuthoring != null)
            {
                return(ColliderAuthoring.ValidParents.Contains(parent.MainAuthoring.GetType()));
            }

            return(MainAuthoring.ValidParents.Contains(parent.MainAuthoring.GetType()));
        }
Ejemplo n.º 7
0
        public static ConvertedItem SetupGameObject(this Light light, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <LightAuthoring>().SetItem(light);
            var meshAuthoring = new List <IItemMeshAuthoring>();

            if (!light.Data.ShowBulbMesh)
            {
                return(new ConvertedItem(mainAuthoring));
            }

            meshAuthoring.Add(ConvertedItem.CreateChild <LightBulbMeshAuthoring>(obj, LightMeshGenerator.Bulb));
            meshAuthoring.Add(ConvertedItem.CreateChild <LightSocketMeshAuthoring>(obj, LightMeshGenerator.Socket));

            return(new ConvertedItem(mainAuthoring, meshAuthoring));
        }
        public static ConvertedItem SetupGameObject(this Plunger plunger, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <PlungerAuthoring>().SetItem(plunger);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            PlungerColliderAuthoring colliderAuthoring = null;

            switch (plunger.SubComponent)
            {
            case ItemSubComponent.None: {
                colliderAuthoring = obj.AddComponent <PlungerColliderAuthoring>();
                switch (plunger.Data.Type)
                {
                case PlungerType.PlungerTypeFlat:
                    meshAuthoring.Add(ConvertedItem.CreateChild <PlungerFlatMeshAuthoring>(obj, PlungerMeshGenerator.Flat));
                    break;

                case PlungerType.PlungerTypeCustom:
                    meshAuthoring.Add(ConvertedItem.CreateChild <PlungerSpringMeshAuthoring>(obj, PlungerMeshGenerator.Spring));
                    meshAuthoring.Add(ConvertedItem.CreateChild <PlungerRodMeshAuthoring>(obj, PlungerMeshGenerator.Rod));
                    break;

                case PlungerType.PlungerTypeModern:
                    meshAuthoring.Add(ConvertedItem.CreateChild <PlungerRodMeshAuthoring>(obj, PlungerMeshGenerator.Rod));
                    break;
                }
                break;
            }

            case ItemSubComponent.Collider: {
                Logger.Warn("Cannot parent a plunger collider to a different object than a plunger!");
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Cannot parent a plunger mesh to a different object than a plunger!");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 9
0
        public void OnRubberWidthUpdated(float before, float after)
        {
            if (before != 0 && after != 0f)
            {
                return;
            }

            if (before == 0)
            {
                ConvertedItem.CreateChild <FlipperRubberMeshAuthoring>(gameObject, FlipperMeshGenerator.Rubber);
            }

            if (after == 0)
            {
                var rubberAuthoring = GetComponentInChildren <FlipperRubberMeshAuthoring>();
                if (rubberAuthoring != null)
                {
                    DestroyImmediate(rubberAuthoring.gameObject);
                }
            }
        }
Ejemplo n.º 10
0
        public static ConvertedItem SetupGameObject(this Bumper bumper, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <BumperAuthoring>().SetItem(bumper);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            BumperColliderAuthoring colliderAuthoring = null;

            switch (bumper.SubComponent)
            {
            case ItemSubComponent.None:
                colliderAuthoring = obj.AddColliderComponent(bumper);
                meshAuthoring.Add(ConvertedItem.CreateChild <BumperBaseMeshAuthoring>(obj, BumperMeshGenerator.Base));
                meshAuthoring.Add(ConvertedItem.CreateChild <BumperCapMeshAuthoring>(obj, BumperMeshGenerator.Cap));

                var ring  = ConvertedItem.CreateChild <BumperRingMeshAuthoring>(obj, BumperMeshGenerator.Ring);
                var skirt = ConvertedItem.CreateChild <BumperSkirtMeshAuthoring>(obj, BumperMeshGenerator.Skirt);

                ring.gameObject.AddComponent <BumperRingAnimationAuthoring>();
                skirt.gameObject.AddComponent <BumperSkirtAnimationAuthoring>();

                meshAuthoring.Add(ring);
                meshAuthoring.Add(skirt);
                break;

            case ItemSubComponent.Collider: {
                Logger.Warn("Bumper collider cannot be parented to anything else than bumpers.");
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Bumper mesh cannot be parented to anything else than bumpers.");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();

            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 11
0
        public static ConvertedItem SetupGameObject(this Ramp ramp, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <RampAuthoring>().SetItem(ramp);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            RampColliderAuthoring colliderAuthoring = null;

            switch (ramp.SubComponent)
            {
            case ItemSubComponent.None:
                colliderAuthoring = obj.AddColliderComponent(ramp);
                if (ramp.IsHabitrail)
                {
                    meshAuthoring.Add(ConvertedItem.CreateChild <RampWireMeshAuthoring>(obj, RampMeshGenerator.Wires));
                }
                else
                {
                    meshAuthoring.Add(ConvertedItem.CreateChild <RampFloorMeshAuthoring>(obj, RampMeshGenerator.Floor));
                    meshAuthoring.Add(ConvertedItem.CreateChild <RampWallMeshAuthoring>(obj, RampMeshGenerator.Wall));
                }
                break;

            case ItemSubComponent.Collider: {
                colliderAuthoring = obj.AddColliderComponent(ramp);
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Cannot parent a ramp mesh to a different object than a ramp!");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 12
0
        public static ConvertedItem SetupGameObject(this Gate gate, GameObject obj)
        {
            var mainAuthoring = obj.AddComponent <GateAuthoring>().SetItem(gate);
            var meshAuthoring = new List <IItemMeshAuthoring>();
            GateColliderAuthoring colliderAuthoring = null;

            switch (gate.SubComponent)
            {
            case ItemSubComponent.None:
                // collider
                colliderAuthoring = obj.AddColliderComponent(gate);

                // bracket mesh
                meshAuthoring.Add(ConvertedItem.CreateChild <GateBracketMeshAuthoring>(obj, GateMeshGenerator.Bracket));

                // wire mesh
                var wireMeshAuth = ConvertedItem.CreateChild <GateWireMeshAuthoring>(obj, GateMeshGenerator.Wire);
                wireMeshAuth.gameObject.AddComponent <GateWireAnimationAuthoring>();
                meshAuthoring.Add(wireMeshAuth);
                break;

            case ItemSubComponent.Collider: {
                Logger.Warn("Cannot parent a gate collider to a different object than a gate!");
                break;
            }

            case ItemSubComponent.Mesh: {
                Logger.Warn("Cannot parent a gate mesh to a different object than a gate!");
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            obj.AddComponent <ConvertToEntity>();
            return(new ConvertedItem(mainAuthoring, meshAuthoring, colliderAuthoring));
        }
Ejemplo n.º 13
0
        public void OnTypeChanged(int plungerTypeBefore, int plungerTypeAfter)
        {
            if (plungerTypeBefore == plungerTypeAfter)
            {
                return;
            }

            switch (plungerTypeBefore)
            {
            case PlungerType.PlungerTypeFlat:
                // remove flat
                var flatPlungerAuthoring = GetComponentInChildren <PlungerFlatMeshAuthoring>();
                if (flatPlungerAuthoring != null)
                {
                    DestroyImmediate(flatPlungerAuthoring.gameObject);
                }

                // create rod
                ConvertedItem.CreateChild <PlungerRodMeshAuthoring>(gameObject, PlungerMeshGenerator.Rod);

                if (plungerTypeAfter == PlungerType.PlungerTypeCustom)
                {
                    // create spring
                    ConvertedItem.CreateChild <PlungerSpringMeshAuthoring>(gameObject, PlungerMeshGenerator.Spring);
                }
                break;

            case PlungerType.PlungerTypeModern:
                if (plungerTypeAfter == PlungerType.PlungerTypeCustom)
                {
                    // create spring
                    ConvertedItem.CreateChild <PlungerSpringMeshAuthoring>(gameObject, PlungerMeshGenerator.Spring);
                }

                if (plungerTypeAfter == PlungerType.PlungerTypeFlat)
                {
                    // remove rod
                    var rodPlungerAuthoring = GetComponentInChildren <PlungerRodMeshAuthoring>();
                    if (rodPlungerAuthoring != null)
                    {
                        DestroyImmediate(rodPlungerAuthoring.gameObject);
                    }
                    // create flat
                    ConvertedItem.CreateChild <PlungerFlatMeshAuthoring>(gameObject, PlungerMeshGenerator.Flat);
                }
                break;

            case PlungerType.PlungerTypeCustom:
                // remove spring
                var springPlungerAuthoring = GetComponentInChildren <PlungerSpringMeshAuthoring>();
                if (springPlungerAuthoring != null)
                {
                    DestroyImmediate(springPlungerAuthoring.gameObject);
                }

                if (plungerTypeAfter == PlungerType.PlungerTypeFlat)
                {
                    // remove rod
                    var rodPlungerAuthoring = GetComponentInChildren <PlungerRodMeshAuthoring>();
                    if (rodPlungerAuthoring != null)
                    {
                        DestroyImmediate(rodPlungerAuthoring.gameObject);
                    }

                    // create flat
                    ConvertedItem.CreateChild <PlungerFlatMeshAuthoring>(gameObject, PlungerMeshGenerator.Flat);
                }
                break;
            }
        }