示例#1
0
        public string tossPatch()
        {
            if (!isObject())
            {
                return(string.Empty);
            }

            Item item = ItemData.createItem("HealthKitPatch");

            item["istemp"] = true.AsString();

            item["sourceObject"] = this;
            item["static"]       = false.AsString();

            ((SimSet)"MissionCleanup").pushToBack(item);

            Random r = new Random();

            Point3F vec = new Point3F(-1 + (float)r.NextDouble() * 2, -1 * (float)r.NextDouble() * 2, (float)r.NextDouble());

            vec = vec.vecotrScale(10);
            Point3F eye = getEyeVector();
            float   dot = new Point3F("0 0 1 ").vectorDot(eye);

            if (dot < 0)
            {
                dot = -dot;
            }

            vec = vec + new Point3F("0 0 8").vecotrScale(1 - dot);
            vec = vec + getVelocity();

            TransformF pos = new TransformF(getWorldBox().Get_MinExtents());

            item.setTransform(pos);
            item.applyImpulse(pos.GetPosition(), vec);
            item.setCollisionTimeout(this);

            item.SchedulePop();

            return(item);
        }
示例#2
0
        public override int onThrow(ShapeBase user, int amount)
        {
            if (amount == 0)
            {
                amount = 1;
            }

            if (this["maxInventory"] != string.Empty)
            {
                if (amount > this["maxInventory"].AsInt())
                {
                    amount = this["maxInventory"].AsInt();
                }
            }

            if (!amount.AsBool())
            {
                return(0);
            }

            user.decInventory(this, amount);
            //ShapeBaseShapeBaseDecInventory(player, datablock, amount);

            // Construct the actual object in the world, and add it to
            // the mission group so it's cleaned up when the mission is
            // done.  The object is given a random z rotation.
            ObjectCreator tch = new ObjectCreator("Item", string.Empty);

            tch["datablock"] = this;
            tch["rotation"]  = "0 0 1 " + (new Random().Next(0, 360));
            tch["count"]     = amount;

            Item item = tch.Create();

            ((SimSet)"MissionGroup").pushToBack(item);

            item.SchedulePop();

            return(item);
        }