Example #1
0
        //GameObject Inits



        //Upon creation, pull all the required song info from the metadata. Additionally, Pull the Notes and insert into an array.
        public void OnInit(InitContext context)
        {
            Notes = new Queue <GameObject>();
            //Initialize generic note. The default note is in the Up Position.



            //Read Beats
            StreamReader x = new StreamReader(FileOp.Open("Data\\Songs\\DemoSong\\meta.smta", FileAccessMode.Read));

            if (UInt16.TryParse(x.ReadLine(), out ushort BPM))
            {
                FramesPerBeat = (int)Math.Ceiling((decimal)3600 / BPM);
                x.Dispose();
            }
            else
            {
                failcode = 1;
            }
            x = new StreamReader(FileOp.Open("Data\\Songs\\DemoSong\\beats.spmp", FileAccessMode.Read));
            while (!x.EndOfStream)
            {
                if (Byte.TryParse(x.ReadLine(), out Byte note))
                {
                    Notes.Enqueue(CreateNote(note));
                }
                else
                {
                    Notes.Enqueue(null);
                }
            }
        }
 public virtual void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         CmdOverlay.AddCommands(this);
     }
 }
Example #3
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         this.MakeCurrent();
     }
 }
Example #4
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (DualityApp.ExecContext != DualityApp.ExecutionContext.Editor && context == InitContext.Activate)
     {
         this.MakeCurrent();
     }
 }
Example #5
0
 public void OnInit(InitContext context)
 {
     if (Duality.DualityApp.ExecContext == DualityApp.ExecutionContext.Game && context == InitContext.Activate)
     {
         humperObject = new PlayerHumper(GameObj.GetComponent <Player>());
     }
 }
Example #6
0
            protected override object MapInternal(InitContext initContext)
            {
                var dr = initContext.SourceObject as FbDataReader;

                // Fb's SP returns single row with nulls if selected object doesn't exists
                // so for all DBNull's (null) should be returned, instead of object instance
                //
                if (dr != null)
                {
                    var i = dr.FieldCount;
                    while (--i >= 0)
                    {
                        if (!dr.IsDBNull(i))
                        {
                            break;
                        }
                    }

                    // All field are DBNull.
                    //
                    if (i < 0)
                    {
                        return(null);
                    }
                }
                return(base.MapInternal(initContext));
            }
Example #7
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         Generate();
     }
 }
Example #8
0
        public void OnInit(InitContext context)
        {
            if (context == InitContext.Activate)
            {
                var  res  = DualityApp.TargetResolution;
                Rect rect = new Rect(res);

                var body      = GameObj.GetComponent <RigidBody>();
                var transform = GameObj.GetComponent <Transform>();
                transform.Scale = 1.33f;

                Vector2 tlPoint = new Vector2(-rect.Size.X / 2, -rect.Size.Y / 2);
                Vector2 trPoint = new Vector2(rect.Size.X / 2, -rect.Size.Y / 2);
                Vector2 brPoint = new Vector2(rect.Size.X / 2, rect.Size.Y / 2);
                Vector2 blPoint = new Vector2(-rect.Size.X / 2, rect.Size.Y / 2);

                ShapeInfo shape = new LoopShapeInfo
                {
                    Vertices = new[]
                    {
                        tlPoint,
                        trPoint,
                        brPoint,
                        blPoint
                    }
                };

                shape.IsSensor = true;

                if (!body.Shapes.Any())
                {
                    body.AddShape(shape);
                }
            }
        }
Example #9
0
        public void OnInit(InitContext context)
        {
            if (Script.IsExplicitNull || !Script.IsAvailable)
            {
                return;
            }

            if (context == InitContext.Loaded)
            {
                _engine = new PythonExecutionEngine(Script.Res.Content);
                _engine.SetVariable("game_object", GameObj);
            }

            if (_engine != null)
            {
                // I can't find a way to retrieve single variables from the code
                // that's why we need a function (method that returns an object)
                if (_engine.HasMethod("bound_radius"))
                {
                    boundRadius = Convert.ToSingle(_engine.CallFunction("bound_radius"));
                }

                if (_engine.HasMethod("start"))
                {
                    _engine.CallMethod("start", context);
                }
            }
        }
