Ejemplo n.º 1
0
            public static dynamic GetTSObject(ComponentTypeEnum dynEnum)
            {
                var tsType = TSActivator.CreateInstance("Tekla.Structures.Catalogs.ComponentItem.ComponentTypeEnum").GetType();

                switch (dynEnum)
                {
                case ComponentTypeEnum.UNKNOWN:
                    return(System.Enum.Parse(tsType, "UNKNOWN"));

                case ComponentTypeEnum.CONNECTION:
                    return(System.Enum.Parse(tsType, "CONNECTION"));

                case ComponentTypeEnum.COMPONENT:
                    return(System.Enum.Parse(tsType, "COMPONENT"));

                case ComponentTypeEnum.SEAM:
                    return(System.Enum.Parse(tsType, "SEAM"));

                case ComponentTypeEnum.DETAIL:
                    return(System.Enum.Parse(tsType, "DETAIL"));

                case ComponentTypeEnum.DRAWING_PLUGIN:
                    return(System.Enum.Parse(tsType, "DRAWING_PLUGIN"));

                case ComponentTypeEnum.CUSTOM_PART:
                    return(System.Enum.Parse(tsType, "CUSTOM_PART"));

                default:
                    throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
                }
            }
    private IEnumerator CheckForBomb()
    {
        yield return(new WaitUntil(() => SceneManager.Instance.GameplayState.Bombs != null && SceneManager.Instance.GameplayState.Bombs.Count > 0));

        yield return(new WaitForSeconds(2.0f));

        Bombs.AddRange(SceneManager.Instance.GameplayState.Bombs);
        int i = 0;

        string[] keyModules =
        {
            "SouvenirModule", "MemoryV2", "TurnTheKey", "TurnTheKeyAdvanced", "theSwan", "HexiEvilFMN", "taxReturns"
        };
        foreach (Bomb bomb in Bombs)
        {
            BombCommanders.Add(new BombCommander(bomb, i));
            foreach (BombComponent bombComponent in bomb.BombComponents)
            {
                ComponentTypeEnum componentType = bombComponent.ComponentType;
                bool   keyModule  = false;
                string moduleName = string.Empty;

                switch (componentType)
                {
                case ComponentTypeEnum.Empty:
                case ComponentTypeEnum.Timer:
                    continue;

                case ComponentTypeEnum.NeedyCapacitor:
                case ComponentTypeEnum.NeedyKnob:
                case ComponentTypeEnum.NeedyVentGas:
                case ComponentTypeEnum.NeedyMod:
                    moduleName = bombComponent.GetModuleDisplayName();
                    keyModule  = true;
                    break;

                case ComponentTypeEnum.Mod:
                    KMBombModule KMModule = bombComponent.GetComponent <KMBombModule>();
                    keyModule = keyModules.Contains(KMModule.ModuleType);
                    goto default;

                default:
                    moduleName = bombComponent.GetModuleDisplayName();
                    break;
                }
                Module module = new Module(bombComponent, i)
                {
                    ComponentType = componentType,
                    IsKeyModule   = keyModule,
                    ModuleName    = moduleName
                };

                Modules.Add(module);
            }
            i++;
        }
        BombActive = true;
    }
