GithubHelp home page GithubHelp logo

goodcatgames / ecslite-multiple-shared Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 4.0 7 KB

LeoECS Lite Multiple Shared Injection

License: MIT License

C# 100.00%
unity ecs unity3d leoecslite leoecs-lite

ecslite-multiple-shared's Introduction

Multiple shared injection for LeoEcsLite C# Entity Component System framework

Dependency injection for LeoECS Lite.

Tested on unity 2020.3 (not dependent on it) and contains assembly definition for compiling to separate assembly file for performance reason.

Important! Don't forget to use DEBUG builds for development and RELEASE builds in production: all internal error checks / exception throwing works only in DEBUG builds and eleminated for performance reasons in RELEASE.

Table of content

Socials

discord

Installation

As unity module

This repository can be installed as unity module directly from git url. In this way new line should be added to Packages/manifest.json:

"com.goodcat.ecslite.shared": "https://github.com/GoodCatGames/ecslite-multiple-shared.git"

As source

If you can't / don't want to use unity modules, code can be downloaded as sources archive from Releases page.

Integration to startup

var battleLog = new BattleLog();
IBattleLogView battleLogView = null;
#if DEBUG
   battleLogView = new BattleLogViewText(battleLog);         
#else
   battleLogView = new BattleLogViewHtml(battleLog);         
#endif

// If you use InjectShared() you cannot create systems with SharedCustom:
//    var systems = new EcsSystems (new EcsWorld(), new SharedCustom());
// You will get an exception.

var systems = new EcsSystems(new EcsWorld());
systems
    .Add (new System1())    
    .Add (new System2())    
    .Add (new BattleLogShowSystem())    
    // ...
    
    // InjectShared() methods should be placed after
    // all systems/worlds registration 
    .InjectShared(battleLog)
    .InjectShared<IBattleLogView>(battleLogView)    
    
    // InitShared() method should be placed after 
    // all InjectShared() methods
    .InitShared()        
    .Init();
public class BattleLogShowSystem : IEcsRunSystem
{
  [EcsInject] private readonly BattleLogViewBase _battleLogView;
  
  public void Run(EcsSystems systems)
  {
    _battleLogView.Show();
  }
}
// Getting Shared directly from systems
var shared = systems.GetShared<shared.Shared>();
var battleLogView = shared.Get<IBattleLogView>();
battleLogView.Show();

License

The software is released under the terms of the MIT license.

No personal support or any guarantees.

ecslite-multiple-shared's People

Contributors

goodcatgames avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.