Example #10
0
 public void OnInit(InitContext context)
 {
     _zoom       = (MinZoom + MaxZoom) / 2;
     _lastZoom   = _zoom;
     _targetZoom = _zoom;
     _time       = 1;
 }
Example #11
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         _speed = MathF.Rnd.NextFloat(1.0f, 3.5f);
     }
 }
Example #12
0
        private async Task <string> GetListText(InitContext ctx)
        {
            var sb = new StringBuilder();

            sb.Append("\u200B\n");
            //sb.Append("```");

            foreach (var item in ctx.State.Characters)
            {
                var playerName = await GetUserLocalName(ctx.ResultChannel.Guild, item.PlayerID);

                if (item.Initiative == ctx.State.CurrentInitiative)
                {
                    sb.Append("**");
                }

                sb.Append(string.Format(
                              "[{0}] {1} ({2})",
                              item.Initiative,
                              item.DisplayName,
                              playerName));

                if (item.Initiative == ctx.State.CurrentInitiative)
                {
                    sb.Append("**");
                }

                sb.Append("\n");
            }
            //sb.Append("```");

            return(sb.ToString());
        }
Example #13
0
        private async Task <string> GetCurrentPoseText(InitContext ctx)
        {
            var currInit   = ctx.State.GetCurrent();
            var playerName = Context.Guild.GetUser(currInit.PlayerID).Mention;

            return($"Next Pose: {currInit.DisplayName} ({playerName})");
        }
Example #14
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         UpdateShape();
     }
 }
Example #15
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         WasInitialized = true;
     }
 }
Example #16
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecContext == DualityApp.ExecutionContext.Game)
     {
         DualityApp.Mouse.ButtonDown += Mouse_ButtonDown;
     }
 }
Example #17
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.AddToGameObject ||
         context == InitContext.Loaded)
     {
         this.gameobj.EventParentChanged += this.gameobj_EventParentChanged;
         if (this.gameobj.Parent != null)
         {
             this.parentTransform = this.gameobj.Parent.Transform;
             if (this.parentTransform == null)
             {
                 this.gameobj.Parent.EventComponentAdded += this.Parent_EventComponentAdded;
             }
             else
             {
                 this.gameobj.Parent.EventComponentRemoving += this.Parent_EventComponentRemoving;
             }
         }
         else
         {
             this.parentTransform = null;
         }
         this.UpdateRel();
     }
 }
Example #18
0
 public AbstractNestedObject(InitContext ic)
 {
     if (ic.MemberParameters != null && ic.MemberParameters.Length > 0)
     {
         ID = Convert.ToInt32(ic.MemberParameters[0]);
     }
 }
Example #19
0
 public virtual void BeginMapping(InitContext initContext)
 {
     if (initContext.IsDestination)
     {
         _noTrackingChangesCount++;
     }
 }
Example #20
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         _coroutine = new Coroutine(Run());
     }
 }
Example #21
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecContext == DualityApp.ExecutionContext.Game)
     {
         Initialize();
     }
 }
 public void OnInit(InitContext context)
 {
     currentDifficulty        = 0;
     currentTimeBetweenSpawns = InitialTimeBetweenSpawns;
     lastSpawnTime            = 0;
     sunkShips = 0;
 }
Example #23
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Loaded)
     {
         this.text.ApplySource();
     }
 }
Example #24
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecContext == DualityApp.ExecutionContext.Game)
     {
         DualityApp.Keyboard.KeyDown += OnKeyDown;
     }
 }
Example #25
0
 public static DataAccessor CreateInstance(
     Type type,
     InitContext context,
     DbManager dbManager)
 {
     return(CreateInstance(type, context, dbManager, false));
 }
Example #26
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         body = GameObj.GetComponent <RigidBody>();
     }
 }
Example #27
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         this.carryType = MathF.Rnd.Next(1, 5);
     }
 }
 public void OnInit(InitContext context)
 {
     if (context != InitContext.Activate)
         return;
     _playerWood = Scene.Current.FindComponent<Player>().GameObj.GetComponent<WoodComponent>();
     _logs = new List<GameObject>();
 }
