Beispiel #1
0
        public static Pointer <LocomotionClass> ToLocomotionClass(this ILocomotion locomotion)
        {
            Pointer <IntPtr> ptr = Marshal.GetIUnknownForObject(locomotion);

            Marshal.Release(ptr);
            ptr -= 1;

            return(ptr.Convert <LocomotionClass>());
        }
Beispiel #2
0
        private void KillUpdate()
        {
            if (Target.TryGet(out TechnoExt ext))
            {
                Pointer <TechnoClass> pTechno = ext.OwnerObject;
                TechnoTypeExt         extType = ext.Type;

                CoordStruct curLocation = pTechno.Ref.Base.Base.GetCoords();

                int height = pTechno.Ref.Base.GetHeight();

                Action <int, int> Attack = (int start, int count) => {
                    int         increasement = 360 / count;
                    CoordStruct from         = curLocation;
                    from.Z += 5000;
                    for (int i = 0; i < count; i++)
                    {
                        double      x  = radius * Math.Cos((start + i * increasement) * Math.PI / 180);
                        double      y  = radius * Math.Sin((start + i * increasement) * Math.PI / 180);
                        CoordStruct to = curLocation + new CoordStruct((int)x, (int)y, -height);
                        Pointer <LaserDrawClass> pLaser = YRMemory.Create <LaserDrawClass>(from, to, innerColor, outerColor, outerSpread, 8);
                        pLaser.Ref.Thickness    = 10;
                        pLaser.Ref.IsHouseColor = true;

                        if (frames > 300)
                        {
                            int damage = 11;
                            // MapClass.DamageArea(to, damage, Owner.OwnerObject, pWH, false, Owner.OwnerObject.Ref.Owner);
                            // MapClass.FlashbangWarheadAt(damage, pWH, to);
                            Pointer <BulletClass> pBullet = pBulletType.Ref.CreateBullet(pTechno.Convert <AbstractClass>(), Owner.OwnerObject, damage, pWH, 100, true);
                            pBullet.Ref.Detonate(to);
                        }
                        else
                        {
                            frames++;
                        }
                    }
                };

                Attack(angle, 5);
                angle   = (angle + 4) % 360;
                radius -= 11;
                if (radius < 0)
                {
                    KillStart(ext);
                }
            }
        }
Beispiel #3
0
        static bool TryParse(string str, ref T outValue)
        {
            Pointer <T> pOutValue = Pointer <T> .AsPointer(ref outValue);

            Type type = typeof(T);

            if (type == typeof(string))
            {
                return(TryParseString(str, ref pOutValue.Convert <string>().Ref));
            }
            else if (type == typeof(bool))
            {
                return(TryParseBool(str, ref pOutValue.Convert <bool>().Ref));
            }
            else if (type == typeof(int))
            {
                return(TryParseInt(str, ref pOutValue.Convert <int>().Ref));
            }
            else if (type == typeof(uint))
            {
                return(TryParseUInt(str, ref pOutValue.Convert <uint>().Ref));
            }
            else if (type == typeof(sbyte))
            {
                return(TryParseSByte(str, ref pOutValue.Convert <sbyte>().Ref));
            }
            else if (type == typeof(byte))
            {
                return(TryParseByte(str, ref pOutValue.Convert <byte>().Ref));
            }
            else if (type == typeof(long))
            {
                return(TryParseLong(str, ref pOutValue.Convert <long>().Ref));
            }
            else if (type == typeof(ulong))
            {
                return(TryParseULong(str, ref pOutValue.Convert <ulong>().Ref));
            }
            else if (type == typeof(short))
            {
                return(TryParseShort(str, ref pOutValue.Convert <short>().Ref));
            }
            else if (type == typeof(ushort))
            {
                return(TryParseUShort(str, ref pOutValue.Convert <ushort>().Ref));
            }
            else if (type == typeof(float))
            {
                return(TryParseFloat(str, ref pOutValue.Convert <float>().Ref));
            }
            else if (type == typeof(double))
            {
                return(TryParseDouble(str, ref pOutValue.Convert <double>().Ref));
            }

            //switch (outValue)
            //{
            //    case string:
            //        return TryParseString(str, ref pOutValue.Convert<string>().Ref);
            //    case bool:
            //        return TryParseBool(str, ref pOutValue.Convert<bool>().Ref);
            //    case int:
            //        return TryParseInt(str, ref pOutValue.Convert<int>().Ref);
            //    case byte:
            //        return TryParseByte(str, ref pOutValue.Convert<byte>().Ref);
            //    case float:
            //        return TryParseFloat(str, ref pOutValue.Convert<float>().Ref);
            //    case double:
            //        return TryParseDouble(str, ref pOutValue.Convert<double>().Ref);
            //    default:
            //        break;
            //}
            return(false);
        }