Ejemplo n.º 3
0
    private bool CreateComponentHandlesForBomb(MonoBehaviour bomb)
    {
        bool foundComponents = false;

        IList bombComponents = (IList)CommonReflectedTypeInfo.BombComponentsField.GetValue(bomb);

        if (bombComponents.Count > 12)
        {
            _bombCommanders[_bombCommanders.Count - 1]._multiDecker = true;
        }

        foreach (MonoBehaviour bombComponent in bombComponents)
        {
            object            componentType     = CommonReflectedTypeInfo.ComponentTypeField.GetValue(bombComponent);
            int               componentTypeInt  = (int)Convert.ChangeType(componentType, typeof(int));
            ComponentTypeEnum componentTypeEnum = (ComponentTypeEnum)componentTypeInt;

            switch (componentTypeEnum)
            {
            case ComponentTypeEnum.Empty:
                continue;

            case ComponentTypeEnum.Timer:
                _bombCommanders[_bombCommanders.Count - 1]._timerComponent = bombComponent;
                continue;

            default:
                foundComponents = true;
                break;
            }

            TwitchComponentHandle handle = (TwitchComponentHandle)Instantiate(twitchComponentHandlePrefab, bombComponent.transform, false);
            handle.ircConnection      = _ircConnection;
            handle.bombCommander      = _bombCommanders[_bombCommanders.Count - 1];
            handle.bombComponent      = bombComponent;
            handle.componentType      = componentTypeEnum;
            handle.coroutineQueue     = _coroutineQueue;
            handle.coroutineCanceller = _coroutineCanceller;
            handle.leaderboard        = leaderboard;
            handle.bombID             = _currentBomb == -1 ? -1 : _bombCommanders.Count - 1;

            Vector3 idealOffset = handle.transform.TransformDirection(GetIdealPositionForHandle(handle, bombComponents, out handle.direction));
            handle.transform.SetParent(bombComponent.transform.parent, true);
            handle.basePosition = handle.transform.localPosition;
            handle.idealHandlePositionOffset = bombComponent.transform.parent.InverseTransformDirection(idealOffset);

            handle.bombCommander._bombSolvableModules++;

            _componentHandles.Add(handle);
        }

        return(foundComponents);
    }
    private bool CreateComponentHandlesForBomb(Bomb bomb)
    {
        bool foundComponents = false;

        List <BombComponent> bombComponents = bomb.BombComponents;

        var bombCommander = _bombCommanders[_bombCommanders.Count - 1];

        if (bombComponents.Count > 12 || TwitchPlaySettings.data.ForceMultiDeckerMode)
        {
            bombCommander.multiDecker = true;
        }

        foreach (BombComponent bombComponent in bombComponents)
        {
            ComponentTypeEnum componentType = bombComponent.ComponentType;

            switch (componentType)
            {
            case ComponentTypeEnum.Empty:
                continue;

            case ComponentTypeEnum.Timer:
                _bombCommanders[_bombCommanders.Count - 1].timerComponent = (TimerComponent)bombComponent;
                continue;

            default:
                foundComponents = true;
                break;
            }

            TwitchComponentHandle handle = Instantiate <TwitchComponentHandle>(twitchComponentHandlePrefab, bombComponent.transform, false);
            handle.ircConnection      = _ircConnection;
            handle.bombCommander      = bombCommander;
            handle.bombComponent      = bombComponent;
            handle.componentType      = componentType;
            handle.coroutineQueue     = _coroutineQueue;
            handle.coroutineCanceller = _coroutineCanceller;
            handle.leaderboard        = leaderboard;
            handle.bombID             = _currentBomb == -1 ? -1 : _bombCommanders.Count - 1;

            Vector3 idealOffset = handle.transform.TransformDirection(GetIdealPositionForHandle(handle, bombComponents, out handle.direction));
            handle.transform.SetParent(bombComponent.transform.parent, true);
            handle.basePosition = handle.transform.localPosition;
            handle.idealHandlePositionOffset = bombComponent.transform.parent.InverseTransformDirection(idealOffset);

            bombCommander.bombSolvableModules++;

            _componentHandles.Add(handle);
        }

        return(foundComponents);
    }
        public static ObservableCollection <ClassProperties> Enumerate(ComponentTypeEnum component)
        {
            Assembly assembly = typeof(ComponentTypeAttribute).Assembly;
            var      result   = new ObservableCollection <ClassProperties>();

            foreach (var typeNode in assembly.DefinedTypes)
            {
                if (typeNode.GetCustomAttribute(typeof(ComponentTypeAttribute)) != null)
                {
                    if ((ComponentTypeEnum)typeNode.CustomAttributes.Where(x => x.AttributeType == typeof(ComponentTypeAttribute)).First().ConstructorArguments[0].Value == component)
                    {
                        var Properties = typeNode.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                        foreach (var node in Properties)
                        {
                            if (node.GetCustomAttribute(typeof(ReportVisibilityAttribute)) != null)
                            {
                                if (!(bool)node.GetCustomAttributesData().Where(x => x.AttributeType == typeof(ReportVisibilityAttribute)).First().ConstructorArguments[0].Value)
                                {
                                    continue;
                                }
                                else
                                {
                                    var property = new ClassProperties()
                                    {
                                        SourceClassTypeName = typeNode.Name,
                                        PropertyKey         = node.Name,
                                        PropertyBindingKey  = typeNode.Name + "_" + node.Name,
                                        PropertyValueType   = node.PropertyType.Name
                                    };
                                    foreach (var anode in node.CustomAttributes)
                                    {
                                        if (anode.AttributeType == typeof(DescriptionAttribute))
                                        {
                                            property.PropertyDescription = anode.ConstructorArguments[0].Value.ToString();
                                        }
                                    }
                                    result.Add(property);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static int GetSize(this ComponentTypeEnum componentType)
        {
            switch (componentType)
            {
            case ComponentTypeEnum.BYTE:
            case ComponentTypeEnum.UNSIGNED_BYTE:
                return(1);

            case ComponentTypeEnum.SHORT:
            case ComponentTypeEnum.UNSIGNED_SHORT:
                return(2);

            case ComponentTypeEnum.UNSIGNED_INT:
            case ComponentTypeEnum.FLOAT:
                return(4);

            default:
                throw new ArgumentException();
            }
        }
Ejemplo n.º 7
0
        public static void FloatAccessorCommon(DataType outputType, BinaryWriter binaryWriter, out ComponentTypeEnum componentType, out bool normalized, out Action <float> writeComponent)
        {
            switch (outputType)
            {
            case DataType.Float:
                writeComponent = value => binaryWriter.Write(value);
                componentType  = ComponentTypeEnum.FLOAT;
                normalized     = false;
                break;

            case DataType.NormalizedShort:
                writeComponent = value => binaryWriter.Write(System.Convert.ToInt16(Math.Round(value * short.MaxValue)));
                componentType  = ComponentTypeEnum.SHORT;
                normalized     = true;
                break;

            case DataType.NormalizedByte:
                writeComponent = value => binaryWriter.Write(System.Convert.ToSByte(Math.Round(value * sbyte.MaxValue)));
                componentType  = ComponentTypeEnum.BYTE;
                normalized     = true;
                break;

            case DataType.NormalizedUnsignedShort:
                writeComponent = value => binaryWriter.Write(System.Convert.ToUInt16(Math.Round(value * ushort.MaxValue)));
                componentType  = ComponentTypeEnum.UNSIGNED_SHORT;
                normalized     = true;
                break;

            case DataType.NormalizedUnsignedByte:
                writeComponent = value => binaryWriter.Write(System.Convert.ToByte(Math.Round(value * byte.MaxValue)));
                componentType  = ComponentTypeEnum.UNSIGNED_BYTE;
                normalized     = true;
                break;

            default:
                throw new InvalidOperationException($"Invalid accessor output type {outputType}");
            }
        }
Ejemplo n.º 8
0
        public static void IntAccessorCommon(DataType outputType, BinaryWriter binaryWriter, out ComponentTypeEnum componentType, out Action <int> writeComponent)
        {
            switch (outputType)
            {
            case DataType.UnsignedInt:
                writeComponent = value => binaryWriter.Write((uint)value);
                componentType  = ComponentTypeEnum.UNSIGNED_INT;
                break;

            case DataType.UnsignedShort:
                writeComponent = value => binaryWriter.Write((ushort)value);
                componentType  = ComponentTypeEnum.UNSIGNED_SHORT;
                break;

            case DataType.UnsignedByte:
                writeComponent = value => binaryWriter.Write((byte)value);
                componentType  = ComponentTypeEnum.UNSIGNED_BYTE;
                break;

            default:
                throw new InvalidOperationException($"Invalid data output type {outputType}");
            }
        }
Ejemplo n.º 9
0
 public CubicSplineAnimationSampler(IEnumerable <float> inputKeys, IEnumerable <Key> outputKeys, ComponentTypeEnum outputComponentType = ComponentTypeEnum.FLOAT)
     : base(inputKeys, outputKeys, outputComponentType)
 {
     OutputKeys = outputKeys;
 }
Ejemplo n.º 10
0
 public LinearAnimationSampler(IEnumerable <float> inputKeys, IEnumerable <T> outputKeys, ComponentTypeEnum outputComponentType = ComponentTypeEnum.FLOAT)
     : base(inputKeys, outputKeys, outputComponentType)
 {
     OutputKeys = outputKeys;
 }
Ejemplo n.º 11
0
 public AnimationSampler(IEnumerable <float> inputKeys, IEnumerable outputKeys, ComponentTypeEnum outputComponentType)
 {
     InputKeys           = inputKeys;
     OutputKeys          = outputKeys;
     OutputComponentType = outputComponentType;
 }
Ejemplo n.º 12
0
 public ComponentTypeAttribute(ComponentTypeEnum componentTypeValue)
 {
     ComponentTypeValue = componentTypeValue;
 }
Ejemplo n.º 13
0
 public ComponentTypeAttribute()
 {
     ComponentTypeValue = 0;
 }
    public static ComponentSolver CreateSolver(BombCommander bombCommander, MonoBehaviour bombComponent, ComponentTypeEnum componentType, IRCConnection ircConnection, CoroutineCanceller canceller)
    {
        switch (componentType)
        {
        case ComponentTypeEnum.Wires:
            return(new WireSetComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Keypad:
            return(new KeypadComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.BigButton:
            return(new ButtonComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Memory:
            return(new MemoryComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Simon:
            return(new SimonComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Venn:
            return(new VennWireComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Morse:
            return(new MorseCodeComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.WireSequence:
            return(new WireSequenceComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Password:
            return(new PasswordComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Maze:
            return(new InvisibleWallsComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.WhosOnFirst:
            return(new WhosOnFirstComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.NeedyVentGas:
            return(new NeedyVentComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.NeedyCapacitor:
            return(new NeedyDischargeComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.NeedyKnob:
            return(new NeedyKnobComponentSolver(bombCommander, bombComponent, ircConnection, canceller));

        case ComponentTypeEnum.Mod:
            KMBombModule solvableModule = bombComponent.GetComponent <KMBombModule>();
            return(CreateModComponentSolver(bombCommander, bombComponent, ircConnection, canceller, solvableModule.ModuleType));

        case ComponentTypeEnum.NeedyMod:
            KMNeedyModule needyModule = bombComponent.GetComponent <KMNeedyModule>();
            return(CreateModComponentSolver(bombCommander, bombComponent, ircConnection, canceller, needyModule.ModuleType));

        default:
            throw new NotSupportedException(string.Format("Currently {0} is not supported by 'Twitch Plays'.", (string)CommonReflectedTypeInfo.ModuleDisplayNameField.Invoke(bombComponent, null)));
        }
    }
    public bool CreateComponentHandlesForBomb(Bomb bomb)
    {
        string[] keyModules =
        {
            "SouvenirModule", "MemoryV2", "TurnTheKey", "TurnTheKeyAdvanced", "theSwan", "HexiEvilFMN"
        };
        bool foundComponents = false;

        List <BombComponent> bombComponents = bomb.BombComponents.Shuffle().ToList();

        var bombCommander = BombCommanders[BombCommanders.Count - 1];

        foreach (BombComponent bombComponent in bombComponents)
        {
            ComponentTypeEnum componentType = bombComponent.ComponentType;
            bool   keyModule  = false;
            string moduleName = "";

            switch (componentType)
            {
            case ComponentTypeEnum.Empty:
                continue;

            case ComponentTypeEnum.Timer:
                BombCommanders[BombCommanders.Count - 1].timerComponent = (TimerComponent)bombComponent;
                continue;

            case ComponentTypeEnum.NeedyCapacitor:
            case ComponentTypeEnum.NeedyKnob:
            case ComponentTypeEnum.NeedyVentGas:
            case ComponentTypeEnum.NeedyMod:
                moduleName      = bombComponent.GetModuleDisplayName();
                keyModule       = true;
                foundComponents = true;
                break;

            case ComponentTypeEnum.Mod:
                KMBombModule module = bombComponent.GetComponent <KMBombModule>();
                keyModule = keyModules.Contains(module.ModuleType);
                goto default;

            default:
                moduleName = bombComponent.GetModuleDisplayName();
                bombCommander.bombSolvableModules++;
                foundComponents = true;
                break;
            }

            if (!bombCommander.SolvedModules.ContainsKey(moduleName))
            {
                bombCommander.SolvedModules[moduleName] = new List <TwitchComponentHandle>();
            }

            TwitchComponentHandle handle = Instantiate <TwitchComponentHandle>(twitchComponentHandlePrefab, bombComponent.transform, false);
            handle.bombCommander  = bombCommander;
            handle.bombComponent  = bombComponent;
            handle.componentType  = componentType;
            handle.coroutineQueue = _coroutineQueue;
            handle.bombID         = _currentBomb == -1 ? -1 : BombCommanders.Count - 1;
            handle.IsKey          = keyModule;

            handle.transform.SetParent(bombComponent.transform.parent, true);
            handle.basePosition = handle.transform.localPosition;

            ComponentHandles.Add(handle);
        }

        return(foundComponents);
    }