Example #29
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecContext == DualityApp.ExecutionContext.Game)
     {
         currentHealth = MaxHealth;
     }
 }
Example #30
0
        void ICmpInitializable.OnInit(InitContext context)
        {
            if (context == InitContext.AddToGameObject ||
                context == InitContext.Loaded)
            {
                this.parentTransform = null;
                if (this.gameobj != null)
                {
                    this.gameobj.EventParentChanged += this.gameobj_EventParentChanged;
                    if (this.gameobj.Parent != null)
                    {
                        this.parentTransform = this.gameobj.Parent.Transform;
                        if (this.parentTransform == null)
                        {
                            this.gameobj.Parent.EventComponentAdded += this.Parent_EventComponentAdded;
                        }
                        else
                        {
                            this.gameobj.Parent.EventComponentRemoving += this.Parent_EventComponentRemoving;
                        }
                    }
                }
                this.UpdateRel();
            }

            // Since we're not serializing rotation dir values, recalculate them on load
            if (context == InitContext.Loaded)
            {
                this.UpdateRotationDirAbs();
            }
        }
Example #31
0
 public virtual void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         AttachToParent();
     }
 }
Example #32
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         _woodComponent = GameObj.GetComponent<WoodComponent>();
     }
 }
Example #33
0
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate && DualityApp.ExecContext == DualityApp.ExecutionContext.Game)
     {
         switchTime = Time.GameTimer + TimeSpan.FromSeconds(SwitchTime);
     }
 }
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         _fallSpeed = MathF.Rnd.NextFloat(4, 7);
         _randomSway = MathF.Rnd.NextFloat(0, 1);
     }
 }
		void ICmpInitializable.OnInit(InitContext context)
		{
			if (context == InitContext.Activate)
			{
				Camera camera = this.GameObj.GetComponent<Camera>();
				this.GameObj.Parent = this.targetObj;
				this.GameObj.Transform.RelativePos = new Vector3(0.0f, 0.0f, -camera.FocusDist);
			}
		}
 public void OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         _lifetime = MathF.Rnd.NextFloat(0.3f, 0.4f);
         _spawnTime = Time.GameTimer.TotalSeconds;
         _randomSway = MathF.Rnd.NextFloat(0, 1);
     }
 }
Example #37
0
        public void OnInit(InitContext context)
        {
            if (context != InitContext.Activate)
                return;

            _player = Scene.Current.FindComponent<Player>();
            _playerWood = _player.GameObj.GetComponent<WoodComponent>();
            _woodComponent = GameObj.GetComponent<WoodComponent>();
            _spriteRenderer = GameObj.Renderer as SpriteRenderer;
        }
        public void OnInit(InitContext context)
        {
            if (context != InitContext.Activate)
                return;

            _player = Scene.Current.FindComponent<Player>();
            _playerWood = _player.GameObj.GetComponent<WoodComponent>();
            _snowSkirt = Scene.Current.FindComponent<SnowSkirt>();
            _flames = GameObj.Children.ToList();
            _currentWood = MaxWoodCount;
        }
        public void OnInit(InitContext context)
        {
            if(context == InitContext.AddToGameObject)
            {
                this.env = (Environment)GameObj.GetComponent(typeof(Environment));
                RigidBody body = (RigidBody)GameObj.GetComponent(typeof(RigidBody));
                body.BodyType = BodyType.Static;

                Vector2[][] vectors = new Vector2[4][];
                int triangleSideLength = env.TriangleSideLength;

                vectors[0] = new Vector2[3];
                vectors[0][0] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
                vectors[0][1] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
                vectors[0][2] = new Vector2(0, 0);

                vectors[1] = new Vector2[3];
                vectors[1][0] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
                vectors[1][1] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
                vectors[1][2] = new Vector2(0, 0);

                vectors[2] = new Vector2[3];
                vectors[2][0] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
                vectors[2][1] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
                vectors[2][2] = new Vector2(0, 0);

                vectors[3] = new Vector2[3];
                vectors[3][0] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
                vectors[3][1] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
                vectors[3][2] = new Vector2(0, 0);

                for (int x = 0; x < env.Triangles.GetLength(0); x++)
                {
                    for (int y = 0; y < env.Triangles.GetLength(1); y++)
                    {
                        int i = 0;
                        Vector2[] vertices = new Vector2[vectors[i].Length];
                        for (int v = 0; v < vectors[i].Length; v++)
                        {
                            vertices[v] = new Vector2(vectors[i][v].X + triangleSideLength / 2 + triangleSideLength * x,
                                vectors[i][v].Y + triangleSideLength / 2 + triangleSideLength * y);
                        }
                        PolyShapeInfo shape = new PolyShapeInfo(vertices, 0);
                        body.AddShape(shape);
                    }
                }
            }
        }
        public void OnInit(InitContext context)
        {
            if (context == InitContext.Activate)
            {
                _defaultOffset = Offset;

                if (TrackedObject == null)
                    return;

                _trackedObjectTransform = TrackedObject.GetComponent<Transform>();
                if (_trackedObjectTransform == null)
                {
                    Log.Game.WriteError("{0} is tracking {1} which doesn't have a transform component.", GameObj, TrackedObject);
                }
            }
        }
