Ejemplo n.º 1
0
        protected override void OnLoaded()
        {
            switch (this.worldObject.ProtoStaticWorldObject)
            {
            case IProtoObjectElectricityProducer:
            {
                var publicState = this.worldObject.GetPublicState <IObjectElectricityProducerPublicState>();
                this.viewModel = new ViewModelPowerStateOverlay(publicState);
                break;
            }

            case IProtoObjectElectricityConsumer:
            {
                var publicState = this.worldObject.GetPublicState <IObjectElectricityConsumerPublicState>();
                this.viewModel = new ViewModelPowerStateOverlay(publicState);
                break;
            }

            default:
                Api.Logger.Error("The object is not an electricity consumer or producer: " + this.worldObject);
                return;
            }

            this.DataContext = this.viewModel;
        }
Ejemplo n.º 2
0
 protected override void OnUnloaded()
 {
     this.DataContext = null;
     this.viewModel?.Dispose();
     this.viewModel = null;
 }