Example #41
0
        public void OnInit(InitContext context)
        {
            scriptable = (Scriptable)GameObj.GetComponent(typeof(Scriptable));

            keyDownScripts = new MGFunction[Enum.GetValues(typeof(Key)).Length];
            keyUpScripts = new MGFunction[Enum.GetValues(typeof(Key)).Length];
            whileKeyDownScripts = new MGFunction[Enum.GetValues(typeof(Key)).Length];

            foreach (Key key in Enum.GetValues(typeof(Key)))
            {
                keyDownScripts[(int)key] = scriptable.EncaseInFunction("if(typeof " + key.ToString() + "_Down === 'function') { " + key.ToString() + "_Down() }");
                keyUpScripts[(int)key] = scriptable.EncaseInFunction("if(typeof " + key.ToString() + "_Up === 'function') { " + key.ToString() + "_Up() }");
                whileKeyDownScripts[(int)key] = scriptable.EncaseInFunction("if(typeof " + key.ToString() + "_WhileDown) === 'function') { " + key.ToString() + "_WhileDown() }");
            }

            Magic_GameCorePlugin.Instance.AddInputProcessor(this);
        }
        public void OnInit(InitContext context)
        {
            body = (RigidBody)GameObj.GetComponent(typeof(RigidBody));

            jumpsRemaining = NumberOfJumps;
            direction = 0;
            jumpNextFrame = false;

            Scriptable scriptable = (Scriptable)GameObj.GetComponent(typeof(Scriptable));
            if(scriptable != null)
            {
                PlayerApi player = new PlayerApi(scriptable.engine, this);
                scriptable.AddObject("Player", player);
                scriptable.Evaluate("A_Down = function() { Player.MoveLeft() };" +
                    "D_Down = function() { Player.MoveRight() };" +
                    "D_Up = function() { Player.Stop() };" +
                    "A_Up = function() { Player.Stop() };" +
                    "Space_Down = function() { Player.Jump() };");

            }
        }
 public void OnInit(InitContext context)
 {
     _currentWood = StartingWoodCount;
 }
Example #44
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.Activate)
     {
         // Do some cleanup before updating again
         this.RemoveDisposedJoints();
         // Initialize the backing Farseer objects upon activation
         this.Initialize();
     }
     else if (context == InitContext.AddToGameObject && DualityApp.ExecContext == DualityApp.ExecutionContext.Editor)
     {
         // Add a default shape when creating a new RigidBody in the editor
         this.AddShape(new CircleShapeInfo(128.0f, Vector2.Zero, 1.0f));
     }
 }
Example #45
0
 public void OnInit(InitContext context)
 {
     if(context == InitContext.Activate)
         WasInitialized = true;
 }
Example #46
0
		void ICmpInitializable.OnInit(InitContext context)
		{
			if (context == InitContext.Activate)
				this.Initialize();
			else if (context == InitContext.Loaded)
				this.RemoveDisposedJoints();
		}
 public void OnInit(InitContext context)
 {
 }
Example #48
0
		void ICmpInitializable.OnInit(InitContext context)
		{
			if (context == InitContext.Activate)
			{
				// Do some cleanup before updating again
				this.RemoveDisposedJoints();
				// Initialize the backing Farseer objects upon activation
				this.Initialize();
			}
		}
		public virtual void EndMapping(InitContext initContext)
		{
			if (initContext.IsDestination)
			{
				AcceptChanges();
				_noTrackingChangesCount--;
			}
		}
Example #50
0
 void ICmpInitializable.OnInit(InitContext context)
 {
 }
Example #51
0
		object IDataContext.CreateInstance(InitContext context)
		{
			return null;
		}
        public void OnInit(InitContext context)
        {
            if (context != InitContext.Activate || DualityApp.ExecContext == DualityApp.ExecutionContext.Editor)
                return;

            if (string.IsNullOrEmpty(_fileName))
                return;

            if (Environment.Is64BitProcess)
            {
                Log.Editor.WriteWarning("The video player is not supported on 64 bit processes, and this is one.");
                return;
            }

            Play();
        }
Example #53
0
 void ICmpInitializable.OnInit(InitContext context)
 {
     if (context == InitContext.AddToGameObject ||
         context == InitContext.Loaded)
     {
         this.gameobj.EventParentChanged += this.gameobj_EventParentChanged;
         if (this.gameobj.Parent != null)
         {
             this.parentTransform = this.gameobj.Parent.Transform;
             if (this.parentTransform == null)
                 this.gameobj.Parent.EventComponentAdded += this.Parent_EventComponentAdded;
             else
                 this.gameobj.Parent.EventComponentRemoving += this.Parent_EventComponentRemoving;
         }
         else
             this.parentTransform = null;
         this.UpdateRel();
     }
 }
		void ICmpInitializable.OnInit(InitContext context)
		{
			if (DualityApp.ExecContext != DualityApp.ExecutionContext.Editor && context == InitContext.Activate)
				this.MakeCurrent();
		}
Example #55
0
 public void OnInit(InitContext context)
 {
     transform = (Transform)GameObj.GetComponent(typeof(Transform));
 }
Example #56
0
		void ICmpInitializable.OnInit(InitContext context)
		{
			if (context == InitContext.Loaded)
				this.text.ApplySource();
		}
Example #57
0
	public TestObject(InitContext ctx)
	{
		this._firstName = new EditableValue<string>("");
		this._lastName  = new EditableValue<string>("");
	}
Example #58
0
			void ICmpInitializable.OnInit(InitContext context)
			{
				if (context == InitContext.Activate)
				{
					Scene last = Scene.Current;
					Scene.SwitchTo(Target);
					this.Switched = (last != Scene.Current && Scene.Current == Target);
				}
			}
		public virtual void BeginMapping(InitContext initContext)
		{
			if (initContext.IsDestination)
				_noTrackingChangesCount++;
		}
Example #60
0
        public void OnInit(InitContext context)
        {
            if(context == InitContext.Activate)
            {
                Theme redBlue = new Theme();
                redBlue.ForegroundColour = ColorRgba.Red;
                redBlue.BackgroundColour = ColorRgba.Blue;

                Theme greenWhite = new Theme();
                greenWhite.ForegroundColour = ColorRgba.Green;
                greenWhite.BackgroundColour = ColorRgba.White;

                Window window = new Window();
                window.H = 100;
                window.W = 300;
                window.OffsetX = 20;
                window.OffsetY = 20;
                window.Theme = redBlue;

                TextBox text = new TextBox();
                text.Theme = greenWhite;
                text.H = 50;
                text.AnchorRight = new Anchor(10);
                text.AnchorLeft = new Anchor(10);
                text.AnchorTop = new Anchor(30);
                text.AnchorBottom = new Anchor(10);
                window.Controls.Add(text);

                this.baseControl = window;

                Magic_GameCorePlugin.Instance.AddInputProcessor(this);
            }
        }